From b2aa276a2a861d77259750faa0207e9a728e4f81 Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 16 Sep 2025 23:36:35 +0700 Subject: [PATCH] [ticket/17543] Fix more PHP 8.5 deprecation warnings PHPBB-17543 --- phpBB/includes/functions_posting.php | 2 -- phpBB/phpbb/captcha/plugins/recaptcha_v3.php | 2 +- .../db/doctrine/connection_parameter_factory.php | 13 ++++++++++++- phpBB/phpbb/notification/type/post.php | 2 +- phpBB/phpbb/search/backend/fulltext_native.php | 6 +++--- tests/profilefields/type_bool_test.php | 2 +- tests/profilefields/type_dropdown_test.php | 2 +- 7 files changed, 19 insertions(+), 10 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index f4637c5057..9559c10cfd 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -763,8 +763,6 @@ function create_thumbnail($source, $destination, $mimetype) imagewebp($new_image, $destination); break; } - - imagedestroy($new_image); } else { diff --git a/phpBB/phpbb/captcha/plugins/recaptcha_v3.php b/phpBB/phpbb/captcha/plugins/recaptcha_v3.php index e8399a5aef..b62c561a67 100644 --- a/phpBB/phpbb/captcha/plugins/recaptcha_v3.php +++ b/phpBB/phpbb/captcha/plugins/recaptcha_v3.php @@ -325,7 +325,7 @@ class recaptcha_v3 extends captcha_abstract $token = $request->variable('recaptcha_token', '', true); $action = $request->variable('recaptcha_action', '', true); $action = in_array($action, self::$actions) ? $action : reset(self::$actions); - $threshold = (double) $config["recaptcha_v3_threshold_{$action}"] ?? 0.5; + $threshold = (float) $config["recaptcha_v3_threshold_{$action}"] ?? 0.5; // No token was provided, discard spam submissions if (empty($token)) diff --git a/phpBB/phpbb/db/doctrine/connection_parameter_factory.php b/phpBB/phpbb/db/doctrine/connection_parameter_factory.php index ea5a929ba7..30ee850138 100644 --- a/phpBB/phpbb/db/doctrine/connection_parameter_factory.php +++ b/phpBB/phpbb/db/doctrine/connection_parameter_factory.php @@ -150,7 +150,18 @@ class connection_parameter_factory if ($params['driver'] === 'pdo_mysql' && extension_loaded('pdo_mysql')) { - $params[\PDO::MYSQL_ATTR_FOUND_ROWS] = true; + // Constant PDO::MYSQL_ATTR_FOUND_ROWS is deprecated since 8.5, use Pdo\Mysql::ATTR_FOUND_ROWS instead + if (class_exists('\Pdo\Mysql')) + { + /** + * @psalm-suppress UndefinedClass + */ + $params[\Pdo\Mysql::ATTR_FOUND_ROWS] = true; + } + else + { + $params[\PDO::MYSQL_ATTR_FOUND_ROWS] = true; + } } return $params; diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index be8c8d75e9..9052f6cbcf 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -386,7 +386,7 @@ class post extends \phpbb\notification\type\base // Topics can be "read" before they are public (while awaiting approval). // Make sure that if the user has read the topic, it's marked as read in the notification - if ($this->inherit_read_status && isset($pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time) + if ($this->inherit_read_status && isset($this->user_id, $pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time) { $this->notification_read = true; } diff --git a/phpBB/phpbb/search/backend/fulltext_native.php b/phpBB/phpbb/search/backend/fulltext_native.php index 95efc38e43..7416544a36 100644 --- a/phpBB/phpbb/search/backend/fulltext_native.php +++ b/phpBB/phpbb/search/backend/fulltext_native.php @@ -1577,7 +1577,7 @@ class fulltext_native extends base implements search_backend_interface // Remove common words if ($this->config['num_posts'] >= 100 && $this->config['fulltext_native_common_thres']) { - $common_threshold = ((double) $this->config['fulltext_native_common_thres']) / 100.0; + $common_threshold = ((float) $this->config['fulltext_native_common_thres']) / 100.0; // First, get the IDs of common words $sql = 'SELECT word_id, word_text FROM ' . $this->search_wordlist_table . ' @@ -2034,14 +2034,14 @@ class fulltext_native extends base implements search_backend_interface

' . $this->language->lang('COMMON_WORD_THRESHOLD_EXPLAIN') . '
-
%
+
%
'; // These are fields required in the config table return array( 'tpl' => $tpl, - 'config' => array('fulltext_native_load_upd' => 'bool', 'fulltext_native_min_chars' => 'integer:0:255', 'fulltext_native_max_chars' => 'integer:0:255', 'fulltext_native_common_thres' => 'double:0:100') + 'config' => array('fulltext_native_load_upd' => 'bool', 'fulltext_native_min_chars' => 'integer:0:255', 'fulltext_native_max_chars' => 'integer:0:255', 'fulltext_native_common_thres' => 'float:0:100') ); } } diff --git a/tests/profilefields/type_bool_test.php b/tests/profilefields/type_bool_test.php index 49bc45805a..f102badb31 100644 --- a/tests/profilefields/type_bool_test.php +++ b/tests/profilefields/type_bool_test.php @@ -187,7 +187,7 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case public function is_set_callback($field_id, $lang_id, $field_value) { - return isset($this->options[$field_value]); + return isset($field_value, $this->options[$field_value]); } public function get($field_id, $lang_id, $field_value) diff --git a/tests/profilefields/type_dropdown_test.php b/tests/profilefields/type_dropdown_test.php index 17e1a7b3f9..9e979b80e2 100644 --- a/tests/profilefields/type_dropdown_test.php +++ b/tests/profilefields/type_dropdown_test.php @@ -225,7 +225,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case public function is_set_callback($field_id, $lang_id, $field_value) { - return isset($this->dropdown_options[$field_value]); + return isset($field_value, $this->dropdown_options[$field_value]); } public function get($field_id, $lang_id, $field_value)