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\Module\Admin;
|
24
|
|
|
use Xmf\Request;
|
25
|
|
|
use XoopsModules\Xoopsfaq;
|
26
|
|
|
use XoopsModules\Xoopsfaq\{
|
27
|
|
|
Common\Configurator,
|
28
|
|
|
Common\Migrate
|
29
|
|
|
|
30
|
|
|
};
|
31
|
|
|
|
32
|
|
|
/** @var Admin $adminObject */
|
33
|
|
|
require_once __DIR__ . '/admin_header.php';
|
34
|
|
|
xoops_cp_header();
|
35
|
|
|
|
36
|
|
|
$adminObject->displayNavigation(basename(__FILE__));
|
37
|
|
|
|
38
|
|
|
echo <<<EOF
|
39
|
|
|
<form method="post" class="form-inline">
|
40
|
|
|
<div class="form-group">
|
41
|
|
|
<input name="show" class="btn btn-default" type="submit" value="Show SQL">
|
42
|
|
|
</div>
|
43
|
|
|
<div class="form-group">
|
44
|
|
|
<input name="migrate" class="btn btn-default" type="submit" value="Do Migration">
|
45
|
|
|
</div>
|
46
|
|
|
<div class="form-group">
|
47
|
|
|
<input name="schema" class="btn btn-default" type="submit" value="Write Schema">
|
48
|
|
|
</div>
|
49
|
|
|
</form>
|
50
|
|
|
EOF;
|
51
|
|
|
|
52
|
|
|
//XoopsLoad::load('migrate', 'newbb');
|
53
|
|
|
|
54
|
|
|
$configurator = new Configurator();
|
55
|
|
|
|
56
|
|
|
$migrator = new Migrate($configurator);
|
|
|
|
|
57
|
|
|
|
58
|
|
|
$op = Request::getCmd('op', 'show');
|
59
|
|
|
$opShow = Request::getCmd('show', '', 'POST');
|
60
|
|
|
$opMigrate = Request::getCmd('migrate', '', 'POST');
|
61
|
|
|
$opSchema = Request::getCmd('schema', '', 'POST');
|
62
|
|
|
$op = !empty($opShow) ? 'show' : $op;
|
63
|
|
|
$op = !empty($opMigrate) ? 'migrate' : $op;
|
64
|
|
|
$op = !empty($opSchema) ? 'schema' : $op;
|
65
|
|
|
|
66
|
|
|
$message = '';
|
67
|
|
|
|
68
|
|
|
switch ($op) {
|
69
|
|
|
case 'show':
|
70
|
|
|
default:
|
71
|
|
|
$queue = $migrator->getSynchronizeDDL();
|
72
|
|
|
if (!empty($queue)) {
|
73
|
|
|
echo "<pre>\n";
|
74
|
|
|
foreach ($queue as $line) {
|
75
|
|
|
echo $line . ";\n";
|
76
|
|
|
}
|
77
|
|
|
echo "</pre>\n";
|
78
|
|
|
}
|
79
|
|
|
break;
|
80
|
|
|
case 'migrate':
|
81
|
|
|
$migrator->synchronizeSchema();
|
82
|
|
|
$message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK');
|
83
|
|
|
break;
|
84
|
|
|
case 'schema':
|
85
|
|
|
xoops_confirm(['op' => 'confirmwrite'], 'migrate.php', constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'));
|
86
|
|
|
break;
|
87
|
|
|
case 'confirmwrite':
|
88
|
|
|
if ($GLOBALS['xoopsSecurity']->check()) {
|
89
|
|
|
$migrator->saveCurrentSchema();
|
90
|
|
|
|
91
|
|
|
$message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK');
|
92
|
|
|
}
|
93
|
|
|
break;
|
94
|
|
|
}
|
95
|
|
|
|
96
|
|
|
echo "<div>$message</div>";
|
97
|
|
|
|
98
|
|
|
require_once __DIR__ . '/admin_footer.php';
|
99
|
|
|
|
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.