Custom dispatch type layout page

PHP 8.1, CS-Cart 4.20
I raised this issue with my theme provider, and they report the bug is in the default Responsive theme.
When I include a Meta description for a layout page with the dispatch type of Custom or Blog (example: Dispatch: Custom > products.on_sale {/index.php?dispatch=products.on_sale} or Custom > products.bestsellers or Custom > products.newest and Blog > page.view?page_type=B) I get the following notice written in the PHP error log for every page view. The log is really filling up with these notices - as much as 10MB per day.
(If I remove the Meta description the notice stops.)

PHP Deprecated

Message

html_entity_decode(): Passing null to parameter #1 ($string) of type string is deprecated

Error at

app/lib/vendor/smarty/smarty/src/Extension/CallbackWrapper.php, line: 29

Backtrace

File: app/lib/vendor/smarty/smarty/src/Extension/CallbackWrapper.php
Line: 29
Function: {closure}
File: var/cache/templates/vivashop/ec4d468677398ee703a44ca7af238f389e93fd58_2.tygh_meta_description.override.tpl.php
Line: 42
Function: handle
File: app/lib/vendor/smarty/smarty/src/Template/GeneratedPhpFile.php
Line: 111
Function: content_69a9e71e615735_82757621
File: app/lib/vendor/smarty/smarty/src/Template/Compiled.php
Line: 110
Function: getRenderedTemplateCode
File: app/lib/vendor/smarty/smarty/src/Template.php
Line: 180
Function: render
File: app/lib/vendor/smarty/smarty/src/Template.php
Line: 655
Function: render
File: app/lib/vendor/smarty/smarty/src/Template.php
Line: 589
Function: _execute
File: app/Tygh/SmartyEngine/Core.php
Line: 85
Function: fetch
File: app/Tygh/SmartyEngine/Blocks/Hook.php
Line: 121
Function: fetch
File: var/cache/templates/vivashop/f55cfef08b63e900a7b0306ac84f4066e726285f_2.tygh_meta.tpl.php
Line: 163
Function: handle
File: app/lib/vendor/smarty/smarty/src/Template/GeneratedPhpFile.php
Line: 111
Function: content_69a9e71e5d7588_15147178
File: app/lib/vendor/smarty/smarty/src/Template/Compiled.php
Line: 110
Function: getRenderedTemplateCode
File: app/lib/vendor/smarty/smarty/src/Template.php
Line: 180
Function: render
File: app/lib/vendor/smarty/smarty/src/Template.php
Line: 287
Function: render
File: var/cache/templates/vivashop/29506607340f1acc447fda9b3e98c1615ec99151_2.tygh_index.tpl.php
Line: 120
Function: renderSubTemplate
File: app/lib/vendor/smarty/smarty/src/Template/GeneratedPhpFile.php
Line: 111
Function: content_69a9e71e566293_85274622
File: app/lib/vendor/smarty/smarty/src/Template/Compiled.php
Line: 110
Function: getRenderedTemplateCode
File: app/lib/vendor/smarty/smarty/src/Template.php
Line: 180
Function: render
File: app/lib/vendor/smarty/smarty/src/Template.php
Line: 655
Function: render
File: app/lib/vendor/smarty/smarty/src/Template.php
Line: 589
Function: _execute
File: app/Tygh/SmartyEngine/Core.php
Line: 85
Function: fetch
File: app/functions/fn.control.php
Line: 639
Function: fetch
File: index.php
Line: 19
Function: fn_dispatch

Until an official fix, try this:
app/lib/vendor/smarty/smarty/src/Extension/CallbackWrapper.php

Replace:

	public function handle(...$params) {
		try {
			return ($this->callback)(...$params);
		} catch (\ArgumentCountError $e) {
			throw new Exception("Invalid number of arguments to modifier " . $this->modifierName);
		}
	}

With:

	public function handle(...$params) {
		$params = array_map(static function ($param) {
			return $param ?? '';
		}, $params);

		try {
			return ($this->callback)(...$params);
		} catch (\ArgumentCountError $e) {
			throw new Exception("Invalid number of arguments to modifier " . $this->modifierName);
		}
	}

That throws a new error on the index.tpl page.

Smarty\Exception

Message

Not matching {capture}{/capture} in ‘index.tpl’

Error at

app/lib/vendor/smarty/smarty/src/Runtime/CaptureRuntime.php, line: 130

Bummer. It must be a more in depth issue.

Thanks for the report!

I’ve reproduced this issue and already forwarded to the developers.

For a quick fix for this bug, you can update the design/themes/responsive/templates/addons/seo/hooks/index/meta_description.override.tpl template and replace this code:

<meta name="description" content="{$meta_description|html_entity_decode:$smarty.const.ENT_COMPAT:"UTF-8"|default:$location_data.meta_description}{$search|fn_get_seo_page_title}" />

with this one:

    {if $meta_description}
         {$content = html_entity_decode($meta_description, $smarty.const.ENT_COMPAT, "UTF-8")}
    {elseif $location_data.meta_description}
         {$content = $location_data.meta_description}
    {/if}

<meta name="description" content="{$content}{$search|fn_get_seo_page_title}" />

I haven’t noticed any issues arising from these changes, but this is still just a quick fix, not the official one.

1 Like