Passed
Push — master ( 437a59...f8edb8 )
by Michael
05:10 queued 03:07
created

admin/migrate.php (1 issue)

Severity
1
<?php
2
//
3
//  ------------------------------------------------------------------------ //
4
//                XOOPS - PHP Content Management System                      //
5
//                  Copyright (c) 2000-2020 XOOPS.org                        //
6
//                       <https://xoops.org>                             //
7
//  ------------------------------------------------------------------------ //
8
//  This program is free software; you can redistribute it and/or modify     //
9
//  it under the terms of the GNU General Public License as published by     //
10
//  the Free Software Foundation; either version 2 of the License, or        //
11
//  (at your option) any later version.                                      //
12
//                                                                           //
13
//  You may not change or alter any portion of this comment or credits       //
14
//  of supporting developers from this source code or any supporting         //
15
//  source code which is considered copyrighted (c) material of the          //
16
//  original comment or credit authors.                                      //
17
//                                                                           //
18
//  This program is distributed in the hope that it will be useful,          //
19
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21
//  GNU General Public License for more details.                             //
22
//                                                                           //
23
//  You should have received a copy of the GNU General Public License        //
24
//  along with this program; if not, write to the Free Software              //
25
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26
//  ------------------------------------------------------------------------ //
27
// Author: Kazumi Ono (AKA onokazu)                                          //
28
// URL: http://www.myweb.ne.jp/, https://xoops.org/, http://jp.xoops.org/ //
29
// Project: XOOPS Project                                                    //
30
// ------------------------------------------------------------------------- //
31
32
use Xmf\Request;
33
use XoopsModules\Xfguestbook;
34
use XoopsModules\Xfguestbook\Common\Migrate;
35
36
require_once __DIR__ . '/admin_header.php';
37
xoops_cp_header();
38
39
$adminObject->displayNavigation(basename(__FILE__));
40
41
echo <<<EOF
42
<form method="post" class="form-inline">
43
<div class="form-group">
44
<input name="show" class="btn btn-default" type="submit" value="Show SQL">
45
</div>
46
<div class="form-group">
47
<input name="migrate" class="btn btn-default" type="submit" value="Do Migration">
48
</div>
49
<div class="form-group">
50
<input name="schema" class="btn btn-default" type="submit" value="Write Schema">
51
</div>
52
</form>
53
EOF;
54
55
//XoopsLoad::load('migrate', 'newbb');
56
57
$configurator = new Xfguestbook\Common\Configurator();
58
59
$migrator = new Migrate($configurator);
0 ignored issues
show
The call to XoopsModules\Xfguestbook...\Migrate::__construct() has too many arguments starting with $configurator. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

59
$migrator = /** @scrutinizer ignore-call */ new Migrate($configurator);

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.

Loading history...
60
61
$op        = Request::getCmd('op', 'show');
62
$opShow    = Request::getCmd('show', null, 'POST');
63
$opMigrate = Request::getCmd('migrate', null, 'POST');
64
$opSchema  = Request::getCmd('schema', null, 'POST');
65
$op        = !empty($opShow) ? 'show' : $op;
66
$op        = !empty($opMigrate) ? 'migrate' : $op;
67
$op        = !empty($opSchema) ? 'schema' : $op;
68
69
$message = '';
70
71
switch ($op) {
72
    case 'show':
73
    default:
74
        $queue = $migrator->getSynchronizeDDL();
75
        if (!empty($queue)) {
76
            echo "<pre>\n";
77
            foreach ($queue as $line) {
78
                echo $line . ";\n";
79
            }
80
            echo "</pre>\n";
81
        }
82
        break;
83
    case 'migrate':
84
        $migrator->synchronizeSchema();
85
        $message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK');
86
        break;
87
    case 'schema':
88
        xoops_confirm(['op' => 'confirmwrite'], 'migrate.php', constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'));
89
        break;
90
    case 'confirmwrite':
91
        if ($GLOBALS['xoopsSecurity']->check()) {
92
            $migrator->saveCurrentSchema();
93
94
            $message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK');
95
        }
96
        break;
97
}
98
99
echo "<div>$message</div>";
100
101
require_once __DIR__ . '/admin_footer.php';
102