Use info_parent_def to get parent information, since it may not be present in info...
[htmlpurifier.git] / maintenance / flush-definition-cache.php
blob138badb659f77e5323098bdaf167729d4e9d2abb
1 #!/usr/bin/php
2 <?php
4 chdir(dirname(__FILE__));
5 require_once 'common.php';
6 assertCli();
8 /**
9 * @file
10 * Flushes the definition serial cache. This file should be
11 * called if changes to any subclasses of HTMLPurifier_Definition
12 * or related classes (such as HTMLPurifier_HTMLModule) are made. This
13 * may also be necessary if you've modified a customized version.
15 * @param Accepts one argument, cache type to flush; otherwise flushes all
16 * the caches.
19 echo "Flushing cache... \n";
21 require_once(dirname(__FILE__) . '/../library/HTMLPurifier.auto.php');
23 $config = HTMLPurifier_Config::createDefault();
25 $names = array('HTML', 'CSS', 'URI', 'Test');
26 if (isset($argv[1])) {
27 if (in_array($argv[1], $names)) {
28 $names = array($argv[1]);
29 } else {
30 throw new Exception("Cache parameter {$argv[1]} is not a valid cache");
34 foreach ($names as $name) {
35 echo " - Flushing $name\n";
36 $cache = new HTMLPurifier_DefinitionCache_Serializer($name);
37 $cache->flush($config);
40 echo "Cache flushed successfully.\n";
42 // vim: et sw=4 sts=4