From e0a041bb3d26971c81be306699fc05bbca186f1b Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 16 Jan 2023 22:42:04 +0900 Subject: [PATCH] Fix deprecation warnings in PHP 8.2 --- classes/validator/Validator.class.php | 2 +- classes/xml/XmlParser.class.php | 1 + common/functions.php | 8 +++++--- modules/member/member.admin.model.php | 4 ++-- modules/member/member.model.php | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/classes/validator/Validator.class.php b/classes/validator/Validator.class.php index f2a09f2b7..7b5fc635b 100644 --- a/classes/validator/Validator.class.php +++ b/classes/validator/Validator.class.php @@ -44,7 +44,7 @@ class Validator * custom message list * @var array */ - var $_messages; + var $_message; /** * custom field name list diff --git a/classes/xml/XmlParser.class.php b/classes/xml/XmlParser.class.php index 828d4cd31..b3f720c54 100644 --- a/classes/xml/XmlParser.class.php +++ b/classes/xml/XmlParser.class.php @@ -8,6 +8,7 @@ * @package /classes/xml * @version 0.1 */ +#[AllowDynamicProperties] class Xml_Node_ { diff --git a/common/functions.php b/common/functions.php index e4290344f..11ca45200 100644 --- a/common/functions.php +++ b/common/functions.php @@ -185,6 +185,7 @@ function clean_path($path) */ function escape($str, $double_escape = true, $except_lang_code = false) { + $str = (string)$str; if ($except_lang_code && preg_match('/^\$user_lang->userLang[0-9]+$/', $str)) { return $str; @@ -204,7 +205,7 @@ function escape($str, $double_escape = true, $except_lang_code = false) */ function escape_css($str) { - return preg_replace('/[^a-zA-Z0-9_.#\/-]/', '', $str); + return preg_replace('/[^a-zA-Z0-9_.#\/-]/', '', (string)$str); } /** @@ -229,7 +230,7 @@ function escape_js($str) */ function escape_sqstr($str) { - return str_replace(array('\\0', '\\"'), array('', '"'), addslashes($str)); + return str_replace(array('\\0', '\\"'), array('', '"'), addslashes((string)$str)); } /** @@ -241,7 +242,7 @@ function escape_sqstr($str) */ function escape_dqstr($str) { - return str_replace(array('\\0', "\\'", '$'), array('', "'", '\\$'), addslashes($str)); + return str_replace(array('\\0', "\\'", '$'), array('', "'", '\\$'), addslashes((string)$str)); } /** @@ -258,6 +259,7 @@ function escape_dqstr($str) function explode_with_escape($delimiter, $str, $limit = 0, $escape_char = '\\') { if ($limit < 1) $limit = 0; + $str = (string)$str; $result = array(); $split = preg_split('/(?is_denied = 'Y';break; } - $search_target = trim(Context::get('search_target')); - $search_keyword = trim(Context::get('search_keyword')); + $search_target = trim(Context::get('search_target') ?? ''); + $search_keyword = trim(Context::get('search_keyword') ?? ''); if($search_target && $search_keyword) { diff --git a/modules/member/member.model.php b/modules/member/member.model.php index f22723a96..2488ad92f 100644 --- a/modules/member/member.model.php +++ b/modules/member/member.model.php @@ -498,7 +498,7 @@ class MemberModel extends Member { foreach($extra_vars as $key => $val) { - if(!is_array($val) && !is_object($val) && strpos($val, '|@|') !== FALSE) + if(!is_null($val) && !is_array($val) && !is_object($val) && strpos($val, '|@|') !== FALSE) { $val = explode('|@|', $val); }