Convert all to new configuration get/set format.
[htmlpurifier/darkodev.git] / maintenance / update-config.php
blob23e10d05d923da8d78a9e50ea1fe87158e0b0b1c
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);