1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
/* |
5
|
|
|
You may not change or alter any portion of this comment or credits |
6
|
|
|
of supporting developers from this source code or any supporting source code |
7
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
8
|
|
|
|
9
|
|
|
This program is distributed in the hope that it will be useful, |
10
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Migration for XOOPS modules |
16
|
|
|
* |
17
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
18
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
19
|
|
|
* @author Richard Griffith <[email protected]> |
20
|
|
|
* @author Michael Beck <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
use Xmf\Request; |
24
|
|
|
use Xmf\Module\Admin; |
25
|
|
|
use XoopsModules\Songlist\{ |
26
|
|
|
Common\Configurator, |
27
|
|
|
Common\Migrate, |
28
|
|
|
Helper |
29
|
|
|
}; |
30
|
|
|
|
31
|
|
|
/** @var Admin $adminObject */ |
32
|
|
|
/** @var Configurator $configurator */ |
33
|
|
|
/** @var Migrate $migrator */ |
34
|
|
|
|
35
|
|
|
require __DIR__ . '/admin_header.php'; |
36
|
|
|
xoops_cp_header(); |
37
|
|
|
|
38
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
39
|
|
|
|
40
|
|
|
echo <<<EOF |
41
|
|
|
<form method="post" class="form-inline"> |
42
|
|
|
<div class="form-group"> |
43
|
|
|
<input name="show" class="btn btn-default" type="submit" value="Show SQL"> |
44
|
|
|
</div> |
45
|
|
|
<div class="form-group"> |
46
|
|
|
<input name="migrate" class="btn btn-default" type="submit" value="Do Migration"> |
47
|
|
|
</div> |
48
|
|
|
<div class="form-group"> |
49
|
|
|
<input name="schema" class="btn btn-default" type="submit" value="Write Schema"> |
50
|
|
|
</div> |
51
|
|
|
</form> |
52
|
|
|
EOF; |
53
|
|
|
|
54
|
|
|
//XoopsLoad::load('migrate', 'newbb'); |
55
|
|
|
|
56
|
|
|
$configurator = new Configurator(); |
57
|
|
|
|
58
|
|
|
$migrator = new Migrate($configurator); |
|
|
|
|
59
|
|
|
|
60
|
|
|
$op = Request::getCmd('op', 'show'); |
61
|
|
|
$opShow = Request::getCmd('show', null, 'POST'); |
62
|
|
|
$opMigrate = Request::getCmd('migrate', null, 'POST'); |
63
|
|
|
$opSchema = Request::getCmd('schema', null, 'POST'); |
64
|
|
|
$op = !empty($opShow) ? 'show' : $op; |
65
|
|
|
$op = !empty($opMigrate) ? 'migrate' : $op; |
66
|
|
|
$op = !empty($opSchema) ? 'schema' : $op; |
67
|
|
|
|
68
|
|
|
$message = ''; |
69
|
|
|
|
70
|
|
|
switch ($op) { |
71
|
|
|
case 'show': |
72
|
|
|
default: |
73
|
|
|
$queue = $migrator->getSynchronizeDDL(); |
74
|
|
|
if (!empty($queue)) { |
75
|
|
|
echo "<pre>\n"; |
76
|
|
|
foreach ($queue as $line) { |
77
|
|
|
echo $line . ";\n"; |
78
|
|
|
} |
79
|
|
|
echo "</pre>\n"; |
80
|
|
|
} |
81
|
|
|
break; |
82
|
|
|
case 'migrate': |
83
|
|
|
$migrator->synchronizeSchema(); |
84
|
|
|
$message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK'); |
85
|
|
|
break; |
86
|
|
|
case 'schema': |
87
|
|
|
xoops_confirm(['op' => 'confirmwrite'], 'migrate.php', constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM')); |
88
|
|
|
break; |
89
|
|
|
case 'confirmwrite': |
90
|
|
|
if ($GLOBALS['xoopsSecurity']->check()) { |
91
|
|
|
$migrator->saveCurrentSchema(); |
92
|
|
|
|
93
|
|
|
$message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK'); |
94
|
|
|
} |
95
|
|
|
break; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
echo "<div>$message</div>"; |
99
|
|
|
|
100
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
101
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.