Conditions | 3 |
Paths | 6 |
Total Lines | 30 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 3.0354 |
Changes | 0 |
1 | <?php |
||
18 | 1 | public function migrate() { |
|
19 | |||
20 | try { |
||
21 | 1 | $row = $this->db->getDataRow(" |
|
22 | 1 | SELECT value FROM {$this->db->prefix}datalists |
|
23 | WHERE name = 'dataroot' |
||
24 | "); |
||
25 | |||
26 | 1 | if ($row) { |
|
|
|||
27 | 1 | $value = $row->value; |
|
28 | $lines = [ |
||
29 | 1 | "", |
|
30 | 1 | "/**", |
|
31 | 1 | " * The full file path for Elgg data storage. E.g. /path/to/elgg-data/", |
|
32 | 1 | " *", |
|
33 | 1 | " * @global string \$CONFIG->dataroot", |
|
34 | 1 | " */", |
|
35 | 1 | "\$CONFIG->dataroot = \"{$value}\";", |
|
36 | 1 | "" |
|
37 | ]; |
||
38 | 1 | $bytes = implode(PHP_EOL, $lines); |
|
39 | |||
40 | 1 | $this->append($bytes); |
|
41 | |||
42 | 1 | return $value; |
|
43 | } else { |
||
44 | error_log("The DB table {$this->db->prefix}datalists did not have 'dataroot'."); |
||
45 | } |
||
46 | } catch (\DatabaseException $ex) { |
||
47 | error_log($ex->getMessage()); |
||
48 | } |
||
50 | } |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.