[TYPO3-dev] scheduler_task should clear cache for one page [solved]

Bernd Wilke t3ng at pi-phi.tk
Fri Aug 26 13:08:00 CEST 2011


On 08/26/2011 12:30 PM, Loek Hilgersom wrote:
> Hi Bernd,
>
> I had a similar problem with my mail2news extension, but I used
> clear_cacheCmd. Until TYPO3 4.4 it worked like this:
>
> function clearpagecache($pid_list) {
> $tce = t3lib_div::makeInstance('t3lib_TCEmain');
> $pid_array = explode(',', $pid_list);
> foreach ($pid_array as $pid) {
> $tce->clear_cacheCmd($pid);
> }
> }
>
> but in 4.5 something was changed in the clear_cacheCmd methods, which no
> longer allowed these to be used in FE-plugins [1]. But, strange enough,
> that also made it stop working in scheduler tasks (which should be BE,
> but is not entirely the same as running a BE-module, apparently).

this might depend on the new mode CLI which is not BE.

> After some more searching and experimenting I found that this does work:
>
> function clearpagecache($pid_list) {
> $tce = t3lib_div::makeInstance('t3lib_TCEmain');
> $tce->start('', '');
> $pid_array = explode(',', $pid_list);
> foreach ($pid_array as $pid) {
> $tce->clear_cacheCmd($pid);
> }
> }


my working solution:
	$TCE = t3lib_div::makeInstance('t3lib_TCEmain');
	// this seems to initalized a BE-User
	$TCE->start(Array(),Array());
	// so this line does not throw an error any more
	$TCE->clear_cache('tt_news',$oneRecordId);

with this I simulated one record-change
and in combination with the Page-TSconfig:
	TCEMAIN.clearCacheCmd = 40
I get a cleared cache.

bernd
-- 
http://www.pi-phi.de/cheatsheet.html




More information about the TYPO3-dev mailing list