Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sheepfy opened this issue May 26, 2022 · 24 comments
Open

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

sheepfy opened this issue May 26, 2022 · 24 comments
Labels
Adobe Commerce The issue related to the Adobe Commerce(EE) or B2B functionality Area: Framework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.1 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@sheepfy
Copy link
Contributor

sheepfy commented May 26, 2022

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.

@sheepfy sheepfy added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label May 26, 2022
@m2-assistant
Copy link

m2-assistant bot commented May 26, 2022

Hi @sheepfy. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

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

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-assistant
Copy link

m2-assistant bot commented May 27, 2022

Hi @engcom-Hotel. 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: 👇

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

@engcom-Hotel
Copy link
Contributor

Hello @sheepfy,

Thanks for the posting and collaboration!

We have checked the usage of function setNameInLayout() defined in class lib/internal/Magento/Framework/View/Element/AbstractBlock.php from where $this->_nameInLayout is initialized but in the Magento core, no null value has been passed.

Please let us know which 3rd party module you have tried where you are facing the issue.

Thanks

@engcom-Hotel engcom-Hotel added the Issue: needs update Additional information is require, waiting for response label May 27, 2022
@sheepfy
Copy link
Contributor Author

sheepfy commented May 27, 2022

@engcom-Hotel Hey, so it is about implementing Tab forms in admin.
Modules in case were Firebear and Xtento_ProductExport . They adds Tabs, tabs will have null as block name and they will fail in that observer.

However, since _nameInLayout can reach as null in that method output, I'll stick to this:
if (!$block->getNameInLayout()) {
return;
}

@engcom-Hotel
Copy link
Contributor

Hello @sheepfy,

Thanks for the response!

I have tried to check the above-mentioned modules in Marketplace and found the below results:

I request you to please connect with them and raise a query for this. They might help you.

Thanks

@engcom-Hotel
Copy link
Contributor

Dear @sheepfy,

We have noticed that this issue has not been updated for a period of 14 Days. Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Regards

@sheepfy
Copy link
Contributor Author

sheepfy commented Jun 14, 2022

@engcom-Hotel hi, I don't think I can create a PR here with that fix tho, Magento\PricePermissions it's an enterprise module.

@kmosdev
Copy link

kmosdev commented Jul 3, 2022

@sheepfy I had this same issue and created a patch for it.

This code can be saved as a .patch file and placed in /m2-hotfixes

diff --git a/vendor/magento/module-price-permissions/Observer/AdminhtmlBlockHtmlBeforeObserver.php b/vendor/magento/module-price-permissions/Observer/AdminhtmlBlockHtmlBeforeObserver.php
index 974b4ec..2ac0e01 100644
--- a/vendor/magento/module-price-permissions/Observer/AdminhtmlBlockHtmlBeforeObserver.php
+++ b/vendor/magento/module-price-permissions/Observer/AdminhtmlBlockHtmlBeforeObserver.php
@@ -120,7 +120,7 @@ class AdminhtmlBlockHtmlBeforeObserver implements ObserverInterface
         $block = $observer->getBlock();

         $this->_filterByBlockName($block);
-
+        if(empty($block->getNameInLayout())) { return; }
         // Handle prices that are shown when admin reviews customers shopping cart
         if (stripos($block->getNameInLayout(), 'customer_cart_') === 0) {
             if (!$this->observerData->isCanReadProductPrice()) {

@sheepfy
Copy link
Contributor Author

sheepfy commented Jul 3, 2022

@kmosdev Hi!
That's the patch that I've used, I'd go with "!$block->getNameInLayout()" since the return value is just a string|null and "!" is doing the same thing as "empty"

file: magentoroot/patches/composer/github-issue-35542.diff

diff --git a/Observer/AdminhtmlBlockHtmlBeforeObserver.php b/Observer/AdminhtmlBlockHtmlBeforeObserver.php
index 974b4ec..1978e66 100644
--- a/Observer/AdminhtmlBlockHtmlBeforeObserver.php
+++ b/Observer/AdminhtmlBlockHtmlBeforeObserver.php
@@ -118,6 +118,9 @@ class AdminhtmlBlockHtmlBeforeObserver implements ObserverInterface
     {
         /** @var $block Template */
         $block = $observer->getBlock();
+        if (!$block->getNameInLayout()) {
+            return;
+        }
 
         $this->_filterByBlockName($block);

file: magentoroot/composer.json

{
    [...]
    "extra": {
        [...]
        "patches": { 
            [...]
            "magento/module-price-permissions": {
                "skip composer execution for missing block name": "patches/composer/github-issue-35542.diff"
            },
            [...]
        }
        [...]
    }
    [...]
}

@johncy65
Copy link

johncy65 commented Jul 18, 2022

@kmosdev How did you create that patch?

@sheepfy
Copy link
Contributor Author

sheepfy commented Jul 18, 2022

@ghost
Copy link

ghost commented Aug 19, 2022

#35542 #35490 #35985

Edited app/code/Magento/Customer/Block/Widget/Name.php as below:

From $prefixOption = $this->getObject()->getPrefix(); to $prefixOption = $this->getObject()->getPrefix() ?? '';


After submited account creation
Got this on https://www.example.com/customer/account/createpost/

ValueError: bcsub(): Argument #1 ($num1) is not well-formed in /var/www/html/vendor/magento/zendframework1/library/Zend/Locale/Math.php:259
Stack trace:
#0 /var/www/html/vendor/magento/zendframework1/library/Zend/Locale/Math.php(259): bcsub()
#1 /var/www/html/vendor/magento/zendframework1/library/Zend/Locale/Format.php(385): Zend_Locale_Math::Sub()
#2 /var/www/html/vendor/magento/zendframework1/library/Zend/Locale/Format.php(662): Zend_Locale_Format::toNumber()
#3 /var/www/html/vendor/magento/zendframework1/library/Zend/Filter/NormalizedToLocalized.php(106): Zend_Locale_Format::toFloat()
#4 /var/www/html/vendor/magento/framework/Data/Form/Filter/Date.php(69): Zend_Filter_NormalizedToLocalized->filter()
#5 /var/www/html/vendor/magento/module-customer/Model/Metadata/Form/AbstractData.php(197): Magento\Framework\Data\Form\Filter\Date->inputFilter()
#6 /var/www/html/vendor/magento/module-customer/Model/Metadata/Form/Date.php(20): Magento\Customer\Model\Metadata\Form\AbstractData->_applyInputFilter()
#7 /var/www/html/vendor/magento/module-customer/Model/Metadata/Form.php(244): Magento\Customer\Model\Metadata\Form\Date->extractValue()
#8 /var/www/html/generated/code/Magento/Customer/Model/Metadata/Form/Interceptor.php(23): Magento\Customer\Model\Metadata\Form->extractData()
#9 /var/www/html/vendor/magento/module-customer/Model/CustomerExtractor.php(84): Magento\Customer\Model\Metadata\Form\Interceptor->extractData()
#10 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Customer\Model\CustomerExtractor->extract()
#11 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Customer\Model\CustomerExtractor\Interceptor->___callParent()
#12 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Customer\Model\CustomerExtractor\Interceptor->Magento\Framework\Interception\{closure}()
#13 /var/www/html/generated/code/Magento/Customer/Model/CustomerExtractor/Interceptor.php(23): Magento\Customer\Model\CustomerExtractor\Interceptor->___callPlugins()
#14 /var/www/html/vendor/magento/module-customer/Controller/Account/CreatePost.php(368): Magento\Customer\Model\CustomerExtractor\Interceptor->extract()
#15 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Customer\Controller\Account\CreatePost->execute()
#16 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Customer\Controller\Account\CreatePost\Interceptor->___callParent()
#17 /var/www/html/vendor/magento/module-customer/Controller/Plugin/Account.php(64): Magento\Customer\Controller\Account\CreatePost\Interceptor->Magento\Framework\Interception\{closure}()
#18 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Customer\Controller\Plugin\Account->aroundExecute()
#19 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Customer\Controller\Account\CreatePost\Interceptor->Magento\Framework\Interception\{closure}()
#20 /var/www/html/generated/code/Magento/Customer/Controller/Account/CreatePost/Interceptor.php(23): Magento\Customer\Controller\Account\CreatePost\Interceptor->___callPlugins()
#21 /var/www/html/vendor/magento/framework/App/Action/Action.php(111): Magento\Customer\Controller\Account\CreatePost\Interceptor->execute()
#22 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch()
#23 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Customer\Controller\Account\CreatePost\Interceptor->___callParent()
#24 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Customer\Controller\Account\CreatePost\Interceptor->Magento\Framework\Interception\{closure}()
#25 /var/www/html/generated/code/Magento/Customer/Controller/Account/CreatePost/Interceptor.php(32): Magento\Customer\Controller\Account\CreatePost\Interceptor->___callPlugins()
#26 /var/www/html/vendor/magento/framework/App/FrontController.php(245): Magento\Customer\Controller\Account\CreatePost\Interceptor->dispatch()
#27 /var/www/html/vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()
#28 /var/www/html/vendor/magento/framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest()
#29 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()
#30 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()
#31 /var/www/html/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(99): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#32 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch()
#33 /var/www/html/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(75): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#34 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch()
#35 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#36 /var/www/html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()
#37 /var/www/html/vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()
#38 /var/www/html/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
#39 /var/www/html/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#40 {main}

@jmonrove
Copy link

@kmosdev Hi! That's the patch that I've used, I'd go with "!$block->getNameInLayout()" since the return value is just a string|null and "!" is doing the same thing as "empty"

file: magentoroot/patches/composer/github-issue-35542.diff

diff --git a/Observer/AdminhtmlBlockHtmlBeforeObserver.php b/Observer/AdminhtmlBlockHtmlBeforeObserver.php
index 974b4ec..1978e66 100644
--- a/Observer/AdminhtmlBlockHtmlBeforeObserver.php
+++ b/Observer/AdminhtmlBlockHtmlBeforeObserver.php
@@ -118,6 +118,9 @@ class AdminhtmlBlockHtmlBeforeObserver implements ObserverInterface
     {
         /** @var $block Template */
         $block = $observer->getBlock();
+        if (!$block->getNameInLayout()) {
+            return;
+        }
 
         $this->_filterByBlockName($block);

file: magentoroot/composer.json

{
    [...]
    "extra": {
        [...]
        "patches": { 
            [...]
            "magento/module-price-permissions": {
                "skip composer execution for missing block name": "patches/composer/github-issue-35542.diff"
            },
            [...]
        }
        [...]
    }
    [...]
}

This fixed an issue on my Commerce edition on version 2.4.5-p1 in which I was getting the same error on a 3rd party module, patching the core magento vendor file as suggested worked wonders, thank you

@jayantakr1
Copy link

Hi,
I am getting same issue in Mageto2.4.5-p1 CE version, Anyone please help me . How to solve this issue?

ValueError: bcsub(): Argument #1 ($num1) is not well-formed in /var/www/html/vendor/magento/zendframework1/library/Zend/Locale/Math.php:259
Stack trace:
#0 /var/www/html/vendor/magento/zendframework1/library/Zend/Locale/Math.php(259): bcsub()
#1 /var/www/html/vendor/magento/zendframework1/library/Zend/Locale/Format.php(385): Zend_Locale_Math::Sub()
#2 /var/www/html/vendor/magento/zendframework1/library/Zend/Locale/Format.php(662): Zend_Locale_Format::toNumber()
#3 /var/www/html/vendor/magento/zendframework1/library/Zend/Filter/NormalizedToLocalized.php(106): Zend_Locale_Format::toFloat()
#4 /var/www/html/vendor/magento/framework/Data/Form/Filter/Date.php(69): Zend_Filter_NormalizedToLocalized->filter()
#5 /var/www/html/vendor/magento/module-customer/Model/Metadata/Form/AbstractData.php(197): Magento\Framework\Data\Form\Filter\Date->inputFilter()
#6 /var/www/html/vendor/magento/module-customer/Model/Metadata/Form/Date.php(20): Magento\Customer\Model\Metadata\Form\AbstractData->_applyInputFilter()
#7 /var/www/html/vendor/magento/module-customer/Model/Metadata/Form.php(244): Magento\Customer\Model\Metadata\Form\Date->extractValue()
#8 /var/www/html/generated/code/Magento/Customer/Model/Metadata/Form/Interceptor.php(23): Magento\Customer\Model\Metadata\Form->extractData()
#9 /var/www/html/vendor/magento/module-customer/Model/CustomerExtractor.php(84): Magento\Customer\Model\Metadata\Form\Interceptor->extractData()
#10 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Customer\Model\CustomerExtractor->extract()
#11 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Customer\Model\CustomerExtractor\Interceptor->___callParent()
#12 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Customer\Model\CustomerExtractor\Interceptor->Magento\Framework\Interception{closure}()
#13 /var/www/html/generated/code/Magento/Customer/Model/CustomerExtractor/Interceptor.php(23): Magento\Customer\Model\CustomerExtractor\Interceptor->___callPlugins()
#14 /var/www/html/vendor/magento/module-customer/Controller/Account/CreatePost.php(368): Magento\Customer\Model\CustomerExtractor\Interceptor->extract()
#15 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Customer\Controller\Account\CreatePost->execute()
#16 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Customer\Controller\Account\CreatePost\Interceptor->___callParent()
#17 /var/www/html/vendor/magento/module-customer/Controller/Plugin/Account.php(64): Magento\Customer\Controller\Account\CreatePost\Interceptor->Magento\Framework\Interception{closure}()
#18 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Customer\Controller\Plugin\Account->aroundExecute()
#19 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Customer\Controller\Account\CreatePost\Interceptor->Magento\Framework\Interception{closure}()
#20 /var/www/html/generated/code/Magento/Customer/Controller/Account/CreatePost/Interceptor.php(23): Magento\Customer\Controller\Account\CreatePost\Interceptor->___callPlugins()
#21 /var/www/html/vendor/magento/framework/App/Action/Action.php(111): Magento\Customer\Controller\Account\CreatePost\Interceptor->execute()
#22 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch()
#23 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Customer\Controller\Account\CreatePost\Interceptor->___callParent()
#24 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Customer\Controller\Account\CreatePost\Interceptor->Magento\Framework\Interception{closure}()
#25 /var/www/html/generated/code/Magento/Customer/Controller/Account/CreatePost/Interceptor.php(32): Magento\Customer\Controller\Account\CreatePost\Interceptor->___callPlugins()
#26 /var/www/html/vendor/magento/framework/App/FrontController.php(245): Magento\Customer\Controller\Account\CreatePost\Interceptor->dispatch()
#27 /var/www/html/vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()
#28 /var/www/html/vendor/magento/framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest()
#29 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()
#30 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()
#31 /var/www/html/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(99): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}()
#32 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch()
#33 /var/www/html/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(75): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}()
#34 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch()
#35 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}()
#36 /var/www/html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()
#37 /var/www/html/vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()
#38 /var/www/html/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
#39 /var/www/html/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#40 {main}

@mmaximo33
Copy link

mmaximo33 commented Apr 26, 2023

Hi team.

I had the same problem when upgrading
From: "magento/magento-cloud-metapackage": ">=2.3.5 <2.4.4",
To "magento/magento-cloud-metapackage": ">= 2.4.6 <2.4.7",

With a third-party module @plumrocket plumrocket/module-datagenerator:2.6.11 marketplace.magento

I hope it can be useful

Regards
Maximo

Sequence Menu > Plumrocket > Data Feed Generator > Manage Data Feed List > Enter a list item
Logs
1 exception(s):
Exception #0 (Exception): Deprecated Functionality: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /var/www/html/vendor/magento/module-price-permissions/Observer/AdminhtmlBlockHtmlBeforeObserver.php on line 133

Exception #0 (Exception): Deprecated Functionality: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /var/www/html/vendor/magento/module-price-permissions/Observer/AdminhtmlBlockHtmlBeforeObserver.php on line 133
<pre>#1 stripos() called at [vendor/magento/module-price-permissions/Observer/AdminhtmlBlockHtmlBeforeObserver.php:133]
#2 Magento\PricePermissions\Observer\AdminhtmlBlockHtmlBeforeObserver->execute() called at [vendor/magento/framework/Event/Invoker/InvokerDefault.php:88]
#3 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() called at [vendor/magento/framework/Event/Invoker/InvokerDefault.php:74]
#4 Magento\Framework\Event\Invoker\InvokerDefault->dispatch() called at [vendor/magento/module-staging/Model/Event/Manager.php:97]
#5 Magento\Staging\Model\Event\Manager->dispatch() called at [generated/code/Magento/Staging/Model/Event/Manager/Proxy.php:95]
#6 Magento\Staging\Model\Event\Manager\Proxy->dispatch() called at [vendor/magento/module-backend/Block/Template.php:140]
#7 Magento\Backend\Block\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1095]
#8 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1099]
#9 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:660]
#10 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/module-backend/Block/Widget/Form/Renderer/Fieldset.php:50]
#11 Magento\Backend\Block\Widget\Form\Renderer\Fieldset->render() called at [vendor/magento/framework/Data/Form/Element/AbstractElement.php:541]
#12 Magento\Framework\Data\Form\Element\AbstractElement->getHtml() called at [vendor/magento/framework/Data/Form/Element/AbstractElement.php:555]
#13 Magento\Framework\Data\Form\Element\AbstractElement->toHtml() called at [vendor/magento/framework/Data/Form.php:373]
#14 Magento\Framework\Data\Form->toHtml() called at [vendor/magento/framework/Data/Form.php:390]
#15 Magento\Framework\Data\Form->getHtml() called at [vendor/magento/module-backend/Block/Widget/Form.php:113]
#16 Magento\Backend\Block\Widget\Form->getFormHtml() called at [vendor/magento/module-backend/view/adminhtml/templates/widget/form.phtml:13]
#17 include() called at [vendor/magento/framework/View/TemplateEngine/Php.php:71]
#18 Magento\Framework\View\TemplateEngine\Php->render() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#19 Magento\Framework\View\TemplateEngine\Php\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#20 Magento\Framework\View\TemplateEngine\Php\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#21 Magento\Framework\View\TemplateEngine\Php\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/TemplateEngine/Php/Interceptor.php:23]
#22 Magento\Framework\View\TemplateEngine\Php\Interceptor->render() called at [vendor/magento/framework/View/Element/Template.php:263]
#23 Magento\Framework\View\Element\Template->fetchView() called at [vendor/magento/framework/View/Element/Template.php:293]
#24 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/module-backend/Block/Template.php:141]
#25 Magento\Backend\Block\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1095]
#26 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1099]
#27 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:660]
#28 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/module-backend/Block/Widget/Tabs.php:492]
#29 Magento\Backend\Block\Widget\Tabs->getTabContent() called at [vendor/magento/module-backend/view/adminhtml/templates/widget/tabs.phtml:73]
#30 include() called at [vendor/magento/framework/View/TemplateEngine/Php.php:71]
#31 Magento\Framework\View\TemplateEngine\Php->render() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#32 Magento\Framework\View\TemplateEngine\Php\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#33 Magento\Framework\View\TemplateEngine\Php\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#34 Magento\Framework\View\TemplateEngine\Php\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/TemplateEngine/Php/Interceptor.php:23]
#35 Magento\Framework\View\TemplateEngine\Php\Interceptor->render() called at [vendor/magento/framework/View/Element/Template.php:263]
#36 Magento\Framework\View\Element\Template->fetchView() called at [vendor/magento/framework/View/Element/Template.php:293]
#37 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/module-backend/Block/Template.php:141]
#38 Magento\Backend\Block\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1095]
#39 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1099]
#40 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:660]
#41 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/View/Layout.php:578]
#42 Magento\Framework\View\Layout->_renderBlock() called at [vendor/magento/framework/View/Layout.php:555]
#43 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#44 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#45 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#46 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#47 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#48 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#49 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#50 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#51 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#52 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#53 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#54 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#55 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#56 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#57 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#58 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#59 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#60 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#61 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#62 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#63 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#64 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#65 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Layout.php:975]
#66 Magento\Framework\View\Layout->getOutput() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:50]
#67 Magento\Framework\View\Layout\Interceptor->getOutput() called at [vendor/magento/framework/View/Result/Page.php:260]
#68 Magento\Framework\View\Result\Page->render() called at [vendor/magento/framework/View/Result/Layout.php:171]
#69 Magento\Framework\View\Result\Layout->renderResult() called at [generated/code/Magento/Backend/Model/View/Result/Page/Interceptor.php:32]
#70 Magento\Backend\Model\View\Result\Page\Interceptor->renderResult() called at [vendor/magento/framework/App/View.php:221]
#71 Magento\Framework\App\View->renderLayout() called at [app/code/Plumrocket/Base/Controller/Adminhtml/Actions.php:156]
#72 Plumrocket\Base\Controller\Adminhtml\Actions->_editAction() called at [app/code/Plumrocket/Datagenerator/Controller/Adminhtml/Datagenerator.php:136]
#73 Plumrocket\Datagenerator\Controller\Adminhtml\Datagenerator->_editAction() called at [app/code/Plumrocket/Base/Controller/Adminhtml/Actions.php:76]
#74 Plumrocket\Base\Controller\Adminhtml\Actions->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#75 Plumrocket\Datagenerator\Controller\Adminhtml\Datagenerator\Edit\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#76 Plumrocket\Datagenerator\Controller\Adminhtml\Datagenerator\Edit\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#77 Plumrocket\Datagenerator\Controller\Adminhtml\Datagenerator\Edit\Interceptor->___callPlugins() called at [generated/code/Plumrocket/Datagenerator/Controller/Adminhtml/Datagenerator/Edit/Interceptor.php:23]
#78 Plumrocket\Datagenerator\Controller\Adminhtml\Datagenerator\Edit\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:111]
#79 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/module-backend/App/AbstractAction.php:151]
#80 Magento\Backend\App\AbstractAction->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#81 Plumrocket\Datagenerator\Controller\Adminhtml\Datagenerator\Edit\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#82 Plumrocket\Datagenerator\Controller\Adminhtml\Datagenerator\Edit\Interceptor->Magento\Framework\Interception\{closure}() called at [app/code/WeltPixel/Backend/Plugin/Utility.php:76]
#83 WeltPixel\Backend\Plugin\Utility->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#84 Plumrocket\Datagenerator\Controller\Adminhtml\Datagenerator\Edit\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:145]
#85 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#86 Plumrocket\Datagenerator\Controller\Adminhtml\Datagenerator\Edit\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#87 Plumrocket\Datagenerator\Controller\Adminhtml\Datagenerator\Edit\Interceptor->___callPlugins() called at [generated/code/Plumrocket/Datagenerator/Controller/Adminhtml/Datagenerator/Edit/Interceptor.php:32]
#88 Plumrocket\Datagenerator\Controller\Adminhtml\Datagenerator\Edit\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:245]
#89 Magento\Framework\App\FrontController->getActionResponse() called at [vendor/magento/framework/App/FrontController.php:212]
#90 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:147]
#91 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#92 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#93 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#94 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:23]
#95 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:116]
#96 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:264]
#97 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:30]

Solution https://github.com//issues/35542#issuecomment-1173031379

@kmosdev Hi! That's the patch that I've used, I'd go with "!$block->getNameInLayout()" since the return value is just a string|null and "!" is doing the same thing as "empty"

file: magentoroot/patches/composer/github-issue-35542.diff

diff --git a/Observer/AdminhtmlBlockHtmlBeforeObserver.php b/Observer/AdminhtmlBlockHtmlBeforeObserver.php
index 974b4ec..1978e66 100644
--- a/Observer/AdminhtmlBlockHtmlBeforeObserver.php
+++ b/Observer/AdminhtmlBlockHtmlBeforeObserver.php
@@ -118,6 +118,9 @@ class AdminhtmlBlockHtmlBeforeObserver implements ObserverInterface
     {
         /** @var $block Template */
         $block = $observer->getBlock();
+        if (!$block->getNameInLayout()) {
+            return;
+        }
 
         $this->_filterByBlockName($block);

file: magentoroot/composer.json

{
    [...]
    "extra": {
        [...]
        "patches": { 
            [...]
            "magento/module-price-permissions": {
                "skip composer execution for missing block name": "patches/composer/github-issue-35542.diff"
            },
            [...]
        }
        [...]
    }
    [...]
}

@jmonrove
Copy link

This is still a problem on 2.4.5-p3 and patch had to be re-applied

@ssx
Copy link
Contributor

ssx commented Oct 16, 2023

Still a problem on 2.4.6-p3 as well.

@athercd
Copy link

athercd commented Oct 18, 2023

v2.4.5-p5 and the issue is still there

@engcom-November engcom-November self-assigned this Oct 19, 2023
@m2-assistant
Copy link

m2-assistant bot commented Oct 19, 2023

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: 👇

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

@engcom-November
Copy link
Contributor

Reopening this issue, we will start looking into this.

Thanks.

@m2-community-project m2-community-project bot removed the Issue: needs update Additional information is require, waiting for response label Oct 19, 2023
@engcom-Bravo engcom-Bravo added the Reported on 2.4.1 Indicates original Magento version for the Issue report. label Oct 19, 2023
@IlyaZha
Copy link

IlyaZha commented Nov 10, 2023

For module developers:
to avoid this error do not use any Magento Renderer where $_nameInLayout unset or null. Or, create new class which extends Renderer, specify protected $_nameInLayout = ''; and use this new class.

@engcom-Hotel engcom-Hotel added the Adobe Commerce The issue related to the Adobe Commerce(EE) or B2B functionality label Nov 15, 2023
@engcom-Hotel
Copy link
Contributor

Hello @sheepfy,

By looking into the codebase, we can confirm this issue, if $block->getNameInLayout() returns null with php 8.1 or greater.

Hence confirming the issue.

Thanks

@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Area: Framework and removed Issue: ready for confirmation labels Nov 15, 2023
@github-jira-sync-bot
Copy link

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

Copy link

m2-assistant bot commented Nov 15, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Adobe Commerce The issue related to the Adobe Commerce(EE) or B2B functionality Area: Framework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.1 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Status: Ready for Development
Development

No branches or pull requests