-
Notifications
You must be signed in to change notification settings - Fork 3
/
upgrade-to-4.5.php
executable file
·44 lines (36 loc) · 1.33 KB
/
upgrade-to-4.5.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/php
<?php
require __DIR__.'/util/globrecursive.php';
if (is_file('vkwf_branch') || is_file('kwf_branch')) {
die("This script will update from 4.4, update to 4.4 first.\n");
}
if (!is_file('composer.json')) {
die("composer.json not found.\n");
}
$changed = false;
$c = json_decode(file_get_contents('composer.json'));
foreach ($c->require as $packageName=>$packageVersion) {
if (substr($packageVersion, 0, 4) == "4.4.") {
$c->require->$packageName = '4.5.x-dev';
$changed = true;
}
}
if (!$changed) {
die("This script will update from 4.4, update to 4.4 first.\n");
}
if (isset($c->extra->{'require-bower'}->jquery)) {
unset($c->extra->{'require-bower'}->jquery);
}
file_put_contents('composer.json', json_encode($c, (defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0) + (defined('JSON_UNESCAPED_SLASHES') ? JSON_UNESCAPED_SLASHES : 0) ));
$files = array_merge(glob_recursive('*.php'), glob_recursive('*.tpl'));
foreach ($files as $file) {
$c = file_get_contents($file);
$origC = $c;
$c = str_replace("htmlspecialchars_decode", 'Kwf_Util_HtmlSpecialChars::decode', $c);
$c = str_replace("htmlspecialchars", 'Kwf_Util_HtmlSpecialChars::filter', $c);
if ($c != $origC) {
file_put_contents($file, $c);
}
}
echo "\n";
echo "run now 'composer update' to update dependencies\n";