Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * CLI script to purge caches without asking for confirmation.
19
 *
20
 * @package    core
21
 * @subpackage cli
22
 * @copyright  2011 David Mudrak <david@moodle.com>
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
define('CLI_SCRIPT', true);
1441 ariadna 27
define('IGNORE_COMPONENT_CACHE', true);
1 efrain 28
 
29
require(__DIR__.'/../../config.php');
30
require_once($CFG->libdir.'/clilib.php');
31
 
32
$longoptions = [
33
    'help' => false,
34
    'muc' => false,
35
    'courses' => false,
36
    'theme' => false,
37
    'lang' => false,
38
    'js' => false,
39
    'filter' => false,
40
    'other' => false
41
];
42
list($options, $unrecognized) = cli_get_params($longoptions, ['h' => 'help']);
43
 
44
if ($unrecognized) {
45
    $unrecognized = implode("\n  ", $unrecognized);
46
    cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2);
47
}
48
 
49
if ($options['help']) {
50
    // The indentation of this string is "wrong" but this is to avoid a extra whitespace in console output.
51
    $help = <<<EOF
52
Invalidates Moodle internal caches
53
 
54
Specific caches can be defined (alone or in combination) using arguments. If none are specified,
55
all caches will be purged.
56
 
57
Options:
58
-h, --help            Print out this help
59
    --muc             Purge all MUC caches (includes lang cache)
60
    --courses         Purge all course caches (or only those specified by a comma-separated list).
61
                      e.g. --courses=4,67,145
62
    --theme           Purge theme cache
63
    --lang            Purge language string cache
64
    --js              Purge JavaScript cache
65
    --filter          Purge text filter cache
66
    --other           Purge all file caches and other miscellaneous caches (may include MUC
67
                      if using cachestore_file).
68
 
69
Example:
70
\$ sudo -u www-data /usr/bin/php admin/cli/purge_caches.php
71
 
72
EOF;
73
 
74
    echo $help;
75
    exit(0);
76
}
77
 
78
purge_caches(array_filter($options));
79
 
80
exit(0);