Skip to content

Cms block cache key does not contain the store id #22299

Closed
@tzyganu

Description

@tzyganu

Preconditions (*)

  1. Magento version 2.2.6
  2. create one block that contains a {{trans}} directive. Or 2 blocks with the same identifier but each one available on a different store view
  3. Block cache must be enabled.

Steps to reproduce (*)

  1. Add the block in the layout and specify a cache lifetime
            <block class="Magento\Cms\Block\Block" name="some-name-here">
                <arguments>
                    <argument name="block_id" xsi:type="string">block-identifier-here</argument>
                    <argument name="cache_lifetime" xsi:type="number">84600</argument>
                </arguments>
            </block>

Expected result (*)

  1. Loading the pages that contain this block on 2 different store views will show the proper content of the block for each website

Actual result (*)

  1. Opening the page that contains the block on the second store view shows the cached version of the block from the first store view.

Additional info:

This happens because the cache key of the cms block is determined by Magento\Framework\View\Element\AbstractBlock::getCacheKey which calls getCacheKeyInfo from the same class which returns an array with the name of the block in the layout.

Possible solution:

Adding the store id to the cache key or to the array returned by getCacheKeyInfo.

Metadata

Metadata

Assignees

Labels

Component: Framework/ViewFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentProgress: PR CreatedIndicates that Pull Request has been created to fix issueReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions