Bug #24406

error when using t3lib_TCEmain->clear_cacheCmd in frontend

Added by Krystian Szymukowicz almost 6 years ago. Updated almost 5 years ago.

Status:Closed Start date:2010-12-23
Priority:Should have Due date:
Assigned To:Steffen Gebert % Done:

0%

Category:Communication Spent time: -
Target version:-
TYPO3 Version: Complexity:
PHP Version: Is Regression:
Tags: Sprint Focus:

Description

PROBLEM:

in rev. 8481 there has been added writelog when clearing the cache.

public function clear_cacheCmd($cacheCmd) {

$this->BE_USER->writelog(..........

But some extesions like Dmitry Dulepov 'comments' are using 'clear_cacheCmd' from frontend where $this->BE_USER is not initialised.

So we get:
Fatal error: Call to a member function writelog() on a non-object in T:\workspace-typo3\typo3\typo3_src-svn-trunk\t3lib\class.t3lib_tcemain.php on line 6761

SOLUTION:

Check if we are in BE mode while writing the log.

if (TYPO3_MODE === 'BE') {
$this->BE_USER->writelog(....
}

(issue imported from #M16832)

16832.patch Magnifier (737 Bytes) Administrator Admin, 2010-12-25 18:58


Related issues

related to Core - Bug #25114: [Patch] Fatal error in /t3lib/class.t3lib_tcemain.php on ... Closed 2011-02-20
related to Core - Bug #28007: TCEmain::clear_cacheCmd relies on active BE_USER Resolved 2011-07-08

History

#1 Updated by Steffen Gebert almost 6 years ago

Krystian, could you please provide a patch against SVN trunk and send it to the core list?

#2 Updated by Krystian Szymukowicz almost 6 years ago

Sure - I am waiting becasue I thought that Steffan Kamper wants to make some wrapper for frontend cache clearing.

But if the above is still a valid solution then I will prepare the patch.

#3 Updated by Steffen Gebert almost 6 years ago

Ah, okay.. however I wonder, when Steffen wants to do this (AFAIK he's on holiday soon) and we already have feature freeze.. so I would expect the wrapper for 4.6

#4 Updated by Krystian Szymukowicz almost 6 years ago

Right. - so here is the patch and I wil post in the core list in minute.

#5 Updated by Krystian Szymukowicz almost 6 years ago

At core list Steffen Kamper found out that there are special functions for clearing the cache in the frontend so using t3lib_TCEmain for this is not quite proper.
This is a bug of extension "comments" then not the core and this bug can be closed.

Post of Steffen Kamper:
------------------------------------------------------------------------------------------

i investigated this issue, and it's nonsense to call tcemain from FE as
this is not intended to do so.

Clearing cache in FE is possible as it's built in. The only senseful is
clearing page cache, configuration cache or rte cache is not allowed
from FE context.

To clear cahce in FE there are two functions available:

$GLOBALS['TSFE']->clearPageCacheContent() <= clears all page cache
$GLOBALS['TSFE']->clearPageCacheContent_pidList($pidList) <= clears
cache of pages for given uid's

So this is all what is needed for FE. For own cache using cache
framework there are the built in functions from cache framework.

#6 Updated by Steffen Gebert almost 6 years ago

So please use the correct API in your extensions.
Bug is closed, but #16843 for EXT:comments is opened.

RFC dropped.

#7 Updated by Steffen Gebert over 5 years ago

Just a note: That's not true:
$GLOBALS['TSFE']->clearPageCacheContent() <= clears all page cache

It only clears the cache of this particular page, also dependent on the allowed FE user groups.

#8 Updated by Nikolas Hagelstein over 5 years ago

Hmmm does not work from cli scripts as well :<

#9 Updated by Nikolas Hagelstein over 5 years ago

Nikolas Hagelstein wrote:

Hmmm does not work from cli scripts as well :<

Forget about this comment i just forgot to call the start method.

#10 Updated by Klaus Hinum almost 5 years ago

Nikolas Hagelstein wrote:

Nikolas Hagelstein wrote:

Hmmm does not work from cli scripts as well :<

Forget about this comment i just forgot to call the start method.

My CLI script also won't work any more with clear_cacheCmd($cacheCmd) and exits with the error from this bug report. How to clear the cache for a specific page now using CLI?

Also available in: Atom PDF