From e4ce3362a5a4857cd569c2670581aeaa48f4c3f5 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 24 Feb 2008 05:06:39 +0000 Subject: [PATCH] Some maintenance script cleanup - Create super-script flush.php - Rename old scripts with old- prefix. git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1574 48356398-32a2-884e-a903-53898d9a118a --- maintenance/flush.php | 23 +++++++++++++++++++ maintenance/generate-includes.php | 4 ++++ maintenance/generate-schema-cache.php | 7 ++---- maintenance/generate-standalone.php | 3 +++ ...ract-schema.php => old-extract-schema.php} | 3 +++ ...e-once.php => old-remove-require-once.php} | 4 ++-- ...hema-def.php => old-remove-schema-def.php} | 0 tests/index.php | 4 +--- tests/multitest.php | 8 ++----- 9 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 maintenance/flush.php rename maintenance/{extract-schema.php => old-extract-schema.php} (95%) rename maintenance/{remove-require-once.php => old-remove-require-once.php} (87%) rename maintenance/{remove-schema-def.php => old-remove-schema-def.php} (100%) diff --git a/maintenance/flush.php b/maintenance/flush.php new file mode 100644 index 00000000..5cf5e88b --- /dev/null +++ b/maintenance/flush.php @@ -0,0 +1,23 @@ +#!/usr/bin/php +globr('.', '*.php'); $files = array(); foreach ($raw_files as $file) { @@ -42,6 +43,7 @@ foreach ($raw_files as $file) { if (in_array($file, $exclude_files)) continue; // rm excluded files $files[] = $file; } +echo "done!\n"; // Reorder list so that dependencies are included first: @@ -145,4 +147,6 @@ foreach ($files as $file) { $php .= "require '$file';" . PHP_EOL; } +echo "Writing file... "; file_put_contents('HTMLPurifier.includes.php', $php); +echo "done!\n"; diff --git a/maintenance/generate-schema-cache.php b/maintenance/generate-schema-cache.php index 3e86c7db..642d1898 100644 --- a/maintenance/generate-schema-cache.php +++ b/maintenance/generate-schema-cache.php @@ -15,11 +15,6 @@ assertCli(); $target = '../library/HTMLPurifier/ConfigSchema/schema.ser'; $FS = new FSTools(); -if (file_exists($target)) { - echo "Delete HTMLPurifier/ConfigSchema/schema.ser before running this script."; - exit; -} - $files = $FS->globr('../library/HTMLPurifier/ConfigSchema', '*.txt'); $namespaces = array(); @@ -42,4 +37,6 @@ $schema = new HTMLPurifier_ConfigSchema(); foreach ($namespaces as $hash) $adapter->adapt($hash, $schema); foreach ($directives as $hash) $adapter->adapt($hash, $schema); +echo "Saving schema... "; file_put_contents($target, serialize($schema)); +echo "done!\n"; diff --git a/maintenance/generate-standalone.php b/maintenance/generate-standalone.php index 8c92544c..7bba7712 100755 --- a/maintenance/generate-standalone.php +++ b/maintenance/generate-standalone.php @@ -108,7 +108,10 @@ function replace_includes_callback($matches) { return replace_includes(remove_php_tags(file_get_contents($file))); } +echo 'Generating includes file... '; shell_exec('php generate-includes.php'); +echo "done!\n"; + chdir(dirname(__FILE__) . '/../library/'); echo 'Creating full file...'; diff --git a/maintenance/extract-schema.php b/maintenance/old-extract-schema.php similarity index 95% rename from maintenance/extract-schema.php rename to maintenance/old-extract-schema.php index 61899af1..e1283362 100644 --- a/maintenance/extract-schema.php +++ b/maintenance/old-extract-schema.php @@ -5,6 +5,9 @@ chdir(dirname(__FILE__)); require_once 'common.php'; assertCli(); +echo "Please do not run this script. It is here for historical purposes only."; +exit; + /** * @file * Extracts all definitions inside a configuration schema diff --git a/maintenance/remove-require-once.php b/maintenance/old-remove-require-once.php similarity index 87% rename from maintenance/remove-require-once.php rename to maintenance/old-remove-require-once.php index 6cb4ed71..57bb472f 100644 --- a/maintenance/remove-require-once.php +++ b/maintenance/old-remove-require-once.php @@ -5,8 +5,8 @@ chdir(dirname(__FILE__)); require_once 'common.php'; assertCli(); -//echo "Please do not run this script. It is here for historical purposes only."; -//exit; +echo "Please do not run this script. It is here for historical purposes only."; +exit; /** * @file diff --git a/maintenance/remove-schema-def.php b/maintenance/old-remove-schema-def.php similarity index 100% rename from maintenance/remove-schema-def.php rename to maintenance/old-remove-schema-def.php diff --git a/tests/index.php b/tests/index.php index c23a64d3..82e81f18 100755 --- a/tests/index.php +++ b/tests/index.php @@ -71,9 +71,7 @@ require 'HTMLPurifier/Harness.php'; // Shell-script code is executed if ($AC['flush']) { - shell_exec($AC['php'] . ' ../maintenance/generate-schema-cache.php'); - shell_exec($AC['php'] . ' ../maintenance/flush-definition-cache.php'); - shell_exec($AC['php'] . ' ../maintenance/generate-standalone.php'); + shell_exec($AC['php'] . ' ../maintenance/flush.php'); } // Now, userland code begins to be executed diff --git a/tests/multitest.php b/tests/multitest.php index ee6a3fa0..0ffdccbb 100644 --- a/tests/multitest.php +++ b/tests/multitest.php @@ -46,12 +46,8 @@ $aliases = array( ); htmlpurifier_parse_args($AC, $aliases); -// Calls generate-includes.php automatically -shell_exec($AC['php'] . ' ../maintenance/generate-standalone.php'); - -// Not strictly necessary, but its a good idea -shell_exec($AC['php'] . ' ../maintenance/generate-schema-cache.php'); -shell_exec($AC['php'] . ' ../maintenance/flush-definition-cache.php'); +// Regenerate any necessary files +shell_exec($AC['php'] . ' ../maintenance/flush.php'); $test = new TestSuite('HTML Purifier Multiple Versions Test'); $file = '';