Skip to content

Instantly share code, notes, and snippets.

@ericmerrill
Created February 10, 2022 04:37
Show Gist options
  • Save ericmerrill/d94fd23fc28ae77aa5936aec6714981d to your computer and use it in GitHub Desktop.
Save ericmerrill/d94fd23fc28ae77aa5936aec6714981d to your computer and use it in GitHub Desktop.
Calculate Moodle code allversionshash without installing
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Calculate all versions hash without installing Moodle.
*
* @copyright 2022 Moodle US
* @author Eric Merrill (eric.merrill@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// This file allows you to get the allversionshash of a Moodle codebase without
// installing Moodle. No datadir, database, or even config.php required.
// Simply place in the root directy of a Moodle codebase and run.
// It will output the all versions hash of the codebase.
global $CFG;
$CFG = new stdClass();
$CFG->dirroot = __DIR__;
$CFG->admin = 'admin';
define('CACHE_DISABLE_ALL', true);
define('IGNORE_COMPONENT_CACHE', true);
define('MOODLE_INTERNAL', true);
require_once(__DIR__.'/lib/classes/component.php');
echo core_component::get_all_versions_hash() . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment