Proyectos de Subversion Moodle

Rev

| 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);
27
 
28
require(__DIR__.'/../../config.php');
29
require_once($CFG->libdir.'/clilib.php');
30
 
31
$longoptions = [
32
    'help' => false,
33
    'muc' => false,
34
    'courses' => false,
35
    'theme' => false,
36
    'lang' => false,
37
    'js' => false,
38
    'filter' => false,
39
    'other' => false
40
];
41
list($options, $unrecognized) = cli_get_params($longoptions, ['h' => 'help']);
42
 
43
if ($unrecognized) {
44
    $unrecognized = implode("\n  ", $unrecognized);
45
    cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2);
46
}
47
 
48
if ($options['help']) {
49
    // The indentation of this string is "wrong" but this is to avoid a extra whitespace in console output.
50
    $help = <<<EOF
51
Invalidates Moodle internal caches
52
 
53
Specific caches can be defined (alone or in combination) using arguments. If none are specified,
54
all caches will be purged.
55
 
56
Options:
57
-h, --help            Print out this help
58
    --muc             Purge all MUC caches (includes lang cache)
59
    --courses         Purge all course caches (or only those specified by a comma-separated list).
60
                      e.g. --courses=4,67,145
61
    --theme           Purge theme cache
62
    --lang            Purge language string cache
63
    --js              Purge JavaScript cache
64
    --filter          Purge text filter cache
65
    --other           Purge all file caches and other miscellaneous caches (may include MUC
66
                      if using cachestore_file).
67
 
68
Example:
69
\$ sudo -u www-data /usr/bin/php admin/cli/purge_caches.php
70
 
71
EOF;
72
 
73
    echo $help;
74
    exit(0);
75
}
76
 
77
purge_caches(array_filter($options));
78
 
79
exit(0);