diff options
author | rxu <rxu@mail.ru> | 2017-01-09 00:23:08 +0700 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2018-01-01 13:08:12 +0100 |
commit | 8c3808e9e7db09531154b2520cbfcc7529a5c752 (patch) | |
tree | ca5edd56088f7c689fcd1afe42a51baa66768508 /phpBB/phpbb/db/driver/driver.php | |
parent | 0ff5f9fa0edf9ac3125cc4e871609a90cee1cfac (diff) | |
download | forums-8c3808e9e7db09531154b2520cbfcc7529a5c752.tar forums-8c3808e9e7db09531154b2520cbfcc7529a5c752.tar.gz forums-8c3808e9e7db09531154b2520cbfcc7529a5c752.tar.bz2 forums-8c3808e9e7db09531154b2520cbfcc7529a5c752.tar.xz forums-8c3808e9e7db09531154b2520cbfcc7529a5c752.zip |
[ticket/14972] Fix sizeof calls
As of PHP 7.2, only arrays and objects implementing the Countable interface
should be passed as a count() or sizeof() parameter.
See https://github.com/php/php-src/blob/php-7.2.0alpha2/UPGRADING#L197-L198
Also, sizeof() seems to be sheduled for deprecation, see
https://wiki.php.net/rfc/deprecations_php_7_2#suggested_deprecations
PHPBB3-14972
Diffstat (limited to 'phpBB/phpbb/db/driver/driver.php')
-rw-r--r-- | phpBB/phpbb/db/driver/driver.php | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php index 214c5590e7..5851469806 100644 --- a/phpBB/phpbb/db/driver/driver.php +++ b/phpBB/phpbb/db/driver/driver.php @@ -537,7 +537,9 @@ abstract class driver implements driver_interface */ function sql_in_set($field, $array, $negate = false, $allow_empty_set = false) { - if (!sizeof($array)) + $array = (array) $array; + + if (!count($array)) { if (!$allow_empty_set) { @@ -559,12 +561,7 @@ abstract class driver implements driver_interface } } - if (!is_array($array)) - { - $array = array($array); - } - - if (sizeof($array) == 1) + if (count($array) == 1) { @reset($array); $var = current($array); @@ -632,7 +629,7 @@ abstract class driver implements driver_interface */ function sql_multi_insert($table, $sql_ary) { - if (!sizeof($sql_ary)) + if (!count($sql_ary)) { return false; } @@ -738,7 +735,7 @@ abstract class driver implements driver_interface // We run the following code to determine if we need to re-order the table array. ;) // The reason for this is that for multi-aliased tables (two equal tables) in the FROM statement the last table need to match the first comparison. // DBMS who rely on this: Oracle, PostgreSQL and MSSQL. For all other DBMS it makes absolutely no difference in which order the table is. - if (!empty($array['LEFT_JOIN']) && sizeof($array['FROM']) > 1 && $used_multi_alias !== false) + if (!empty($array['LEFT_JOIN']) && count($array['FROM']) > 1 && $used_multi_alias !== false) { // Take first LEFT JOIN $join = current($array['LEFT_JOIN']); @@ -848,7 +845,7 @@ abstract class driver implements driver_interface default: - switch (sizeof($condition)) + switch (count($condition)) { case 3: @@ -1138,7 +1135,7 @@ abstract class driver implements driver_interface $html_table = func_get_arg(2); $row = func_get_arg(3); - if (!$html_table && sizeof($row)) + if (!$html_table && count($row)) { $html_table = true; $this->html_hold .= '<table cellspacing="1"><tr>'; |