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/session.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/session.php')
-rw-r--r-- | phpBB/phpbb/session.php | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index 6b5b8f2625..de9345ca85 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -108,7 +108,7 @@ class session $root_dirs = array_diff_assoc($root_dirs, $intersection); $page_dirs = array_diff_assoc($page_dirs, $intersection); - $page_dir = str_repeat('../', sizeof($root_dirs)) . implode('/', $page_dirs); + $page_dir = str_repeat('../', count($root_dirs)) . implode('/', $page_dirs); if ($page_dir && substr($page_dir, -1, 1) == '/') { @@ -127,8 +127,8 @@ class session // The script path from the webroot to the phpBB root (for example: /phpBB3/) $script_dirs = explode('/', $script_path); - array_splice($script_dirs, -sizeof($page_dirs)); - $root_script_path = implode('/', $script_dirs) . (sizeof($root_dirs) ? '/' . implode('/', $root_dirs) : ''); + array_splice($script_dirs, -count($page_dirs)); + $root_script_path = implode('/', $script_dirs) . (count($root_dirs) ? '/' . implode('/', $root_dirs) : ''); // We are on the base level (phpBB root == webroot), lets adjust the variables a bit... if (!$root_script_path) @@ -584,12 +584,12 @@ class session $provider = $provider_collection->get_provider(); $this->data = $provider->autologin(); - if ($user_id !== false && sizeof($this->data) && $this->data['user_id'] != $user_id) + if ($user_id !== false && isset($this->data['user_id']) && $this->data['user_id'] != $user_id) { $this->data = array(); } - if (sizeof($this->data)) + if (isset($this->data['user_id'])) { $this->cookie_data['k'] = ''; $this->cookie_data['u'] = $this->data['user_id']; @@ -597,7 +597,7 @@ class session // If we're presented with an autologin key we'll join against it. // Else if we've been passed a user_id we'll grab data based on that - if (isset($this->cookie_data['k']) && $this->cookie_data['k'] && $this->cookie_data['u'] && !sizeof($this->data)) + if (isset($this->cookie_data['k']) && $this->cookie_data['k'] && $this->cookie_data['u'] && empty($this->data)) { $sql = 'SELECT u.* FROM ' . USERS_TABLE . ' u, ' . SESSIONS_KEYS_TABLE . ' k @@ -617,7 +617,7 @@ class session $db->sql_freeresult($result); } - if ($user_id !== false && !sizeof($this->data)) + if ($user_id !== false && empty($this->data)) { $this->cookie_data['k'] = ''; $this->cookie_data['u'] = $user_id; @@ -645,7 +645,7 @@ class session // User does not exist // User is inactive // User is bot - if (!sizeof($this->data) || !is_array($this->data)) + if (!is_array($this->data) || !count($this->data)) { $this->cookie_data['k'] = ''; $this->cookie_data['u'] = ($bot) ? $bot : ANONYMOUS; @@ -1022,7 +1022,7 @@ class session } $db->sql_freeresult($result); - if (sizeof($del_user_id)) + if (count($del_user_id)) { // Delete expired sessions $sql = 'DELETE FROM ' . SESSIONS_TABLE . ' @@ -1156,7 +1156,7 @@ class session $where_sql[] = $_sql; } - $sql .= (sizeof($where_sql)) ? implode(' AND ', $where_sql) : ''; + $sql .= (count($where_sql)) ? implode(' AND ', $where_sql) : ''; $result = $db->sql_query($sql, $cache_ttl); $ban_triggered_by = 'user'; |