magento2: Fatal error on Product-Compare page when Short Description & Description attributes are empty

Preconditions (*)
- Magento 2.3.5
Steps to reproduce (*)
- Add products to Compare where at least one product has no value set for at least one of its comparable attributes (e.g. “Description” or “Short Description” is empty).
- Go to the compare page (<site_root>/catalog/product_compare/index)
Expected result (*)
- Compare page should load normally, where any unconfigured attributes show “N/A” or “No”.
Actual result (*)
- Compare page is Broken and a Fatal Error is displayed. Fatal error: Uncaught TypeError: preg_match() expects parameter 2 to be string, object given in /app/web/vendor/magento/module-catalog/Helper/Output.php:245
Fatal error: Uncaught TypeError: preg_match() expects parameter 2 to be string, object given in /app/web/vendor/magento/module-catalog/Helper/Output.php:245 Stack trace: #0 /app/web/vendor/magento/module-catalog/Helper/Output.php(245): preg_match('/{{([a-z]{0,10}...', Object(Magento\Framework\Phrase)) #1 /app/web/vendor/magento/module-catalog/Helper/Output.php(185): Magento\Catalog\Helper\Output->isDirectivesExists(Object(Magento\Framework\Phrase)) #2 /app/web/vendor/magento/module-catalog/view/frontend/templates/product/compare/list.phtml(134): Magento\Catalog\Helper\Output->productAttribute(Object(Magento\Catalog\Model\Product\Interceptor), Object(Magento\Framework\Phrase), 'short_descripti...') #3 /app/web/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/app/web/vendor...') #4 /app/web/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Catalog\Block\Product\Compare\ListCompare\Interceptor), '/app/web/vendor...', Array) #5 /app/w in /app/web/vendor/magento/module-catalog/Helper/Output.php on line 245
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (8 by maintainers)
its ok with me friend and no problem. I just try to be thorough and right when doing bug reports and i was like, huh… but i reported that already what is he talking about?! 😃 Now lets quit small talk, and work on this and other issues. Have a nice day!
Yes Brengineer, as you can see on the bottom of #20229 report, I have made an entry yesterday, but noone seem to re-open that case or take any action. So, I had to re-report it here, because although its about the same topic, its still not fixed, and I have no Idea why that report had been closed.
@operator888
This issue is already fixed on M2.4-develop Unfortunately we can not backlog our fixes on M.2.3.5 here the patch to apply on M2.3.5 https://github.com/CarmineDamore78/magento2/blob/bugfix-28254_fix_compare_page/0001-bugfix-28254-Fixed-issue-for-compare-page.patch
Hi.
Should be easy to solve. Add (string) before $attributeHtml. So Phrase is converted to string in preg_match().
@magento fixed on M2.3.5
@magento I confirm the error on M2.3.5