[FEATURE] Add cache_tags to pages table
authorFabrizio Branca <mail@fabrizio-branca.de>
Mon, 27 Feb 2012 21:13:49 +0000 (22:13 +0100)
committerJigal van Hemert <jigal@xs4all.nl>
Tue, 28 Feb 2012 22:04:34 +0000 (23:04 +0100)
By adding a cache_tag field that contains a comma-separated list of tags
that will be attached to the stored content many fine-grained caching
scenarios are possible.

(Also see #34352 that allows to clear pages by tag)

Change-Id: I46ee3a49d0c779f72a84d55882eefa583de6bfe5
Resolves: #34363
Releases: 4.7
Reviewed-on: http://review.typo3.org/9267
Reviewed-by: Jutta Dobner
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
t3lib/stddb/tables.sql
t3lib/stddb/tbl_pages.php
typo3/sysext/cms/locallang_tca.xlf
typo3/sysext/cms/tslib/class.tslib_fe.php

index 64edf41..d297190 100644 (file)
@@ -156,6 +156,7 @@ CREATE TABLE pages (
   lastUpdated int(10) unsigned DEFAULT '0' NOT NULL,
   keywords text,
   cache_timeout int(10) unsigned DEFAULT '0' NOT NULL,
+  cache_tags varchar(255) DEFAULT '' NOT NULL,
   newUntil int(10) unsigned DEFAULT '0' NOT NULL,
   description text,
   no_search tinyint(3) unsigned DEFAULT '0' NOT NULL,
index e28cf72..d349818 100644 (file)
@@ -6,7 +6,7 @@ if (!defined('TYPO3_MODE')) {
 $TCA['pages'] = array(
        'ctrl' => $TCA['pages']['ctrl'],
        'interface' => array(
-               'showRecordFieldList' => 'doktype,title,alias,hidden,starttime,endtime,fe_group,url,target,no_cache,shortcut,keywords,description,abstract,newUntil,lastUpdated,cache_timeout,backend_layout,backend_layout_next_level',
+               'showRecordFieldList' => 'doktype,title,alias,hidden,starttime,endtime,fe_group,url,target,no_cache,shortcut,keywords,description,abstract,newUntil,lastUpdated,cache_timeout,cache_tags,backend_layout,backend_layout_next_level',
                'maxDBListItems' => 30,
                'maxSingleDBListItems' => 50,
        ),
@@ -448,6 +448,16 @@ $TCA['pages'] = array(
                                'default' => '0',
                        ),
                ),
+               'cache_tags' => array(
+                       'exclude' => 1,
+                       'label' => 'LLL:EXT:cms/locallang_tca.xml:pages.cache_tags',
+                       'config' => array(
+                               'type' => 'input',
+                               'size' => '30',
+                               'max' => '255',
+                               'eval' => '',
+                       ),
+               ),
                'no_cache' => array(
                        'exclude' => 1,
                        'label' => 'LLL:EXT:cms/locallang_tca.xml:pages.no_cache',
@@ -907,7 +917,7 @@ $TCA['pages'] = array(
                        'showitem' => 'layout, lastUpdated, newUntil, no_search',
                ),
                '3' => array(
-                       'showitem' => 'alias, target, no_cache, cache_timeout, url_scheme',
+                       'showitem' => 'alias, target, no_cache, cache_timeout, cache_tags, url_scheme',
                ),
                '5' => array(
                        'showitem' => 'author, author_email', 'canNotCollapse' => 1,
@@ -994,7 +1004,7 @@ $TCA['pages'] = array(
                        'canNotCollapse' => 1,
                ),
                'caching' => array(
-                       'showitem' => 'cache_timeout;LLL:EXT:cms/locallang_tca.xml:pages.cache_timeout_formlabel, no_cache;LLL:EXT:cms/locallang_tca.xml:pages.no_cache_formlabel',
+                       'showitem' => 'cache_timeout;LLL:EXT:cms/locallang_tca.xml:pages.cache_timeout_formlabel, cache_tags, no_cache;LLL:EXT:cms/locallang_tca.xml:pages.no_cache_formlabel',
                        'canNotCollapse' => 1,
                ),
                'language' => array(
index 028ae9e..e7a85ef 100644 (file)
                        <trans-unit id="pages.cache_timeout.I.10" xml:space="preserve">
                                <source>1 month</source>
                        </trans-unit>
+                       <trans-unit id="pages.cache_tags" xml:space="preserve">
+                               <source>Cache Tags:</source>
+                       </trans-unit>
                        <trans-unit id="pages.editlock_formlabel" xml:space="preserve">
                                <source>Editable for Admins Only</source>
                        </trans-unit>
index d5f9bf9..6603def 100644 (file)
                        $this->pageCacheTags[] = 'reg1_' . $reg1;
                }
 
+               if (!empty($this->page['cache_tags'])) {
+                       $tags = t3lib_div::trimExplode(',', $this->page['cache_tags'], TRUE);
+                       $this->pageCacheTags = array_merge($this->pageCacheTags, $tags);
+               }
+
                $this->pageCache->set(
                        $this->newHash,
                        $cacheData,