From 8384d7d421cff6e1d04c5df91cb7f62ed7a219b3 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 14 Dec 2022 12:48:56 +0100 Subject: [PATCH] [PHP8.1] Added some fixes for PHP 8.1 --- system/core/Common.php | 3 +++ system/libraries/Profiler.php | 3 ++- system/libraries/Session/drivers/Session_files_driver.php | 7 ++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 03f62c09..158213c0 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -727,6 +727,9 @@ if ( ! function_exists('remove_invisible_characters')) do { + if ($str == null) { + $str = ""; + } $str = preg_replace($non_displayables, '', $str, -1, $count); } while ($count); diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 5531f336..0ef908bc 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -490,10 +490,10 @@ class CI_Profiler { if (is_array($val) OR is_object($val)) { $val = print_r($val, TRUE); - $pre = '
' ;
 				$pre_close = '
'; } + $val = $val == null ? "" : $val; $output .= '' .$config.'  '.$pre.htmlspecialchars($val, ENT_QUOTES, config_item('charset')).$pre_close."\n"; @@ -522,6 +522,7 @@ class CI_Profiler { foreach ($this->CI->session->userdata() as $key => $val) { + $val = $val == null ? "" : $val; $pre = ''; $pre_close = ''; diff --git a/system/libraries/Session/drivers/Session_files_driver.php b/system/libraries/Session/drivers/Session_files_driver.php index 49bf5b78..af380524 100644 --- a/system/libraries/Session/drivers/Session_files_driver.php +++ b/system/libraries/Session/drivers/Session_files_driver.php @@ -129,7 +129,7 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle * @param string $name Session cookie name * @return bool */ - public function open($save_path, $name) + public function open($save_path, $name): bool { if ( ! is_dir($save_path)) { @@ -165,6 +165,7 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle * @param string $session_id Session ID * @return string Serialized session data */ + #[\ReturnTypeWillChange] public function read($session_id) { // This might seem weird, but PHP 5.6 introduces session_reset(), @@ -238,6 +239,7 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle * @param string $session_data Serialized session data * @return bool */ + #[\ReturnTypeWillChange] public function write($session_id, $session_data) { // If the two IDs don't match, we have a session_regenerate_id() call @@ -295,6 +297,7 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle * * @return bool */ + #[\ReturnTypeWillChange] public function close() { if (is_resource($this->_file_handle)) @@ -318,6 +321,7 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle * @param string $session_id Session ID * @return bool */ + #[\ReturnTypeWillChange] public function destroy($session_id) { if ($this->close() === $this->_success) @@ -359,6 +363,7 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle * @param int $maxlifetime Maximum lifetime of sessions * @return bool */ + #[\ReturnTypeWillChange] public function gc($maxlifetime) { if ( ! is_dir($this->_config['save_path']) OR ($directory = opendir($this->_config['save_path'])) === FALSE)