Tighten up ignore spec.
[htmlpurifier/darkodev.git] / maintenance / update-config.php
blob2d8a7a9c1025d394530119836b5c7a852d153a65
1 #!/usr/bin/php
2 <?php
4 chdir(dirname(__FILE__));
5 require_once 'common.php';
6 assertCli();
8 /**
9 * @file
10 * Converts all instances of $config->set and $config->get to the new
11 * format, as described by docs/dev-config-bcbreaks.txt
14 $FS = new FSTools();
15 chdir(dirname(__FILE__) . '/..');
16 $raw_files = $FS->globr('.', '*.php');
17 foreach ($raw_files as $file) {
18 $file = substr($file, 2); // rm leading './'
19 if (strpos($file, 'library/standalone/') === 0) continue;
20 if (strpos($file, 'maintenance/update-config.php') === 0) continue;
21 if (strpos($file, 'test-settings.php') === 0) continue;
22 if (substr_count($file, '.') > 1) continue; // rm meta files
23 // process the file
24 $contents = file_get_contents($file);
25 $contents = preg_replace(
26 "#config->(set|get)\('(.+?)', '(.+?)'#",
27 "config->\\1('\\2.\\3'",
28 $contents
30 if ($contents === '') continue;
31 file_put_contents($file, $contents);
34 // vim: et sw=4 sts=4