backpack_cron()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 18
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 23
rs 9.6666
1
<?php
2
3
/*
4
** for clockedworks module
5
*/
6
function backpack_cron($parameter = null)
7
{
8
    global $xoopsDB;
9
    $dirname = basename(__DIR__);
10
    require XOOPS_ROOT_PATH . '/modules/' . $dirname . '/include/zip.lib.php';
11
    require XOOPS_ROOT_PATH . '/modules/' . $dirname . '/include/defines.lib.php';
12
    require XOOPS_ROOT_PATH . '/modules/' . $dirname . '/include/read_dump.lib.php';
13
    require XOOPS_ROOT_PATH . '/modules/' . $dirname . '/admin/backup.ini.php';
14
    require XOOPS_ROOT_PATH . '/modules/' . $dirname . '/class/class.backpack.php';
15
16
    $alltables  = $backup_structure = $backup_data = 1;
0 ignored issues
show
Unused Code introduced by
The assignment to $alltables is dead and can be removed.
Loading history...
17
    $result     = $xoopsDB->queryF('SHOW TABLES FROM ' . $db_selected);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $db_selected seems to be never defined.
Loading history...
18
    $num_tables = $xoopsDB->getRowsNum($result);
19
    for ($i = 0; $i < $num_tables; ++$i) {
20
        $tablename_array[$i] = mysqli_tablename($result, $i);
21
    }
22
    $filename   = 'xdb' . date('YmdHis', time());
23
    $cfgZipType = 'gzip';
24
    $bp         = new backpack($dirname, $parameter);
0 ignored issues
show
Unused Code introduced by
The call to backpack::__construct() has too many arguments starting with $dirname. ( Ignorable by Annotation )

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

24
    $bp         = /** @scrutinizer ignore-call */ new backpack($dirname, $parameter);

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...
25
    if ($bp->err_msg) {
26
        echo "<span style=\"color: red; \">" . $bp->err_msg . '</span>';
27
    }
28
    $bp->backup_data($tablename_array, $backup_structure, $backup_data, $filename, $cfgZipType);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $tablename_array does not seem to be defined for all execution paths leading up to this point.
Loading history...
29
}
30