require __DIR__ . '/../../config.php'; require_once $CFG->libdir . '/clilib.php'; // Now get cli options. list($options, $unrecognized) = cli_get_params(array('file' => false, 'rebuild' => false, 'print' => false, 'help' => false), array('h' => 'help')); if ($unrecognized) { $unrecognized = implode("\n ", $unrecognized); cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2); } if (!$options['rebuild'] and !$options['file'] and !$options['print']) { $help = "Create alternative component cache file\n\nOptions:\n-h, --help Print out this help\n--rebuild Rebuild \$CFG->alternative_component_cache file\n--file=filepath Save component cache to file\n--print Print component cache file content\n\nExample:\n\$ php admin/cli/rebuild_alternative_component_cache.php --rebuild\n"; echo $help; exit(0); } error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 1); $content = core_component::get_cache_content(); if ($options['print']) { echo $content; exit(0); } if ($options['rebuild']) { if (empty($CFG->alternative_component_cache)) { fwrite(STDERR, 'config.php does not contain $CFG->alternative_component_cache setting'); fwrite(STDERR, "\n"); exit(2); } $target = $CFG->alternative_component_cache; } else { $target = $options['file']; } if (!$target) {