Release 2.1.0, merged in 1313 to HEAD.
[htmlpurifier.git] / maintenance / flush-definition-cache.php
blob6d51ab06c49253cb3d86afc953986292245bc737
1 #!/usr/bin/php
2 <?php
4 require_once 'common.php';
5 assertCli();
7 /**
8 * Flushes the default HTMLDefinition serial cache
9 * @param Accepts one argument, cache type to flush; otherwise flushes all
10 * the caches.
13 echo "Flushing cache... \n";
15 require_once(dirname(__FILE__) . '/../library/HTMLPurifier.auto.php');
17 $config = HTMLPurifier_Config::createDefault();
19 $names = array('HTML', 'CSS', 'URI', 'Test');
20 if (isset($argv[1])) {
21 if (in_array($argv[1], $names)) {
22 $names = array($argv[1]);
23 } else {
24 echo "Did not recognized cache parameter {$argv[1]} as valid cache, aborting.\n";
25 exit;
29 foreach ($names as $name) {
30 echo " - Flushing $name\n";
31 $cache = new HTMLPurifier_DefinitionCache_Serializer($name);
32 $cache->flush($config);
35 echo 'Cache flushed successfully.';