[TYPO3-core] RFC: Bug 4581: Duplicate entry on cache_pagesection on reloading twice

Michael Stucki michael at typo3.org
Thu Jan 25 01:09:11 CET 2007


Ernesto Baschny [cron IT] wrote:
> > So the data that should be written to the database changes every second.
> > To simply test this issue, I suggest to set $dbFields['tstamp']=1 and of
> > course
> > FE caching should be disabled.
>
> Now looking at this I wonder why would we want to save to
> cache_pagesection if we have no_cache turned ON?

Turning it on seems to help to reproduce the error. However, the error may 
also occur if all of the following conditions match:

- page X is not in the cache yet
- client A requests page X, processes it, and finally stores it into the cache
- client B requests the same page while A didn't write the cache yet

> Maybe the solution here is not even save anything to cache_pagesection
> if we are going to throw it away in 1 second anyway...

No, but it helps to reduce the chance that this may happen to a minimum. Good 
idea! So I just finished the attached patch, which seems to work quite well.


Since this seems to be quite tricky to follow easily, here is a rough 
explanation of the workflow: (current and new - the patch won't change this)

1. cache_pagesection is only written when the template parser is started

2. the template parser is only started if $TSFE->config is not an array

3. $TSFE->config is only set if the following condition matches:

	if ($this->all && !$this->no_cache && !$this->headerNoCache())	{

4. $this->all = the template of this condition combination exists in the cache


So far this means, that the template parser is only started in two situations:

- no_cache (or headerNoCache) is forced
- or there is no data in the cache


However, the cache should only be written in the latter situation. So this 
patch will change the following behaviours:

As soon as $GLOBALS['TSFE']->no_cache is true, the following operations will 
be skipped:

- TStemplate::start() (the template parser) will not read from
  cache_pagesection

- It also won't write anything into the cache for the same reason

- $GLOBALS['TSFE']->getFromCache() will not access the cache (same as above)


Have a look at the attached patch. Did I forget to consider anything?

- michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: skip_cache_pagesection.diff
Type: text/x-diff
Size: 4533 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20070125/564130e0/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: skip_cache_pagesection_w.diff
Type: text/x-diff
Size: 3400 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20070125/564130e0/attachment-0001.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20070125/564130e0/attachment.pgp 


More information about the TYPO3-team-core mailing list