From bdf24cded2bcf0cea2aa1eda6334919852426e9e Mon Sep 17 00:00:00 2001 From: Cyssoo Date: Thu, 15 Jan 2026 18:02:59 +0100 Subject: [PATCH] Fix warnings for prettyblocks and shortcodes --- src/Service/EverblockPrettyBlocks.php | 6 +++++- src/Service/EverblockTools.php | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Service/EverblockPrettyBlocks.php b/src/Service/EverblockPrettyBlocks.php index ecf422f..9e808ea 100644 --- a/src/Service/EverblockPrettyBlocks.php +++ b/src/Service/EverblockPrettyBlocks.php @@ -165,7 +165,11 @@ private static function getPrettyblocksChoicesByCode( $config = json_decode((string) ($row['config'] ?? ''), true); $label = ''; if (is_array($config)) { - $label = (string) ($config[$labelField] ?? ''); + $labelValue = $config[$labelField] ?? ''; + if (is_array($labelValue)) { + $labelValue = reset($labelValue) ?: ''; + } + $label = is_scalar($labelValue) ? (string) $labelValue : ''; } if ($label === '') { $label = $module->l('Item') . ' #' . $id; diff --git a/src/Service/EverblockTools.php b/src/Service/EverblockTools.php index 963699e..0df505c 100644 --- a/src/Service/EverblockTools.php +++ b/src/Service/EverblockTools.php @@ -3553,7 +3553,8 @@ private static function renderSmartyVarsInArray(string $txt, string $search, arr if (is_array($value)) { $txt = static::renderSmartyVarsInArray($txt, $elementSearch, $value); } else { - $txt = str_replace($elementSearch, $value, $txt); + $replacement = is_scalar($value) ? (string) $value : ''; + $txt = str_replace($elementSearch, $replacement, $txt); } } return $txt; @@ -4502,7 +4503,8 @@ public static function getCustomerShortcodes(string $txt, Context $context): str '[entity_gender]' => $gender->name, ]; foreach ($entityShortcodes as $key => $value) { - $txt = str_replace($key, $value, $txt); + $replacement = $value ?? ''; + $txt = str_replace($key, (string) $replacement, $txt); } return $txt; } @@ -4515,7 +4517,8 @@ public static function getEverShortcodes(string $txt, Context $context): string ); $returnedShortcodes = []; foreach ($customShortcodes as $sc) { - $txt = str_replace($sc->shortcode, $sc->content, $txt); + $content = $sc->content ?? ''; + $txt = str_replace($sc->shortcode, (string) $content, $txt); } return $txt; }