Skip to content

Commit

Permalink
Revert "#108310 add changes to loading config file and add new option…
Browse files Browse the repository at this point in the history
… to fix session issue for Moodle4.5"

This reverts commit b81c588.
  • Loading branch information
Tomek Muras committed Jan 10, 2025
1 parent 8d8797d commit f10fdbc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 111 deletions.
70 changes: 0 additions & 70 deletions Moosh/Command/Moodle45/Cache/CacheAddRedisStore.php

This file was deleted.

65 changes: 24 additions & 41 deletions moosh.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
$appspecs->add('u|user:', "Moodle user, by default ADMIN");
$appspecs->add('n|no-user-check', "Don't check if Moodle data is owned by the user running script");
$appspecs->add('t|performance', "Show performance information including timings");
$appspecs->add('o|options:', "Change any setting in config.php");
$appspecs->add('h|help', "Show global help.");
$appspecs->add('list-commands', "Show all possible commands");

Expand Down Expand Up @@ -194,34 +193,32 @@ function cli_error($text, $errorcode = 1) {
*/
$subcommand = $subcommands[$subcommand];
$bootstrap_level = $subcommand->bootstrapLevel();

// Manually retrieve the information from config.php
$config = [];
if(!file_exists($top_dir . '/config.php')) {
cli_error('config.php not found.');
}
exec("php -w " . $top_dir . "/config.php", $config);
if (count($config) == 0) {
cli_error("config.php does not look right to me.");
}
$config = implode("\n", $config);
$config = str_ireplace('<?php', '', $config);
$config = str_replace('require_once', '//require_once', $config);

eval($config);
if(!isset($CFG)) {
cli_error('After evaluating config.php, $CFG is not set');
}
if($app_options->has('verbose')) {
echo '$CFG - ';
print_r($CFG);
}

if ($bootstrap_level === MooshCommand::$BOOTSTRAP_NONE ) {
// Do nothing really.
// Do nothing really.
} else if($bootstrap_level === MooshCommand::$BOOTSTRAP_DB_ONLY) {
// Manually retrieve the information from config.php
// and create $DB object.
$config = [];
if(!file_exists($top_dir . '/config.php')) {
cli_error('config.php not found.');
}
exec("php -w " . $top_dir . "/config.php", $config);
if (count($config) == 0) {
cli_error("config.php does not look right to me.");
}
$config = implode("\n", $config);
$config = str_ireplace('<?php', '', $config);
$config = str_replace('require_once', '//require_once', $config);

eval($config);
if(!isset($CFG)) {
cli_error('After evaluating config.php, $CFG is not set');
}
if($app_options->has('verbose')) {
echo '$CFG - ';
print_r($CFG);
}

// create $DB object
$CFG->libdir = $moosh_dir . "/includes/moodle/lib/";
$CFG->debugdeveloper = false;

Expand Down Expand Up @@ -253,25 +250,11 @@ function string_exists() {
define('ABORT_AFTER_CONFIG', true);
}

$CFG->dirroot = $top_dir;

if ($app_options->has('options')) {
$option_value = $app_options['options']->value;
list($key, $value) = explode('=', $option_value, 2);

if (isset($CFG->$key)) {
if ($value == 'null') {
$value = null;
}
$CFG->$key = $value;
}
}

if (!$top_dir) {
echo "Could not find Moodle installation!\n";
exit(1);
}
require_once($top_dir . "/lib/setup.php");
require_once($top_dir . '/config.php');

$shell_user = false;
if (!$app_options->has('no-user-check')) {
Expand Down

0 comments on commit f10fdbc

Please sign in to comment.