Closed jajajaime closed 2 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
@magento I am working on this
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.