From 5f5880738c223e7c693d7e63cb45336e68446807 Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Tue, 17 Sep 2024 17:03:37 -0400 Subject: [PATCH] Tweaks to handle null product descriptions --- includes/functions/functions_strings.php | 2 +- includes/modules/pages/product_info/main_template_vars.php | 3 ++- includes/modules/product_listing.php | 2 +- includes/modules/responsive_classic/product_listing.php | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/functions/functions_strings.php b/includes/functions/functions_strings.php index 0e298b8371..1c77f75dc3 100644 --- a/includes/functions/functions_strings.php +++ b/includes/functions/functions_strings.php @@ -332,7 +332,7 @@ function zen_clean_html($clean_it, $extraTags = '') if (!is_array($extraTags)) $extraTags = [$extraTags]; // remove any embedded javascript - $clean_it = preg_replace('#(.*?)#is', '', $clean_it); + $clean_it = preg_replace('#(.*?)#is', '', $clean_it ?? ''); $clean_it = preg_replace('/\r/', ' ', $clean_it); $clean_it = preg_replace('/\t/', ' ', $clean_it); diff --git a/includes/modules/pages/product_info/main_template_vars.php b/includes/modules/pages/product_info/main_template_vars.php index 1275fbb3bc..45d58016ee 100644 --- a/includes/modules/pages/product_info/main_template_vars.php +++ b/includes/modules/pages/product_info/main_template_vars.php @@ -66,7 +66,8 @@ $products_name = $product_info->fields['lang'][$_SESSION['languages_code']]['products_name']; $products_model = $product_info->fields['products_model']; // if no common markup tags in description, add line breaks for readability: - $products_description = (!preg_match('/(fields['lang'][$_SESSION['languages_code']]['products_description']) ? nl2br($product_info->fields['lang'][$_SESSION['languages_code']]['products_description']) : $product_info->fields['lang'][$_SESSION['languages_code']]['products_description']); + $products_description = $product_info->fields['lang'][$_SESSION['languages_code']]['products_description'] ?? ''; + $products_description = (!preg_match('/(fields['products_image'] == '') && PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') ? PRODUCTS_IMAGE_NO_IMAGE : ''; if ($product_info->fields['products_image'] != '' || PRODUCTS_IMAGE_NO_IMAGE_STATUS != '1') { diff --git a/includes/modules/product_listing.php b/includes/modules/product_listing.php index b2d9b650b6..53d7d6553b 100644 --- a/includes/modules/product_listing.php +++ b/includes/modules/product_listing.php @@ -218,7 +218,7 @@ $listing_product_name = zen_get_products_name((int)$record['products_id']); $listing_description = ''; if ((int)PRODUCT_LIST_DESCRIPTION > 0) { - $listing_description = zen_trunc_string(zen_clean_html(stripslashes($record['products_description'])), PRODUCT_LIST_DESCRIPTION); + $listing_description = zen_trunc_string(zen_clean_html(stripslashes($record['products_description'] ?? '')), PRODUCT_LIST_DESCRIPTION); } $listing_model = $record['products_model'] ?? ''; $listing_mfg_name = $record['manufacturers_name'] ?? ''; diff --git a/includes/modules/responsive_classic/product_listing.php b/includes/modules/responsive_classic/product_listing.php index aa93f91134..3337070f6f 100644 --- a/includes/modules/responsive_classic/product_listing.php +++ b/includes/modules/responsive_classic/product_listing.php @@ -214,7 +214,7 @@ $listing_product_name = $record['products_name'] ?? ''; $listing_description = ''; if ((int)PRODUCT_LIST_DESCRIPTION > 0) { - $listing_description = zen_trunc_string(zen_clean_html(stripslashes($record['products_description'])), PRODUCT_LIST_DESCRIPTION); + $listing_description = zen_trunc_string(zen_clean_html(stripslashes($record['products_description'] ?? '')), PRODUCT_LIST_DESCRIPTION); $lc_text .= '
' . $listing_description . '
'; } $listing_model = $record['products_model'] ?? '';