[PHP8.1] Added some fixes for PHP 8.1

This commit is contained in:
Andreas 2022-12-14 12:48:56 +01:00
parent 7043561f18
commit 8384d7d421
3 changed files with 11 additions and 2 deletions

View File

@ -727,6 +727,9 @@ if ( ! function_exists('remove_invisible_characters'))
do do
{ {
if ($str == null) {
$str = "";
}
$str = preg_replace($non_displayables, '', $str, -1, $count); $str = preg_replace($non_displayables, '', $str, -1, $count);
} }
while ($count); while ($count);

View File

@ -490,10 +490,10 @@ class CI_Profiler {
if (is_array($val) OR is_object($val)) if (is_array($val) OR is_object($val))
{ {
$val = print_r($val, TRUE); $val = print_r($val, TRUE);
$pre = '<pre>' ; $pre = '<pre>' ;
$pre_close = '</pre>'; $pre_close = '</pre>';
} }
$val = $val == null ? "" : $val;
$output .= '<tr><td style="padding:5px;vertical-align:top;color:#900;background-color:#ddd;">' $output .= '<tr><td style="padding:5px;vertical-align:top;color:#900;background-color:#ddd;">'
.$config.'&nbsp;&nbsp;</td><td style="padding:5px;color:#000;background-color:#ddd;">'.$pre.htmlspecialchars($val, ENT_QUOTES, config_item('charset')).$pre_close."</td></tr>\n"; .$config.'&nbsp;&nbsp;</td><td style="padding:5px;color:#000;background-color:#ddd;">'.$pre.htmlspecialchars($val, ENT_QUOTES, config_item('charset')).$pre_close."</td></tr>\n";
@ -522,6 +522,7 @@ class CI_Profiler {
foreach ($this->CI->session->userdata() as $key => $val) foreach ($this->CI->session->userdata() as $key => $val)
{ {
$val = $val == null ? "" : $val;
$pre = ''; $pre = '';
$pre_close = ''; $pre_close = '';

View File

@ -129,7 +129,7 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
* @param string $name Session cookie name * @param string $name Session cookie name
* @return bool * @return bool
*/ */
public function open($save_path, $name) public function open($save_path, $name): bool
{ {
if ( ! is_dir($save_path)) 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 * @param string $session_id Session ID
* @return string Serialized session data * @return string Serialized session data
*/ */
#[\ReturnTypeWillChange]
public function read($session_id) public function read($session_id)
{ {
// This might seem weird, but PHP 5.6 introduces session_reset(), // 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 * @param string $session_data Serialized session data
* @return bool * @return bool
*/ */
#[\ReturnTypeWillChange]
public function write($session_id, $session_data) public function write($session_id, $session_data)
{ {
// If the two IDs don't match, we have a session_regenerate_id() call // 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 * @return bool
*/ */
#[\ReturnTypeWillChange]
public function close() public function close()
{ {
if (is_resource($this->_file_handle)) 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 * @param string $session_id Session ID
* @return bool * @return bool
*/ */
#[\ReturnTypeWillChange]
public function destroy($session_id) public function destroy($session_id)
{ {
if ($this->close() === $this->_success) 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 * @param int $maxlifetime Maximum lifetime of sessions
* @return bool * @return bool
*/ */
#[\ReturnTypeWillChange]
public function gc($maxlifetime) public function gc($maxlifetime)
{ {
if ( ! is_dir($this->_config['save_path']) OR ($directory = opendir($this->_config['save_path'])) === FALSE) if ( ! is_dir($this->_config['save_path']) OR ($directory = opendir($this->_config['save_path'])) === FALSE)