magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.31k forks source link

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

Open sheepfy opened 2 years ago

sheepfy commented 2 years ago

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) {
  2. 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.

m2-assistant[bot] commented 2 years ago

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

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.


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

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

m2-assistant[bot] commented 2 years ago

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

engcom-Hotel commented 2 years ago

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

sheepfy commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

@kmosdev How did you create that patch?

sheepfy commented 2 years ago

@johncy65 using this: https://github.com/cweagans/composer-patches

ghost commented 2 years ago

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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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
#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/magento/magento2/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 > 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 commented 1 year ago

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

ssx commented 11 months ago

Still a problem on 2.4.6-p3 as well.

athercd commented 11 months ago

v2.4.5-p5 and the issue is still there

m2-assistant[bot] commented 11 months ago

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:

engcom-November commented 11 months ago

Reopening this issue, we will start looking into this.

Thanks.

IlyaZha commented 11 months ago

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 commented 11 months ago

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

github-jira-sync-bot commented 11 months ago

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

m2-assistant[bot] commented 11 months ago

:white_check_mark: 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.