tslib_class.tslib_fe.php_patch.txt

Administrator Admin, 2008-09-03 22:34

Download (2.8 kB)

 
1
Index: /daten/workspace/TYPO3_4_TRUNK/typo3/sysext/cms/tslib/class.tslib_fe.php
2
===================================================================
3
--- /daten/workspace/TYPO3_4_TRUNK/typo3/sysext/cms/tslib/class.tslib_fe.php	(revision 4059)
4
+++ /daten/workspace/TYPO3_4_TRUNK/typo3/sysext/cms/tslib/class.tslib_fe.php	(working copy)
5
@@ -2701,6 +2701,52 @@
6
 	 */
7
 	function setPageCacheContent($content,$data,$tstamp)	{
8
 		$this->clearPageCacheContent();
9
+
10
+		// Call hook for $tstamp calulating
11
+		if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_cacheexpire_timestamp']))    {
12
+		    foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_cacheexpire_timestamp'] as $_classRef)    {
13
+		    	$_procObj = &t3lib_div::getUserObj($_classRef);
14
+		        $tstamp = $_procObj->calculateExpireTimestamp(array('tstamp' => $tstamp, 'pid' => $this->id),$this);
15
+		    }
16
+		}
17
+		
18
+		$sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
19
+		
20
+		// Workspace does not matter, because they are on an different page
21
+		// so whe can use $this-id to check for content elements on this page
22
+		// Versioning does not matter, because they got pid = -1
23
+		$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', '
24
+		tt_content.pid='.intval($this->id).' 
25
+		AND (
26
+			(tt_content.starttime > '.$GLOBALS['EXEC_TIME'].' AND tt_content.starttime < '.$tstamp.')
27
+			OR 
28
+			(tt_content.endtime > '.$GLOBALS['EXEC_TIME'].' AND tt_content.endtime < '.$tstamp.')
29
+		) '.$sys_page->enableFields('tt_content',0,array('starttime' => true,'endtime' => true),FALSE));
30
+		
31
+		while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
32
+			// $tstamp is the orignial expire-date of that page
33
+			// usually it is calculated by cache-expiredate and 
34
+			// $GLOBALS['EXEC_TIME']
35
+			// the page starttime/endtime is checked before
36
+			// it is requested from cache. So we do not have to care
37
+			// of starttime/endtime of the page itself 
38
+			
39
+			// we want to respect the starttime / endtime of the
40
+			// content elements 
41
+			// 
42
+			// we have to check for each content element only, if it has a starttime
43
+			// or an endtime which takes effect betwwen $GLOBALS['EXEC_TIME']
44
+			// and the default-expire date ($tstamp). 
45
+			if ($row['starttime'] < $tstamp && $row['starttime'] > $GLOBALS['EXEC_TIME']) {
46
+				t3lib_div::devLog('Expires was: '.$tstamp.' new Timestamp via starttime is: '.$row['starttime'].' (ID='.$row['id'].')','cacheexpire',0,$row);  
47
+				$tstamp = $row['starttime'];
48
+			}
49
+			if ($row['endtime'] < $tstamp && $row['endtime'] > $GLOBALS['EXEC_TIME']) {
50
+				t3lib_div::devLog('Expires was: '.$tstamp.' new Timestamp via endtime is: '.$row['endtime'].' (ID='.$row['id'].')','cacheexpire',0,$row);
51
+				$tstamp = $row['endtime'];
52
+			}
53
+		}
54
+		
55
 		$insertFields = array(
56
 			'hash' => $this->newHash,
57
 			'page_id' => $this->id,