Skip to content

[php8.1 M2.4.4 EE] stripos expects parameter string, null given #35542

Open
@sheepfy

Description

@sheepfy

Hi, so we have this:

  1. This observer: Magento\PricePermissions\Observer\AdminhtmlBlockHtmlBeforeObserver::execute method have this part of code:
        /** @var $block Template */
        $block = $observer->getBlock();

        $this->_filterByBlockName($block);

        // Handle prices that are shown when admin reviews customers shopping cart
        if (stripos($block->getNameInLayout(), 'customer_cart_') === 0) {
  1. The $block::getNameInLayout method is marked with annotation @return string. However, it can return NULL as well which can trigger an issue on php8 in stripos function.

My issue:
I'm using a 3rd party module that adds Tabs in it's admin form and I am thinking of adding this condition in AdminhtmlBlockHtmlBeforeObserver::execute :

if (!$block->getNameInLayout()) {
    return;
}

I don't think there is a reason to check anything in that observer if the block name is missing. (even if it's empty string).

Either that, either if the block name is not intended to be NULL update the getNameInLayout() to return only string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Adobe CommerceThe issue related to the Adobe Commerce(EE) or B2B functionalityArea: FrameworkIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: ready for devReported on 2.4.1Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions