brotkrueml / schema

TYPO3 extension providing an API and view helpers for schema.org markup

Home Page:https://extensions.typo3.org/extension/schema

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support custom page cache tags at schema page caches

websi opened this issue · comments

Is your feature request related to a problem? Please describe.

If an extension add additional cache tags to the page, the page ignored by the schema extension

Describe the solution you'd like

The custom cache tags should be also used.

Describe alternatives you've considered

Teachability, Documentation, Adoption, Migration Strategy

Additional context

Patch:

Index: Classes/Cache/PagesCacheService.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Classes/Cache/PagesCacheService.php b/Classes/Cache/PagesCacheService.php
--- a/Classes/Cache/PagesCacheService.php
+++ b/Classes/Cache/PagesCacheService.php   (date 1685615295287)
@@ -46,7 +46,7 @@
             $this->cache->set(
                 $this->getCacheIdentifier(),
                 $markup,
-                ['pageId_' . $this->controller->page['uid']],
+                array_merge(['pageId_' . $this->controller->page['uid']], $this->controller->getPageCacheTags()),
                 $this->controller->get_cache_timeout()
             );
         }

@websi I don't really understand the problem. EXT:schema uses a custom cache identifier (something like 32_ee1908e5560a6638ccfe2cc3f9f385c5-tx-schema, mind the -tx-schema at the end) not the default page cache identifier (something like 32_ee1908e5560a6638ccfe2cc3f9f385c5) to store the generated JSON-LD. So that should not interfere with your cache entries? Perhaps you can give an example where this a problem.

Yes. if you add an extra page cache tag to the page. For example tx_example_domain_model_product_14.
Then the page cache entry 298_19fb783768c57d291e2699670edd13ba has a tag tx_example_domain_model_product_14 and pageId_298.
But the 298_19fb783768c57d291e2699670edd13ba-tx-schema has only pageId_298.

if you save the record with the id 14 for the table tx_example_domain_model_product the cache for the page was cleared but the cache for schema was not cleared. So the content of the schema hast the old content of the product.

Link to core: https://github.com/TYPO3/typo3/blob/37c6b702d1fb5f791921dc569f343752706db94b/typo3/sysext/core/Classes/DataHandling/DataHandler.php#L9239

Example data before patch:

Table cache_pages_tags

id identifier tag
1 298_19fb783768c57d291e2699670edd13ba-tx-schema pageId_298
5 298_19fb783768c57d291e2699670edd13ba tx_example_domain_model_product_14
8 298_19fb783768c57d291e2699670edd13ba pageId_298

Example data after patch:

Table cache_pages_tags

id identifier tag
1 298_19fb783768c57d291e2699670edd13ba-tx-schema pageId_298
2 298_19fb783768c57d291e2699670edd13ba-tx-schema tx_example_domain_model_product_14
5 298_19fb783768c57d291e2699670edd13ba tx_example_domain_model_product_14
8 298_19fb783768c57d291e2699670edd13ba pageId_298

@websi Yup, you are right. Good catch. Thanks for the report and the clarification. I will provide a bugfix version.

Version 2.9.1 was released which fixes this bug.