magento / devdocs

Magento Developer Documentation
https://devdocs.magento.com
Open Software License 3.0
673 stars 1.76k forks source link

Block's name is required when attempting to make the block non-cacheable #8981

Closed jajajaime closed 2 years ago

jajajaime commented 3 years ago

Topic clarification/correction request

Topic Link

https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/xml-instructions.html#fedg_layout_xml-instruc_ex_block

Description

The documentation states that a block's name attribute is recommended, otherwise it is given a random name. It also states that a name is not required. The issue comes when a block is marked as cacheable="false" (https://devdocs.magento.com/guides/v2.4/extension-dev-guide/cache/page-caching.html#cache-over-cacheable), making the name required on the block, as a check for a block name is in place, and not having it will not consider the block to be non-cacheable. This check happens before the random name is applied to the block. https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/View/Layout.php#L1128-L1129

Possible solutions

Update the documentation to reflect this conflict, by either making the name attribute required in some cases, and stating that if the cache needs to be skipped for the block, a name is required.

Additional information

This became an issue starting with Magento 2.3.5 and is still present on the latest 2.4 version and dev branch.

m2-assistant[bot] commented 3 years ago

Hi @jajajaime. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


MaksSum41 commented 2 years ago

@magento I am working on this

dobooth commented 2 years ago

Fixed in https://github.com/AdobeDocs/commerce-frontend-core/pull/17