diff --git a/moosh.php b/moosh.php index 4d57ff64..04b42990 100755 --- a/moosh.php +++ b/moosh.php @@ -35,8 +35,9 @@ define('MOOSH_VERSION', '1.21'); define('MOODLE_INTERNAL', true); -$appspecs = new OptionCollection; -$spec_verbose = $appspecs->add('v|verbose', "be verbose"); +// suppressing warnings for php > 8 +$appspecs = @new OptionCollection; +$spec_verbose = @$appspecs->add('v|verbose', "be verbose"); $appspecs->add('p|moodle-path:', "Moodle directory."); $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"); @@ -44,8 +45,8 @@ $appspecs->add('h|help', "Show global help."); $appspecs->add('list-commands', "Show all possible commands"); -$parser = new ContinuousOptionParser($appspecs); -$app_options = $parser->parse($argv); +$parser = @new ContinuousOptionParser($appspecs); +$app_options = @$parser->parse($argv); if ($app_options->has('moodle-path')) { $top_dir = $app_options['moodle-path']->value; @@ -248,6 +249,7 @@ function string_exists() { if ($subcommand->bootstrapLevel() == MooshCommand::$BOOTSTRAP_CONFIG) { define('ABORT_AFTER_CONFIG', true); } + if (!$top_dir) { echo "Could not find Moodle installation!\n"; exit(1);