magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Magento_Theme title.phtml template invalid for PHP 8.2

Open adamlavery opened this issue 1 year ago • 7 comments

Preconditions and environment

OS 2.4.7

Steps to reproduce

There's a code error in vendor\magento\module-theme\view\frontend\templates\html\title.phtml

Expected result

Should be written for PHP 8.2 but is not.

Actual result

Template crashes if there's no page title.

Additional information

This code:

if (trim($block->getPageHeading())) {
    $titleHtml = '<span class="base" data-ui-id="page-title-wrapper" '
        . $block->getAddBaseAttribute()
        . '>'
        . $block->escapeHtml($block->getPageHeading())
        . '</span>';
}

Needs correcting to:

if ($block->getPageHeading()) {
    $titleHtml = '<span class="base" data-ui-id="page-title-wrapper" '
        . $block->getAddBaseAttribute()
        . '>'
        . $block->escapeHtml(trim($block->getPageHeading()))
        . '</span>';
}

Release note

Fix code that fails with PHP 8.2

Triage and priority

  • [X] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

adamlavery avatar Aug 22 '24 11:08 adamlavery

Hi @adamlavery. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

m2-assistant[bot] avatar Aug 22 '24 11:08 m2-assistant[bot]

It would help if you could specify the error message you're seeing? But I guess it happens when $block->getPageHeading() returns null and not a string?

hostep avatar Aug 28 '24 10:08 hostep

@hostep sorry, didn't think a log of this error was necessary. Yes, as of PHP 8.? you can no longer pass null to most/all PHP string functions. I'm sure there must be a valid reason for this change which breaks code all over the place, although I can't see it!!

adamlavery avatar Aug 28 '24 10:08 adamlavery

Hi @engcom-November. 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).
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • [ ] 3. Add Area: XXXXX label to the ticket, indicating the functional areas 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.

m2-assistant[bot] avatar Aug 29 '24 10:08 m2-assistant[bot]

Hello @adamlavery,

Thank you for the report and collaboration!

If the function $block->getPageHeading() returns null by any case which it should not, will cause the error as php string functions won't accept null as parameter. Hence confirming this.

engcom-November avatar Aug 29 '24 12:08 engcom-November

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-12856 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Aug 29 '24 12:08 github-jira-sync-bot

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] avatar Aug 29 '24 12:08 m2-assistant[bot]

@magento i'm working on this

magentoabu avatar Nov 20 '24 14:11 magentoabu

Hi @magentoabu! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

m2-assistant[bot] avatar Nov 20 '24 14:11 m2-assistant[bot]

@magento add to contributors team

magentoabu avatar Nov 20 '24 15:11 magentoabu

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

m2-assistant[bot] avatar Nov 20 '24 15:11 m2-assistant[bot]

@magento I'm working on this

magentoabu avatar Nov 20 '24 15:11 magentoabu