From 99ae1c8a79a84c17e5e9b6f1c44e1fbf4699f974 Mon Sep 17 00:00:00 2001 From: k4be Date: Sat, 28 Oct 2023 15:41:21 +0200 Subject: Fix compatibility problems with PHP 8. Tested with PHP 8.1.20. Includes fixes from misterludvigsen and ColdSphinX. --- htdocs/application/helpers/captcha_helper.php | 6 +++--- htdocs/application/libraries/Carabiner.php | 2 +- htdocs/system/core/Input.php | 2 +- htdocs/system/libraries/Pagination.php | 2 +- .../libraries/Session/drivers/Session_database_driver.php | 12 ++++++------ 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/application/helpers/captcha_helper.php b/htdocs/application/helpers/captcha_helper.php index 9bcb132..6e86060 100644 --- a/htdocs/application/helpers/captcha_helper.php +++ b/htdocs/application/helpers/captcha_helper.php @@ -350,7 +350,7 @@ if (!function_exists('display_captcha')) { $rad1 = $radius * (($i + 1) / $points); $x1 = ($rad1 * cos($theta)) + $x_axis; $y1 = ($rad1 * sin($theta)) + $y_axis; - imageline($im, $x, $y, $x1, $y1, $grid_color); + imageline($im, (int)$x, (int)$y, (int)$x1, (int)$y1, $grid_color); $theta = $theta - $thetac; } @@ -368,11 +368,11 @@ if (!function_exists('display_captcha')) { if ($use_font == false) { $font_size = 5; - $x = mt_rand(0, $img_width / ($length / 3)); + $x = mt_rand(0, (int)($img_width / ($length / 3))); $y = 0; } else { $font_size = 16; - $x = mt_rand(0, $img_width / ($length / 1.5)); + $x = mt_rand(0, (int)($img_width / ($length / 1.5))); $y = $font_size + 2; } for ($i = 0; $i < strlen($word); $i++) { diff --git a/htdocs/application/libraries/Carabiner.php b/htdocs/application/libraries/Carabiner.php index f8037cf..6fbafe2 100644 --- a/htdocs/application/libraries/Carabiner.php +++ b/htdocs/application/libraries/Carabiner.php @@ -461,7 +461,7 @@ class Carabiner { * @param String of the group name with which the asset is to be associated. NOT REQUIRED * @return Void */ - private function _asset($type, $dev_file, $prod_file = '', $combine, $minify, $media = 'screen', $group = 'main') + private function _asset($type, $dev_file, $prod_file = '', $combine = TRUE, $minify = TRUE, $media = 'screen', $group = 'main') { if ($type == 'css') : diff --git a/htdocs/system/core/Input.php b/htdocs/system/core/Input.php index 143babf..61b7a3e 100644 --- a/htdocs/system/core/Input.php +++ b/htdocs/system/core/Input.php @@ -565,7 +565,7 @@ class CI_Input { $which = FILTER_FLAG_IPV6; break; default: - $which = NULL; + $which = FILTER_DEFAULT; break; } diff --git a/htdocs/system/libraries/Pagination.php b/htdocs/system/libraries/Pagination.php index 3fe3d3a..3933448 100644 --- a/htdocs/system/libraries/Pagination.php +++ b/htdocs/system/libraries/Pagination.php @@ -522,7 +522,7 @@ class CI_Pagination { } // If something isn't quite right, back to the default base page. - if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0)) + if ( ! ctype_digit(strval($this->cur_page)) OR ($this->use_page_numbers && (int) $this->cur_page === 0)) { $this->cur_page = $base_page; } diff --git a/htdocs/system/libraries/Session/drivers/Session_database_driver.php b/htdocs/system/libraries/Session/drivers/Session_database_driver.php index 074accf..70774aa 100644 --- a/htdocs/system/libraries/Session/drivers/Session_database_driver.php +++ b/htdocs/system/libraries/Session/drivers/Session_database_driver.php @@ -126,7 +126,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan * @param string $name Session cookie name, unused * @return bool */ - public function open($save_path, $name) + public function open(string $path, string $name): bool { if (empty($this->_db->conn_id) && ! $this->_db->db_connect()) { @@ -148,7 +148,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan * @param string $session_id Session ID * @return string Serialized session data */ - public function read($session_id) + public function read($session_id): string|false { if ($this->_get_lock($session_id) !== FALSE) { @@ -205,7 +205,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan * @param string $session_data Serialized session data * @return bool */ - public function write($session_id, $session_data) + public function write($session_id, $session_data): bool { // Prevent previous QB calls from messing with our queries $this->_db->reset_query(); @@ -277,7 +277,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan * * @return bool */ - public function close() + public function close() : bool { return ($this->_lock && ! $this->_release_lock()) ? $this->_fail() @@ -294,7 +294,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan * @param string $session_id Session ID * @return bool */ - public function destroy($session_id) + public function destroy($session_id) : bool { if ($this->_lock) { @@ -332,7 +332,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan * @param int $maxlifetime Maximum lifetime of sessions * @return bool */ - public function gc($maxlifetime) + public function gc(int $max_lifetime): int|false { // Prevent previous QB calls from messing with our queries $this->_db->reset_query(); -- cgit v1.2.3