From df6fdd3bc36505bedb726104d043dc568e655c20 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 3 Oct 2023 16:18:56 +0900 Subject: [PATCH] Fix potential type error in editor component XML handling logic --- common/framework/parsers/EditorComponentParser.php | 6 +++--- modules/editor/editor.model.php | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/common/framework/parsers/EditorComponentParser.php b/common/framework/parsers/EditorComponentParser.php index 9dbed59b3..a50036ab6 100644 --- a/common/framework/parsers/EditorComponentParser.php +++ b/common/framework/parsers/EditorComponentParser.php @@ -13,15 +13,15 @@ class EditorComponentParser extends BaseParser * @param string $filename * @param string $component_name * @param string $lang - * @return object|false + * @return ?object */ - public static function loadXML(string $filename, string $component_name, string $lang = '') + public static function loadXML(string $filename, string $component_name, string $lang = ''): ?object { // Load the XML file. $xml = simplexml_load_string(file_get_contents($filename)); if ($xml === false) { - return false; + return null; } // Get the current language. diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index e4f42b80b..deee0baa7 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -638,12 +638,14 @@ class EditorModel extends Editor $component_name = $component->component_name; - unset($xml_info); $xml_info = self::getComponentXmlInfo($component_name); + if (!$xml_info) + { + return (object)['enabled' => false]; + } + $xml_info->enabled = $component->enabled; - $xml_info->target_group = array(); - $xml_info->mid_list = array(); if($component->extra_vars) @@ -690,7 +692,7 @@ class EditorModel extends Editor // Get from cache $cache_key = sprintf('editor:component:%s:%s:%d', $component, $lang_type, $xml_mtime); $info = Rhymix\Framework\Cache::get($cache_key); - if ($info !== null && FALSE) + if (!empty($info)) { return $info; }