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

Created on 18 May 2020  路  16Comments  路  Source: magento/magento2

magento2-3-5-dev-bug t23dev-2020 05 17-21-40-01 (1)

Preconditions (*)

  1. Magento 2.3.5

Steps to reproduce (*)

  1. 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).
  2. Go to the compare page (/catalog/product_compare/index)

Expected result (*)

  1. Compare page should load normally, where any unconfigured attributes show "N/A" or "No".

Actual result (*)

  1. 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

Catalog Clear Description Confirmed Format is valid Ready for Work Reported on 2.3.5 Reproduced on 2.3.5p1

Most helpful comment

I'm sorry, I did not notice that entry.
If you like, I will remove my comments.

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!

All 16 comments

Hi @sudheers-kensium. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

(Note that this is essentially the same issue as #20229, which was not fixed properly.)

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.

But I cross-referenced and clearly mention that relation with that bug-report 2 messages before your message in here.

Screenshot 2020-05-19 at 10 01 36

Anyway, could you help fix this bug, or at least verify the validity of it? :)

I'm sorry, I did not notice that entry.
If you like, I will remove my comments.

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!

Hi.

Should be easy to solve. Add (string) before $attributeHtml. So Phrase is converted to string in preg_match().

    public function isDirectivesExists($attributeHtml)
.....
            if (preg_match($pattern, (string)$attributeHtml)) {
.....
    }

:white_check_mark: Confirmed by @sudheers-kensium
Thank you for verifying the issue. Based on the provided information internal tickets MC-34464 were created

Issue Available: @sudheers-kensium, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

@magento give me 2.3.5 instance

Hi @CarmineDamore78. Thank you for your request. I'm working on Magento 2.3.5 instance for you

Hi @CarmineDamore78, here is your Magento instance.
Admin access: https://i-28254-2-3-5.instances.magento-community.engineering/admin_b603
Login: 55914a98 Password: 7dc37a2889a8
Instance will be terminated in up to 3 hours.

@magento I confirm the error on M2.3.5

@magento I am working on this

@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

@magento fixed on M2.3.5

@magento fixed on M2.3.5

Thank you for your help and your time @CarmineDamore78 !

Hi @vrajesh-patel1993! :wave:
Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.

Hello @operator888

Just checked and the issue has been fixed and available in 2.3.5-p2 and 2.4.0

Was this page helpful?
0 / 5 - 0 ratings