Project

General

Profile

Bug #22828 » 14638_all.diff

Administrator Admin, 2010-06-07 03:42

View differences:

tests/t3lib/cache/frontend/t3lib_cache_frontend_abstractfrontendtestcase.php (working copy)
*/
public function theConstructorAcceptsValidIdentifiers() {
$mockBackend = $this->getMock('t3lib_cache_backend_AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'findIdentifiersByTags', 'flush', 'flushByTag', 'flushByTags', 'collectGarbage'), array(), '', FALSE);
foreach (array('x', 'someValue', '123fivesixseveneight', 'some&', 'ab_cd%', rawurlencode('package://some/äöü$&% sadf'), str_repeat('x', 250)) as $identifier) {
foreach (array('x', 'someValue', '123fivesixseveneight', 'some&', 'ab_cd%', rawurlencode('resource://some/äöü$&% sadf'), str_repeat('x', 250)) as $identifier) {
$abstractCache = $this->getMock('t3lib_cache_frontend_StringFrontend', array('__construct', 'get', 'set', 'has', 'remove', 'getByTag', 'flush', 'flushByTag', 'collectGarbage'), array($identifier, $mockBackend));
}
}
tests/t3lib/cache/backend/t3lib_cache_backend_apcbackendtestcase.php (working copy)
$backend = $this->setUpBackend();
$data = 'some data' . microtime();
$backend->set('BackendMemcacheTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
$backend->set('BackendMemcacheTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
$backend->set('BackendMemcacheTest3', $data, array('UnitTestTag%test'));
$backend->set('BackendAPCTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
$backend->set('BackendAPCTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
$backend->set('BackendAPCTest3', $data, array('UnitTestTag%test'));
$backend->flushByTag('UnitTestTag%special');
$this->assertTrue($backend->has('BackendMemcacheTest1'), 'BackendMemcacheTest1');
$this->assertFalse($backend->has('BackendMemcacheTest2'), 'BackendMemcacheTest2');
$this->assertTrue($backend->has('BackendMemcacheTest3'), 'BackendMemcacheTest3');
$this->assertTrue($backend->has('BackendAPCTest1'), 'BackendAPCTest1');
$this->assertFalse($backend->has('BackendAPCTest2'), 'BackendAPCTest2');
$this->assertTrue($backend->has('BackendAPCTest3'), 'BackendAPCTest3');
}
/**
......
$backend = $this->setUpBackend();
$data = 'some data' . microtime();
$backend->set('BackendMemcacheTest1', $data);
$backend->set('BackendMemcacheTest2', $data);
$backend->set('BackendMemcacheTest3', $data);
$backend->set('BackendAPCTest1', $data);
$backend->set('BackendAPCTest2', $data);
$backend->set('BackendAPCTest3', $data);
$backend->flush();
$this->assertFalse($backend->has('BackendMemcacheTest1'), 'BackendMemcacheTest1');
$this->assertFalse($backend->has('BackendMemcacheTest2'), 'BackendMemcacheTest2');
$this->assertFalse($backend->has('BackendMemcacheTest3'), 'BackendMemcacheTest3');
$this->assertFalse($backend->has('BackendAPCTest1'), 'BackendAPCTest1');
$this->assertFalse($backend->has('BackendAPCTest2'), 'BackendAPCTest2');
$this->assertFalse($backend->has('BackendAPCTest3'), 'BackendAPCTest3');
}
/**
......
}
/**
* Sets up the memcached backend used for testing
* Sets up the APC backend used for testing
*
* @param array $backendOptions Options for the memcache backend
* @param array $backendOptions Options for the APC backend
* @return t3lib_cache_backend_ApcBackend
* @author Karsten Dambekalns <karsten@typo3.org>
* @author Ingo Renner <ingo@typo3.org>
*/
protected function setUpBackend(array $backendOptions = array()) {
protected function setUpBackend() {
$cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
$backend = new t3lib_cache_backend_ApcBackend();
$backend->setCache($cache);
t3lib/cache/frontend/class.t3lib_cache_frontend_stringfrontend.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_frontend_stringfrontend.php 6536 2009-11-25 14:07:18Z stucki $
*/
class t3lib_cache_frontend_StringFrontend extends t3lib_cache_frontend_AbstractFrontend {
t3lib/cache/frontend/interfaces/interface.t3lib_cache_frontend_frontend.php (working copy)
*
* @author Ingo Renner <ingo@typo3.org>
* @package TYPO3
* @api
* @subpackage t3lib_cache
*/
interface t3lib_cache_frontend_Frontend {
......
/**
* Checks the validity of an entry identifier. Returns true if it's valid.
*
* @param string An identifier to be checked for validity
* @param string $identifier An identifier to be checked for validity
* @return boolean
*/
public function isValidEntryIdentifier($identifier);
......
/**
* Checks the validity of a tag. Returns true if it's valid.
*
* @param string A tag to be checked for validity
* @param string $tag A tag to be checked for validity
* @return boolean
*/
public function isValidTag($tag);
t3lib/cache/frontend/class.t3lib_cache_frontend_abstractfrontend.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_frontend_abstractfrontend.php 5595 2009-06-15 21:40:01Z flyguide $
*/
abstract class t3lib_cache_frontend_AbstractFrontend implements t3lib_cache_frontend_Frontend {
......
/**
* Checks the validity of an entry identifier. Returns true if it's valid.
*
* @param string An identifier to be checked for validity
* @param string $identifier An identifier to be checked for validity
* @return boolean
* @author Christian Jul Jensen <julle@typo3.org>
*/
......
/**
* Checks the validity of a tag. Returns true if it's valid.
*
* @param string An identifier to be checked for validity
* @param string $tag An identifier to be checked for validity
* @return boolean
* @author Robert Lemke <robert@typo3.org>
*/
t3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontend.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_frontend_variablefrontend.php 5595 2009-06-15 21:40:01Z flyguide $
*/
class t3lib_cache_frontend_VariableFrontend extends t3lib_cache_frontend_AbstractFrontend {
t3lib/cache/class.t3lib_cache_factory.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_factory.php 5595 2009-06-15 21:40:01Z flyguide $
*/
class t3lib_cache_Factory implements t3lib_Singleton {
......
*
* This is called by the cache manager itself
*
* @param t3lib_cache_Manager The cache manager
* @param t3lib_cache_Manager $cacheManager The cache manager
* @return void
* @author Robert Lemke <robert@typo3.org>
* @internal
......
* Factory method which creates the specified cache along with the specified kind of backend.
* After creating the cache, it will be registered at the cache manager.
*
* @param string The name / identifier of the cache to create
* @param string Name of the cache frontend
* @param string Name of the cache backend
* @param array (optional) Array of backend options
* @param string $cacheIdentifier The name / identifier of the cache to create
* @param string $cacheName Name of the cache frontend
* @param string $backendName Name of the cache backend
* @param array $backendOptions (optional) Array of backend options
* @return t3lib_cache_frontend_Frontend The created cache frontend
* @author Robert Lemke <robert@typo3.org>
*/
t3lib/cache/class.t3lib_cache_manager.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_manager.php 5595 2009-06-15 21:40:01Z flyguide $
*/
class t3lib_cache_Manager implements t3lib_Singleton {
......
$backend = isset($configuration['backend']) ? $configuration['backend'] : $this->cacheConfigurations['default']['backend'];
$backendOptions = isset($configuration['backendOptions']) ? $configuration['backendOptions'] : $this->cacheConfigurations['default']['backendOptions'];
$cache = $this->cacheFactory->create($identifier, $frontend, $backend, $backendOptions);
$this->cacheFactory->create($identifier, $frontend, $backend, $backendOptions);
}
}
}
t3lib/cache/backend/class.t3lib_cache_backend_memcachedbackend.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_backend_memcachedbackend.php 7823 2010-06-06 13:43:22Z lolli $
*/
class t3lib_cache_backend_MemcachedBackend extends t3lib_cache_backend_AbstractBackend {
......
parent::__construct($options);
$this->memcache = new Memcache();
$this->identifierPrefix = $this->getIdentifierPrefix();
$defaultPort = ini_get('memcache.default_port');
if (!count($this->servers)) {
......
}
/**
* Initializes the identifier prefix when setting the cache.
*
* @param t3lib_cache_frontend_Frontend $cache The frontend for this backend
* @return void
* @author Robert Lemke <robert@typo3.org>
* @author Dmitry Dulepov
*/
public function setCache(t3lib_cache_frontend_Frontend $cache) {
parent::setCache($cache);
$this->identifierPrefix = 'TYPO3_' . md5(PATH_site) . '_';
}
/**
* Saves data in the cache.
*
* @param string An identifier for this specific cache entry
......
);
}
$tags[] = '%MEMCACHEBE%' . $this->cache->getIdentifier();
$tags[] = '%MEMCACHEBE%' . $this->cacheIdentifier;
$expiration = $lifetime !== NULL ? $lifetime : $this->defaultLifetime;
// Memcached consideres values over 2592000 sec (30 days) as UNIX timestamp
......
throw new t3lib_cache_Exception('No cache frontend has been set via setCache() yet.', 1204111376);
}
$this->flushByTag('%MEMCACHEBE%' . $this->cache->getIdentifier());
$this->flushByTag('%MEMCACHEBE%' . $this->cacheIdentifier);
}
/**
......
}
/**
* Returns idenfier prefix. Extensions can override this function to provide
* another identifier prefix if it is necessary for special purposes.
* Default identifier prefix is based on PATH_site only. In most cases
* it is enough because different installations use different paths and page
* IDs in the same installation never repeat.
*
* @return string Identifier prefix, ending with underscore
* @author Dmitry Dulepov
*/
protected function getIdentifierPrefix() {
return 'TYPO3_' . md5(PATH_site) . '_';
}
/**
* Does nothing, as memcached does GC itself
*
* @return void
t3lib/cache/backend/interfaces/interface.t3lib_cache_backend_backend.php (working copy)
*
* @author Ingo Renner <ingo@typo3.org>
* @package TYPO3
* @api
* @subpackage t3lib
*/
interface t3lib_cache_backend_Backend {
......
/**
* Loads data from the cache.
*
* @param string $entryIdentifier: An identifier which describes the cache entry to load
* @param string $entryIdentifier An identifier which describes the cache entry to load
* @return mixed The cache entry's content as a string or FALSE if the cache entry could not be loaded
*/
public function get($entryIdentifier);
t3lib/cache/backend/class.t3lib_cache_backend_nullbackend.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_backend_nullbackend.php 5149 2009-03-08 15:39:26Z flyguide $
*/
class t3lib_cache_backend_NullBackend extends t3lib_cache_backend_AbstractBackend {
t3lib/cache/backend/class.t3lib_cache_backend_filebackend.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_backend_filebackend.php 7816 2010-06-06 11:37:12Z lolli $
*/
class t3lib_cache_backend_FileBackend extends t3lib_cache_backend_AbstractBackend {
......
}
} else {
$delimiter = ':';
if ($cacheDirectory{0} != '/') {
if ($cacheDirectory[0] != '/') {
// relative path to cache directory.
$cacheDirectory = PATH_site . $cacheDirectory;
}
......
if (TYPO3_OS === 'WIN') {
$basedir = str_replace('\\', '/', $basedir);
}
if ($basedir{strlen($basedir) - 1} !== '/') {
if ($basedir[strlen($basedir) - 1] !== '/') {
$basedir .= '/';
}
if (t3lib_div::isFirstPartOfStr($cacheDirectory, $basedir)) {
......
);
}
} else {
if ($cacheDirectory{0} == '/') {
if ($cacheDirectory[0] == '/') {
// absolute path to cache directory.
$documentRoot = '/';
}
......
// after this point all paths have '/' as directory seperator
if ($cacheDirectory{strlen($cacheDirectory) - 1} !== '/') {
if ($cacheDirectory[strlen($cacheDirectory) - 1] !== '/') {
$cacheDirectory .= '/';
}
......
* Creates a tag that is associated with the given cache identifier
*
* @param string $entryIdentifier An identifier for this specific cache entry
* @param string Tag to associate with this cache entry
* @param string $tag Tag to associate with this cache entry
* @return void
* @throws t3lib_cache_Exception if the tag path is not writable or exceeds the maximum allowed path length
* @author Bastian Waidelich <bastian@typo3.org>
......
}
}
$tagPathAndFilename = $absTagPath . $this->cache->getIdentifier()
$tagPathAndFilename = $absTagPath . $this->cacheIdentifier
. self::SEPARATOR . $entryIdentifier;
if (strlen($tagPathAndFilename) > $this->maximumPathLength) {
throw new t3lib_cache_Exception(
......
return FALSE;
}
if (unlink ($pathAndFilename) === FALSE) {
if (unlink($pathAndFilename) === FALSE) {
return FALSE;
}
......
return FALSE;
}
if (unlink ($pathAndFilename) === FALSE) {
if (unlink($pathAndFilename) === FALSE) {
return FALSE;
}
}
......
}
$path = $this->root . $this->cacheDirectory . 'tags/';
$pattern = $path . $tag . '/' . $this->cache->getIdentifier() . self::SEPARATOR . '*';
$pattern = $path . $tag . '/' . $this->cacheIdentifier . self::SEPARATOR . '*';
$filesFound = glob($pattern);
if ($filesFound === FALSE || count($filesFound) === 0) {
......
);
}
$dataPath = $this->root . $this->cacheDirectory . 'data/' . $this->cache->getIdentifier() . '/';
$dataPath = $this->root . $this->cacheDirectory . 'data/' . $this->cacheIdentifier . '/';
$tagsPath = $this->root . $this->cacheDirectory . 'tags/';
t3lib_div::rmdir($dataPath, true);
......
);
}
$pattern = $this->root . $this->cacheDirectory . 'data/' . $this->cache->getIdentifier() . '/*/*/*';
$pattern = $this->root . $this->cacheDirectory . 'data/' . $this->cacheIdentifier . '/*/*/*';
$filesFound = glob($pattern);
foreach ($filesFound as $cacheFilename) {
......
*/
protected function renderCacheEntryPath($identifier) {
$identifierHash = sha1($identifier);
return $this->cacheDirectory . 'data/' . $this->cache->getIdentifier() . '/' . $identifierHash[0] . '/' . $identifierHash[1] . '/';
return $this->cacheDirectory . 'data/' . $this->cacheIdentifier . '/' . $identifierHash[0] . '/' . $identifierHash[1] . '/';
}
/**
......
* Usually only one cache entry should be found - if more than one exist, this
* is due to some error or crash.
*
* @param string The cache entry identifier
* @param string $entryIdentifier The cache entry identifier
* @return mixed The file names (including path) as an array if one or more entries could be found, otherwise FALSE
* @author Robert Lemke <robert@typo3.org>
* @throws t3lib_cache_Exception if no frontend has been set
......
/**
* Tries to find the tag entries for the specified cache entry.
*
* @param string The cache entry identifier to find tag files for
* @param string $entryIdentifier The cache entry identifier to find tag files for
* @return array The file names (including path)
* @author Robert Lemke <robert@typo3.org>
* @throws t3lib_cache_Exception if no frontend has been set
......
}
$path = $this->root . $this->cacheDirectory . 'tags/';
$pattern = $path . '*/' . $this->cache->getIdentifier() . self::SEPARATOR . $entryIdentifier;
return glob($pattern);
$pattern = $path . '*/' . $this->cacheIdentifier . self::SEPARATOR . $entryIdentifier;
$tagFilesFound = glob($pattern);
return ($tagFilesFound ? $tagFilesFound : array());
}
}
t3lib/cache/backend/class.t3lib_cache_backend_transientmemorybackend.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_backend_transientmemorybackend.php 6536 2009-11-25 14:07:18Z stucki $
*/
class t3lib_cache_backend_TransientMemoryBackend extends t3lib_cache_backend_AbstractBackend {
t3lib/cache/backend/class.t3lib_cache_backend_abstractbackend.php (working copy)
* @author Ingo Renner <ingo@typo3.org>
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_backend_abstractbackend.php 5595 2009-06-15 21:40:01Z flyguide $
*/
abstract class t3lib_cache_backend_AbstractBackend implements t3lib_cache_backend_Backend {
......
protected $cache;
/**
* @var string
*/
protected $cacheIdentifier;
/**
* Default lifetime of a cache entry in seconds
*
* @var integer
......
*/
public function setCache(t3lib_cache_frontend_Frontend $cache) {
$this->cache = $cache;
$this->cacheIdentifier = $this->cache->getIdentifier();
}
/**
* Sets the default lifetime for this cache backend
*
* @param integer $defaultLifeTime Default lifetime of this cache backend in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited liftime.
* @param integer $defaultLifetime Default lifetime of this cache backend in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited liftime.
* @return void
* @author Karsten Dambekalns <karsten@typo3.org>
*/
t3lib/cache/backend/class.t3lib_cache_backend_apcbackend.php (working copy)
* Each key is prepended with a prefix. By default prefix consists from two parts
* separated by underscore character and ends in yet another underscore character:
* - "TYPO3"
* - MD5 of script path and filename and SAPI name
* - MD5 of path to TYPO3 and user running TYPO3
* This prefix makes sure that keys from the different installations do not
* conflict.
*
......
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_backend_apcbackend.php 6577 2009-11-29 13:21:28Z ohader $
*/
class t3lib_cache_backend_ApcBackend extends t3lib_cache_backend_AbstractBackend {
......
}
/**
* Initializes the identifier prefix when setting the cache.
*
* @param t3lib_cache_frontend_Frontend $cache The frontend for this backend
* @return void
* @author Robert Lemke <robert@typo3.org>
*/
public function setCache(t3lib_cache_frontend_Frontend $cache) {
parent::setCache($cache);
$processUser = extension_loaded('posix') ? posix_getpwuid(posix_geteuid()) : array('name' => 'default');
$pathHash = t3lib_div::shortMD5(PATH_site . $processUser['name'], 12);
$this->identifierPrefix = 'TYPO3_' . $pathHash;
}
/**
* Saves data in the cache.
*
* @param string $entryIdentifier An identifier for this specific cache entry
......
);
}
$tags[] = '%APCBE%' . $this->cache->getIdentifier();
$tags[] = '%APCBE%' . $this->cacheIdentifier;
$expiration = $lifetime !== NULL ? $lifetime : $this->defaultLifetime;
$success = apc_store($this->identifierPrefix . $entryIdentifier, $data, $expiration);
......
);
}
$this->flushByTag('%APCBE%' . $this->cache->getIdentifier());
$this->flushByTag('%APCBE%' . $this->cacheIdentifier);
}
/**
t3lib/cache/backend/class.t3lib_cache_backend_dbbackend.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_backend_dbbackend.php 7311 2010-04-12 18:12:52Z lolli $
*/
class t3lib_cache_backend_DbBackend extends t3lib_cache_backend_AbstractBackend {
t3lib/cache/class.t3lib_cache_exception.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_exception.php 5165 2009-03-09 18:28:59Z ohader $
*/
class t3lib_cache_Exception extends Exception {
t3lib/cache/exception/class.t3lib_cache_exception_invalidcache.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_exception_invalidcache.php 5165 2009-03-09 18:28:59Z ohader $
*/
class t3lib_cache_exception_InvalidCache extends t3lib_cache_Exception {
t3lib/cache/exception/class.t3lib_cache_exception_duplicateidentifier.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_exception_duplicateidentifier.php 5165 2009-03-09 18:28:59Z ohader $
*/
class t3lib_cache_exception_DuplicateIdentifier extends t3lib_cache_Exception {
t3lib/cache/exception/class.t3lib_cache_exception_invalidbackend.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_exception_invalidbackend.php 5165 2009-03-09 18:28:59Z ohader $
*/
class t3lib_cache_exception_InvalidBackend extends t3lib_cache_Exception {
t3lib/cache/exception/class.t3lib_cache_exception_classalreadyloaded.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_exception_classalreadyloaded.php 5165 2009-03-09 18:28:59Z ohader $
*/
class t3lib_cache_exception_ClassAlreadyLoaded extends t3lib_cache_Exception {
t3lib/cache/exception/class.t3lib_cache_exception_invaliddata.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_exception_invaliddata.php 5165 2009-03-09 18:28:59Z ohader $
*/
class t3lib_cache_exception_InvalidData extends t3lib_cache_Exception {
t3lib/cache/exception/class.t3lib_cache_exception_nosuchcache.php (working copy)
*
* @package TYPO3
* @subpackage t3lib_cache
* @api
* @version $Id: class.t3lib_cache_exception_nosuchcache.php 5165 2009-03-09 18:28:59Z ohader $
*/
class t3lib_cache_exception_NoSuchCache extends t3lib_cache_Exception {
t3lib/cache/last_synched_revision (working copy)
2953
4443
(1-1/2)