Bug #28007

TCEmain::clear_cacheCmd relies on active BE_USER

Added by Jochen Weiland over 8 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Backend API
Target version:
Start date:
2011-07-08
Due date:
% Done:

100%

TYPO3 Version:
4.5
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Sympton:

An extension (like ve_guestbook) might clear the cache with this command:

$GLOBALS ['TSFE']->clearPageCacheContent_pidList ( $GLOBALS ['TSFE']->id );

Since clearing of the cache is now written to the system log, the following call in function clear_cacheCmd() class.t3lib_tcemain.php will fail if no BE_USER is logged in:

$this->BE_USER->writelog(3, 1, 0, 0, 'User %s has cleared the cache (cacheCmd=%s)', array($this->BE_USER->user['username'], $cacheCmd));

Solution: check whether a BE_USER object exists before making the call to the log (otherwise the log message would have no user name either)

if ($this->BE_USER) {
$this->BE_USER->writelog(3, 1, 0, 0, 'User %s has cleared the cache (cacheCmd=%s)', array($this->BE_USER->user['username'], $cacheCmd));
}


Related issues

Related to TYPO3 Core - Bug #32666: Fatal error during install process Closed 2011-12-18
Related to TYPO3 Core - Bug #24406: error when using t3lib_TCEmain->clear_cacheCmd in frontend Closed 2010-12-23
Related to TYPO3 Core - Bug #25287: error when using t3lib_TCEmain->clear_cacheCmd in CLI mode Closed 2011-03-09
Related to TYPO3 Core - Bug #51829: TCEmain::log relies on active BE_USER Rejected 2013-09-07

Associated revisions

Revision 7b2dc40f (diff)
Added by Steffen Gebert almost 8 years ago

[BUGFIX] TCEmain::clear_cacheCmd relies on active BE_USER

Several developers abuse t3lib_TCEmain and instantiate it also in other
contexts than BE, for which it never was made.

As this breaks several extensions that use it in FE or CLI mode and the
fix is trivial, avoid crashing.

Change-Id: I0998b4fc36bb803f82becbbca0137a7dfd43eb8a
Fixes: #28007
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/7633
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Wouter Wolters
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch

Revision 78ffa6ab (diff)
Added by Steffen Gebert almost 8 years ago

[BUGFIX] TCEmain::clear_cacheCmd relies on active BE_USER

Several developers abuse t3lib_TCEmain and instantiate it also in other
contexts than BE, for which it never was made.

As this breaks several extensions that use it in FE or CLI mode and the
fix is trivial, avoid crashing.

Change-Id: I8df6682f0c28fd73cec461211c87fdcb4c9c4cb1
Fixes: #28007
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/7807
Reviewed-by: Steffen Ritter
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer

Revision 416dd485 (diff)
Added by Steffen Gebert almost 8 years ago

[BUGFIX] TCEmain::clear_cacheCmd relies on active BE_USER

Several developers abuse t3lib_TCEmain and instantiate it also in other
contexts than BE, for which it never was made.

As this breaks several extensions that use it in FE or CLI mode and the
fix is trivial, avoid crashing.

Change-Id: I5d72375fe252184b3ed41c90cf7b06ae45052cc5
Fixes: #28007
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/7806
Reviewed-by: Steffen Ritter
Reviewed-by: Wouter Wolters
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer

History

#1 Updated by Jigal van Hemert over 8 years ago

  • Status changed from New to Needs Feedback

tslib_fe::clearPageCacheContent_pidList() (in 4.5) uses either the caching framework to clear the cache, or performs a query on the cache_pages table.

The function t3lib_TCEmain::clear_cacheCmd() needs a BE user. This function is not meant to be used in FE context. If you absolutely want to use this function than it's also quite easy to create a BE user.

#2 Updated by Oliver Hader over 8 years ago

  • Target version changed from 4.5.4 to 4.5.6

#3 Updated by Chris topher about 8 years ago

  • Target version changed from 4.5.6 to 4.5.8

#4 Updated by Steffen Gebert almost 8 years ago

  • Subject changed from Error when cache cleared by extension to TCEmain::clear_cacheCmd relies on active BE_USER
  • Status changed from Needs Feedback to Accepted
  • Target version deleted (4.5.8)

As this error also occurs in CLI context, I want to finally fix this. I was against forcing TCEmain to be used in BE only by adding this call all the time. People abuse TYPO3 in all kind of ways, thus also TCEmain in other contexts.

#5 Updated by Gerrit Code Review almost 8 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7633

#6 Updated by Gerrit Code Review almost 8 years ago

Patch set 1 for branch TYPO3_4-6 has been pushed to the review server.
It is available at http://review.typo3.org/7806

#7 Updated by Gerrit Code Review almost 8 years ago

Patch set 1 for branch TYPO3_4-5 has been pushed to the review server.
It is available at http://review.typo3.org/7807

#8 Updated by Steffen Gebert almost 8 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#9 Updated by Ernesto Baschny almost 8 years ago

  • Target version set to 4.5.11

#10 Updated by Riccardo De Contardi about 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF