From 651238916ba2aa6af89d83f53df17d8ea3f3c370 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 17 Jan 2023 00:15:12 +0900 Subject: [PATCH] Fix deprecation warnings in PHP 8.2 --- classes/xml/XmlJsFilter.class.php | 6 +++--- common/functions.php | 10 +++++----- modules/comment/comment.model.php | 4 ++-- modules/document/document.model.php | 2 +- modules/file/file.admin.model.php | 4 ++-- modules/menu/menu.admin.view.php | 10 ++-------- modules/module/module.model.php | 2 +- modules/ncenterlite/ncenterlite.view.php | 2 +- 8 files changed, 17 insertions(+), 23 deletions(-) diff --git a/classes/xml/XmlJsFilter.class.php b/classes/xml/XmlJsFilter.class.php index 998cb6bde..34efcfcc3 100644 --- a/classes/xml/XmlJsFilter.class.php +++ b/classes/xml/XmlJsFilter.class.php @@ -229,8 +229,8 @@ class XmlJsFilter extends XeXmlParser continue; } - $rule = trim($attrs->rule ? $attrs->rule : $attrs->filter); - $equalto = trim($attrs->equalto); + $rule = trim(strval($attrs->rule ? $attrs->rule : $attrs->filter)); + $equalto = trim(strval($attrs->equalto)); $field = array(); @@ -387,7 +387,7 @@ class XmlJsFilter extends XeXmlParser $js_messages[] = sprintf("v.cast('ADD_MESSAGE',['%s','%s']);", $key, $val); } - $callback_func = $xml_obj->filter->response->attrs->callback_func; + $callback_func = $xml_obj->filter->response->attrs->callback_func ?? null; if(!$callback_func) { $callback_func = "filterAlertMessage"; diff --git a/common/functions.php b/common/functions.php index 11ca45200..60b8bef90 100644 --- a/common/functions.php +++ b/common/functions.php @@ -606,11 +606,11 @@ function utf8_check($str) { if (function_exists('mb_check_encoding')) { - return mb_check_encoding($str, 'UTF-8'); + return mb_check_encoding((string)$str, 'UTF-8'); } else { - return ($str === @iconv('UTF-8', 'UTF-8', $str)); + return ($str === @iconv('UTF-8', 'UTF-8', (string)$str)); } } @@ -659,7 +659,7 @@ function utf8_mbencode($str) $bytes = array(ord($m[0][0]), ord($m[0][1]), ord($m[0][2]), ord($m[0][3])); $codepoint = ((0x07 & $bytes[0]) << 18) + ((0x3F & $bytes[1]) << 12) + ((0x3F & $bytes[2]) << 6) + (0x3F & $bytes[3]); return '&#x' . dechex($codepoint) . ';'; - }, $str); + }, (string)$str); } /** @@ -672,7 +672,7 @@ function utf8_mbencode($str) */ function utf8_normalize_spaces($str, $multiline = false) { - return $multiline ? preg_replace('/((?!\x0A)[\pZ\pC])+/u', ' ', $str) : preg_replace('/[\pZ\pC]+/u', ' ', $str); + return $multiline ? preg_replace('/((?!\x0A)[\pZ\pC])+/u', ' ', (string)$str) : preg_replace('/[\pZ\pC]+/u', ' ', (string)$str); } /** @@ -684,7 +684,7 @@ function utf8_normalize_spaces($str, $multiline = false) */ function utf8_trim($str) { - return preg_replace('/^[\s\pZ\pC]+|[\s\pZ\pC]+$/u', '', $str); + return preg_replace('/^[\s\pZ\pC]+|[\s\pZ\pC]+$/u', '', (string)$str); } /** diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index 25e4e2ded..d2886998e 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -853,8 +853,8 @@ class CommentModel extends Comment } // Search options - $search_target = (isset($obj->search_target) && $obj->search_target) ? $obj->search_target : trim(Context::get('search_target')); - $search_keyword = (isset($obj->search_keyword) && $obj->search_keyword) ? $obj->search_keyword : trim(Context::get('search_keyword')); + $search_target = (isset($obj->search_target) && $obj->search_target) ? $obj->search_target : trim(Context::get('search_target') ?? ''); + $search_keyword = (isset($obj->search_keyword) && $obj->search_keyword) ? $obj->search_keyword : trim(Context::get('search_keyword') ?? ''); if($search_target && $search_keyword) { switch($search_target) diff --git a/modules/document/document.model.php b/modules/document/document.model.php index e3f73e5ff..1b2b7bb3a 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -1302,7 +1302,7 @@ class DocumentModel extends Document } // check it can use extra variable - if(!$load_extra_vars || !$extra_keys = self::getExtraKeys($obj->module_srl)) + if(!$load_extra_vars || !$extra_keys = self::getExtraKeys($obj->module_srl ?? 0)) { $args->sort_index = 'list_order'; return $args; diff --git a/modules/file/file.admin.model.php b/modules/file/file.admin.model.php index 5a045e93f..1f724979b 100644 --- a/modules/file/file.admin.model.php +++ b/modules/file/file.admin.model.php @@ -179,8 +179,8 @@ class FileAdminModel extends File protected function _makeSearchParam(&$obj, &$args) { // Search options - $search_target = isset($obj->search_target)? ($obj->search_target? $obj->search_target : trim(Context::get('search_target'))) : trim(Context::get('search_target')); - $search_keyword = isset($obj->search_keyword)? ($obj->search_keyword? $obj->search_keyword : trim(Context::get('search_keyword'))) : trim(Context::get('search_keyword')); + $search_target = isset($obj->search_target)? ($obj->search_target? $obj->search_target : trim(Context::get('search_target'))) : trim(Context::get('search_target') ?? ''); + $search_keyword = isset($obj->search_keyword)? ($obj->search_keyword? $obj->search_keyword : trim(Context::get('search_keyword'))) : trim(Context::get('search_keyword') ?? ''); if($search_target && $search_keyword) { diff --git a/modules/menu/menu.admin.view.php b/modules/menu/menu.admin.view.php index 2dd414685..808449b44 100644 --- a/modules/menu/menu.admin.view.php +++ b/modules/menu/menu.admin.view.php @@ -31,14 +31,8 @@ class menuAdminView extends menu Context::loadLang(RX_BASEDIR.'modules/document/lang/'); Context::loadLang(RX_BASEDIR.'modules/layout/lang/'); Context::loadLang(RX_BASEDIR.'modules/autoinstall/lang/'); - $site_srl = Context::get('site_srl'); $site_module_info = Context::get('site_module_info'); - - if(!$site_srl) - { - if($logged_info->is_admin == 'Y' && !$site_keyword) $site_srl = 0; - else $site_srl = (int)$site_module_info->site_srl; - } + $site_srl = $site_module_info->site_srl ?? 0; // process for unlinked modules if($site_srl == 0) @@ -163,4 +157,4 @@ class menuAdminView extends menu } } /* End of file menu.admin.view.php */ -/* Location: ./modules/menu/menu.admin.view.php */ \ No newline at end of file +/* Location: ./modules/menu/menu.admin.view.php */ diff --git a/modules/module/module.model.php b/modules/module/module.model.php index 8df23956f..f5124e87a 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -1034,7 +1034,7 @@ class ModuleModel extends Module $obj->value = $val->attrs->value ?? null; $obj->default = $val->attrs->default ?? null; - if(preg_match('/,|\|@\|/', $obj->value, $delimiter) && $delimiter[0]) + if(preg_match('/,|\|@\|/', $obj->value ?? '', $delimiter) && $delimiter[0]) { $obj->value = explode($delimiter[0], $obj->value); } diff --git a/modules/ncenterlite/ncenterlite.view.php b/modules/ncenterlite/ncenterlite.view.php index b04b83f3a..c7df27bb5 100644 --- a/modules/ncenterlite/ncenterlite.view.php +++ b/modules/ncenterlite/ncenterlite.view.php @@ -85,7 +85,7 @@ class ncenterliteView extends ncenterlite } } - Context::set('member_info', $member_info); + Context::set('member_info', $member_info ?? null); Context::set('notify_types', $notify_types); Context::set('user_config', $user_config); Context::set('user_selected', $user_selected);