flush-definition-cache.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/php
  2. <?php
  3. chdir(dirname(__FILE__));
  4. require_once 'common.php';
  5. assertCli();
  6. /**
  7. * @file
  8. * Flushes the definition serial cache. This file should be
  9. * called if changes to any subclasses of HTMLPurifier_Definition
  10. * or related classes (such as HTMLPurifier_HTMLModule) are made. This
  11. * may also be necessary if you've modified a customized version.
  12. *
  13. * @param Accepts one argument, cache type to flush; otherwise flushes all
  14. * the caches.
  15. */
  16. echo "Flushing cache... \n";
  17. require_once(dirname(__FILE__) . '/../library/HTMLPurifier.auto.php');
  18. $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. throw new Exception("Cache parameter {$argv[1]} is not a valid cache");
  25. }
  26. }
  27. foreach ($names as $name) {
  28. echo " - Flushing $name\n";
  29. $cache = new HTMLPurifier_DefinitionCache_Serializer($name);
  30. $cache->flush($config);
  31. }
  32. echo "Cache flushed successfully.\n";
  33. // vim: et sw=4 sts=4