Bug #24400 ยป 16824_01.diff
tests/t3lib/cache/frontend/t3lib_cache_frontend_variablefrontendTest.php (working copy) | ||
---|---|---|
/**
|
||
* @test
|
||
* @author Robert Lemke <robert@typo3.org>
|
||
*/
|
||
public function setUsesIgBinarySerializeIfAvailable() {
|
||
if (!extension_loaded('igbinary')) {
|
||
$this->markTestSkipped('Cannot test igbinary support, because igbinary is not installed.');
|
||
}
|
||
$theString = 'Just some value';
|
||
$backend = $this->getMock('t3lib_cache_backend_AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'findIdentifiersByTags', 'flush', 'flushByTag', 'flushByTags', 'collectGarbage'), array(), '', FALSE);
|
||
$backend->expects($this->once())->method('set')->with($this->equalTo('VariableCacheTest'), $this->equalTo(igbinary_serialize($theString)));
|
||
$cache = new t3lib_cache_frontend_VariableFrontend('VariableFrontend', $backend);
|
||
$cache->set('VariableCacheTest', $theString);
|
||
}
|
||
/**
|
||
* @test
|
||
* @author Robert Lemke <robert@typo3.org>
|
||
* @author Ingo Renner <ingo@typo3.org>
|
||
*/
|
||
public function getFetchesStringValueFromBackend() {
|
||
... | ... | |
/**
|
||
* @test
|
||
* @author Robert Lemke <robert@typo3.org>
|
||
*/
|
||
public function getUsesIgBinaryIfAvailable() {
|
||
if (!extension_loaded('igbinary')) {
|
||
$this->markTestSkipped('Cannot test igbinary support, because igbinary is not installed.');
|
||
}
|
||
$theArray = array('Just some value', 'and another one.');
|
||
$backend = $this->getMock('t3lib_cache_backend_AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'findIdentifiersByTags', 'flush', 'flushByTag', 'flushByTags', 'collectGarbage'), array(), '', FALSE);
|
||
$backend->expects($this->once())->method('get')->will($this->returnValue(igbinary_serialize($theArray)));
|
||
$cache = new t3lib_cache_frontend_VariableFrontend('VariableFrontend', $backend);
|
||
$this->assertEquals($theArray, $cache->get('VariableCacheTest'), 'The returned value was not the expected unserialized array.');
|
||
}
|
||
/**
|
||
* @test
|
||
* @author Robert Lemke <robert@typo3.org>
|
||
* @author Ingo Renner <ingo@typo3.org>
|
||
*/
|
||
public function hasReturnsResultFromBackend() {
|
||
... | ... | |
$this->assertEquals($entries, $cache->getByTag($tag), 'Did not receive the expected entries');
|
||
}
|
||
/**
|
||
* @test
|
||
* @author Robert Lemke <robert@typo3.org>
|
||
*/
|
||
public function getByTagUsesIgBinaryIfAvailable() {
|
||
if (!extension_loaded('igbinary')) {
|
||
$this->markTestSkipped('Cannot test igbinary support, because igbinary is not installed.');
|
||
}
|
||
$tag = 'sometag';
|
||
$identifiers = array('one', 'two');
|
||
$entries = array('one value', 'two value');
|
||
$backend = $this->getMock('t3lib_cache_backend_AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'findIdentifiersByTags', 'flush', 'flushByTag', 'flushByTags', 'collectGarbage'), array(), '', FALSE);
|
||
$backend->expects($this->once())->method('findIdentifiersByTag')->with($this->equalTo($tag))->will($this->returnValue($identifiers));
|
||
$backend->expects($this->exactly(2))->method('get')->will($this->onConsecutiveCalls(igbinary_serialize('one value'), igbinary_serialize('two value')));
|
||
$cache = new t3lib_cache_frontend_VariableFrontend('VariableFrontend', $backend);
|
||
$this->assertEquals($entries, $cache->getByTag($tag), 'Did not receive the expected entries');
|
||
}
|
||
}
|
||
?>
|
||
?>
|
tests/t3lib/cache/frontend/t3lib_cache_frontend_phpfrontendTest.php (working copy) | ||
---|---|---|
*/
|
||
public function setPassesPhpSourceCodeTagsAndLifetimeToBackend() {
|
||
$originalSourceCode = 'return "hello world!";';
|
||
$modifiedSourceCode = '<?php' . chr(10) . $originalSourceCode . chr(10) . '__halt_compiler();';
|
||
$modifiedSourceCode = '<?php' . chr(10) . $originalSourceCode . chr(10) . '#';
|
||
$mockBackend = $this->getMock('t3lib_cache_backend_PhpCapableBackend', array(), array(), '', FALSE);
|
||
$mockBackend->expects($this->once())->method('set')->with('Foo-Bar', $modifiedSourceCode, array('tags'), 1234);
|
tests/t3lib/cache/backend/t3lib_cache_backend_pdobackendTest.php (working copy) | ||
---|---|---|
protected $backupGlobalVariables;
|
||
/**
|
||
* @var string
|
||
*/
|
||
protected $fixtureFolder;
|
||
/**
|
||
* @var string
|
||
*/
|
||
protected $fixtureDB;
|
||
/**
|
||
* Sets up this testcase
|
||
*
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
... | ... | |
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
*/
|
||
protected function setUpBackend() {
|
||
$this->fixtureFolder = sys_get_temp_dir() . '/' . 'typo3pdobackendtest/';
|
||
t3lib_div::mkdir_deep(sys_get_temp_dir() . '/', 'typo3pdobackendtest/');
|
||
$this->fixtureDB = uniqid('Cache') . '.db';
|
||
$pdoHelper = t3lib_div::makeInstance('t3lib_PdoHelper', 'sqlite:' . $this->fixtureFolder . $this->fixtureDB, '', '');
|
||
$pdoHelper->importSql(PATH_t3lib . 'cache/backend/resources/ddl.sql');
|
||
$mockCache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
|
||
$mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('TestCache'));
|
||
$backendOptions = array(
|
||
'dataSourceName' => 'sqlite:' . $this->fixtureFolder . $this->fixtureDB,
|
||
'dataSourceName' => 'sqlite::memory:',
|
||
'username' => '',
|
||
'password' => '',
|
||
);
|
||
... | ... | |
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
*/
|
||
public function tearDown() {
|
||
if ($this->fixtureDB) {
|
||
t3lib_div::rmdir($this->fixtureFolder, TRUE);
|
||
}
|
||
foreach ($this->backupGlobalVariables as $key => $data) {
|
||
$GLOBALS[$key] = $data;
|
||
}
|
||
}
|
||
}
|
||
?>
|
||
?>
|
tests/t3lib/cache/backend/t3lib_cache_backend_apcbackendTest.php (working copy) | ||
---|---|---|
if (!extension_loaded('apc')) {
|
||
$this->markTestSkipped('APC extension was not available');
|
||
}
|
||
if (ini_get('apc.slam_defense') == 1) {
|
||
$this->markTestSkipped('This testcase can only be executed with apc.slam_defense = Off');
|
||
}
|
||
}
|
||
/**
|
||
... | ... | |
public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
|
||
$backend = new t3lib_cache_backend_ApcBackend();
|
||
$data = 'Some data';
|
||
$identifier = 'MyIdentifier';
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data);
|
||
}
|
||
... | ... | |
public function itIsPossibleToSetAndCheckExistenceInCache() {
|
||
$backend = $this->setUpBackend();
|
||
$data = 'Some data';
|
||
$identifier = 'MyIdentifier';
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data);
|
||
$inCache = $backend->has($identifier);
|
||
$this->assertTrue($inCache, 'APC backend failed to set and check entry');
|
||
... | ... | |
public function itIsPossibleToSetAndGetEntry() {
|
||
$backend = $this->setUpBackend();
|
||
$data = 'Some data';
|
||
$identifier = 'MyIdentifier';
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data);
|
||
$fetchedData = $backend->get($identifier);
|
||
$this->assertEquals($data, $fetchedData, 'APC backend failed to set and retrieve data');
|
||
... | ... | |
public function itIsPossibleToRemoveEntryFromCache() {
|
||
$backend = $this->setUpBackend();
|
||
$data = 'Some data';
|
||
$identifier = 'MyIdentifier';
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data);
|
||
$backend->remove($identifier);
|
||
$inCache = $backend->has($identifier);
|
||
... | ... | |
public function itIsPossibleToOverwriteAnEntryInTheCache() {
|
||
$backend = $this->setUpBackend();
|
||
$data = 'Some data';
|
||
$identifier = 'MyIdentifier';
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data);
|
||
$otherData = 'some other data';
|
||
$backend->set($identifier, $otherData);
|
||
... | ... | |
$backend = $this->setUpBackend();
|
||
$data = 'Some data';
|
||
$entryIdentifier = 'MyIdentifier';
|
||
$backend->set($entryIdentifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
|
||
$retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag1');
|
||
$this->assertEquals($entryIdentifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
|
||
$this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
|
||
$retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
|
||
$this->assertEquals($entryIdentifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
|
||
$this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
|
||
}
|
||
/**
|
||
... | ... | |
$backend = $this->setUpBackend();
|
||
$data = 'Some data';
|
||
$entryIdentifier = 'MyIdentifier';
|
||
$backend->set($entryIdentifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
|
||
$backend->set($entryIdentifier, $data, array('UnitTestTag%tag3'));
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
|
||
$backend->set($identifier, $data, array('UnitTestTag%tag3'));
|
||
$retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
|
||
$this->assertEquals(array(), $retrieved, 'Found entry which should no longer exist.');
|
||
... | ... | |
*/
|
||
public function hasReturnsFalseIfTheEntryDoesntExist() {
|
||
$backend = $this->setUpBackend();
|
||
$identifier = 'NonExistingIdentifier';
|
||
$identifier = uniqid('NonExistingIdentifier');
|
||
$inCache = $backend->has($identifier);
|
||
$this->assertFalse($inCache,'"has" did not return false when checking on non existing identifier');
|
||
}
|
||
... | ... | |
*/
|
||
public function removeReturnsFalseIfTheEntryDoesntExist() {
|
||
$backend = $this->setUpBackend();
|
||
$identifier = 'NonExistingIdentifier';
|
||
$identifier = uniqid('NonExistingIdentifier');
|
||
$inCache = $backend->remove($identifier);
|
||
$this->assertFalse($inCache,'"remove" did not return false when checking on non existing identifier');
|
||
}
|
||
... | ... | |
$backend = $this->setUpBackend();
|
||
$data = str_repeat('abcde', 1024 * 1024);
|
||
$backend->set('tooLargeData', $data);
|
||
$identifier = uniqid('tooLargeData');
|
||
$backend->set($identifier, $data);
|
||
$this->assertTrue($backend->has('tooLargeData'));
|
||
$this->assertEquals($backend->get('tooLargeData'), $data);
|
||
$this->assertTrue($backend->has($identifier));
|
||
$this->assertEquals($backend->get($identifier), $data);
|
||
}
|
||
/**
|
tests/t3lib/cache/backend/t3lib_cache_backend_memcachedbackendTest.php (working copy) | ||
---|---|---|
$backend = new t3lib_cache_backend_MemcachedBackend($backendOptions);
|
||
$data = 'Some data';
|
||
$identifier = 'MyIdentifier';
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data);
|
||
}
|
||
... | ... | |
public function setThrowsExceptionIfConfiguredServersAreUnreachable() {
|
||
$backend = $this->setUpBackend(array('servers' => array('julle.did.this:1234')));
|
||
$data = 'Somedata';
|
||
$identifier = 'MyIdentifier';
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data);
|
||
}
|
||
... | ... | |
public function itIsPossibleToSetAndCheckExistenceInCache() {
|
||
$backend = $this->setUpBackend();
|
||
$data = 'Some data';
|
||
$identifier = 'MyIdentifier';
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data);
|
||
$inCache = $backend->has($identifier);
|
||
$this->assertTrue($inCache, 'Memcache failed to set and check entry');
|
||
... | ... | |
public function itIsPossibleToSetAndGetEntry() {
|
||
$backend = $this->setUpBackend();
|
||
$data = 'Some data';
|
||
$identifier = 'MyIdentifier';
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data);
|
||
$fetchedData = $backend->get($identifier);
|
||
$this->assertEquals($data, $fetchedData, 'Memcache failed to set and retrieve data');
|
||
... | ... | |
public function itIsPossibleToRemoveEntryFromCache() {
|
||
$backend = $this->setUpBackend();
|
||
$data = 'Some data';
|
||
$identifier = 'MyIdentifier';
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data);
|
||
$backend->remove($identifier);
|
||
$inCache = $backend->has($identifier);
|
||
... | ... | |
public function itIsPossibleToOverwriteAnEntryInTheCache() {
|
||
$backend = $this->setUpBackend();
|
||
$data = 'Some data';
|
||
$identifier = 'MyIdentifier';
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data);
|
||
$otherData = 'some other data';
|
||
$backend->set($identifier, $otherData);
|
||
... | ... | |
$backend = $this->setUpBackend();
|
||
$data = 'Some data';
|
||
$entryIdentifier = 'MyIdentifier';
|
||
$backend->set($entryIdentifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
|
||
$retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag1');
|
||
$this->assertEquals($entryIdentifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
|
||
$this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
|
||
$retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
|
||
$this->assertEquals($entryIdentifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
|
||
$this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
|
||
}
|
||
/**
|
||
... | ... | |
$backend = $this->setUpBackend();
|
||
$data = 'Some data';
|
||
$entryIdentifier = 'MyIdentifier';
|
||
$backend->set($entryIdentifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
|
||
$backend->set($entryIdentifier, $data, array('UnitTestTag%tag3'));
|
||
$identifier = uniqid('MyIdentifier');
|
||
$backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
|
||
$backend->set($identifier, $data, array('UnitTestTag%tag3'));
|
||
$retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
|
||
$retrieved = $backend->findIdentifiersByTag('UnitTestTag%tagX');
|
||
$this->assertEquals(array(), $retrieved, 'Found entry which should no longer exist.');
|
||
}
|
||
... | ... | |
*/
|
||
public function hasReturnsFalseIfTheEntryDoesntExist() {
|
||
$backend = $this->setUpBackend();
|
||
$identifier = 'NonExistingIdentifier';
|
||
$identifier = uniqid('NonExistingIdentifier');
|
||
$inCache = $backend->has($identifier);
|
||
$this->assertFalse($inCache,'"has" did not return false when checking on non existing identifier');
|
||
}
|
||
... | ... | |
*/
|
||
public function removeReturnsFalseIfTheEntryDoesntExist() {
|
||
$backend = $this->setUpBackend();
|
||
$identifier = 'NonExistingIdentifier';
|
||
$identifier = uniqid('NonExistingIdentifier');
|
||
$inCache = $backend->remove($identifier);
|
||
$this->assertFalse($inCache,'"remove" did not return false when checking on non existing identifier');
|
||
}
|
tests/t3lib/cache/backend/t3lib_cache_backend_redisbackendTest.php (working copy) | ||
---|---|---|
}
|
||
try {
|
||
if (!fsockopen('127.0.0.1', 6379)) {
|
||
if (!@fsockopen('127.0.0.1', 6379)) {
|
||
$this->markTestSkipped('redis server not reachable');
|
||
}
|
||
} catch (Exception $e) {
|
tests/t3lib/cache/last_synched_revision (revision 0) | ||
---|---|---|
8d61bb9e22fcab1bedcd7ba72f8d0de9f6efc521
|
t3lib/cache/frontend/class.t3lib_cache_frontend_phpfrontend.php (working copy) | ||
---|---|---|
);
|
||
}
|
||
}
|
||
$sourceCode = '<?php' . chr(10) . $sourceCode . chr(10) . '__halt_compiler();';
|
||
$sourceCode = '<?php' . chr(10) . $sourceCode . chr(10) . '#';
|
||
$this->backend->set($entryIdentifier, $sourceCode, $tags, $lifetime);
|
||
}
|
||
t3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontend.php (working copy) | ||
---|---|---|
class t3lib_cache_frontend_VariableFrontend extends t3lib_cache_frontend_AbstractFrontend {
|
||
/**
|
||
* If the extension "igbinary" is installed, use it for increased performance
|
||
*
|
||
* @var boolean
|
||
*/
|
||
protected $useIgBinary = FALSE;
|
||
/**
|
||
* Constructs the cache
|
||
*
|
||
* @param string A identifier which describes this cache
|
||
* @param t3lib_cache_backend_Backend Backend to be used for this cache
|
||
* @author Robert Lemke <robert@typo3.org>
|
||
* @throws InvalidArgumentException if the identifier doesn't match PATTERN_ENTRYIDENTIFIER
|
||
* @internal
|
||
*/
|
||
public function __construct($identifier, t3lib_cache_backend_Backend $backend) {
|
||
parent::__construct($identifier, $backend);
|
||
$this->initializeObject();
|
||
}
|
||
/**
|
||
* Initializes this cache frontend
|
||
*
|
||
* @return void
|
||
* @author Robert Lemke <robert@typo3.org>
|
||
*/
|
||
protected function initializeObject() {
|
||
$this->useIgBinary = extension_loaded('igbinary');
|
||
}
|
||
/**
|
||
* Saves the value of a PHP variable in the cache. Note that the variable
|
||
* will be serialized if necessary.
|
||
*
|
||
... | ... | |
}
|
||
}
|
||
$this->backend->set($entryIdentifier, serialize($variable), $tags, $lifetime);
|
||
if ($this->useIgBinary === TRUE) {
|
||
$this->backend->set($entryIdentifier, igbinary_serialize($variable), $tags, $lifetime);
|
||
} else {
|
||
$this->backend->set($entryIdentifier, serialize($variable), $tags, $lifetime);
|
||
}
|
||
}
|
||
/**
|
||
... | ... | |
);
|
||
}
|
||
return unserialize($this->backend->get($entryIdentifier));
|
||
return ($this->useIgBinary === TRUE) ? igbinary_unserialize($this->backend->get($entryIdentifier)) : unserialize($this->backend->get($entryIdentifier));
|
||
}
|
||
/**
|
||
... | ... | |
$identifiers = $this->backend->findIdentifiersByTag($tag);
|
||
foreach ($identifiers as $identifier) {
|
||
$entries[] = unserialize($this->backend->get($identifier));
|
||
$entries[] = ($this->useIgBinary === TRUE) ? igbinary_unserialize($this->backend->get($identifier)) : unserialize($this->backend->get($identifier));
|
||
}
|
||
return $entries;
|
t3lib/cache/backend/class.t3lib_cache_backend_memcachedbackend.php (working copy) | ||
---|---|---|
/**
|
||
* Constructs this backend
|
||
*
|
||
* @param mixed $options Configuration options - depends on the actual backend
|
||
* @param array $options Configuration options - depends on the actual backend
|
||
* @author Robert Lemke <robert@typo3.org>
|
||
*/
|
||
public function __construct($options = array()) {
|
||
public function __construct(array $options = array()) {
|
||
if (!extension_loaded('memcache')) {
|
||
throw new t3lib_cache_Exception(
|
||
'The PHP extension "memcached" must be installed and loaded in ' .
|
t3lib/cache/backend/class.t3lib_cache_backend_redisbackend.php (working copy) | ||
---|---|---|
/**
|
||
* Construct this backend
|
||
*
|
||
* @param array Configuration options
|
||
* @param array $options Configuration options
|
||
* @throws t3lib_cache_Exception if php redis module is not loaded
|
||
* @author Christopher Hlubek <hlubek@networkteam.com>
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
... | ... | |
/**
|
||
* Initializes the redis backend
|
||
*
|
||
* @param array Configuration options
|
||
* @return void
|
||
* @throws t3lib_cache_Exception if access to redis with password is denied or if database selection fails
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
... | ... | |
/**
|
||
* Setter for server hostname
|
||
*
|
||
* @param string Hostname
|
||
* @param string $hostname Hostname
|
||
* @return void
|
||
* @author Christopher Hlubek <hlubek@networkteam.com>
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
... | ... | |
/**
|
||
* Setter for server port
|
||
*
|
||
* @param integer Port
|
||
* @param integer $port Port
|
||
* @return void
|
||
* @author Christopher Hlubek <hlubek@networkteam.com>
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
... | ... | |
/**
|
||
* Setter for database number
|
||
*
|
||
* @param integer Database
|
||
* @param integer $database Database
|
||
* @return void
|
||
* @throws InvalidArgumentException if database number is not valid
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
... | ... | |
/**
|
||
* Setter for authentication password
|
||
*
|
||
* @param string Password
|
||
* @param string $password Password
|
||
* @return void
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
* @api
|
||
... | ... | |
/**
|
||
* Enable data compression
|
||
*
|
||
* @param boolean TRUE to enable compression
|
||
* @param boolean $compression TRUE to enable compression
|
||
* @return void
|
||
* @throws InvalidArgumentException if compression parameter is not of type boolean
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
... | ... | |
* If compression is enabled and this is not set,
|
||
* gzcompress default level will be used.
|
||
*
|
||
* @param integer -1 to 9: Compression level
|
||
* @param integer $compressionLevel -1 to 9: Compression level
|
||
* @return void
|
||
* @throws InvalidArgumentException if compressionLevel parameter is not within allowed bounds
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
... | ... | |
* Scales O(1) with number of cache entries
|
||
* Scales O(n) with number of tags
|
||
*
|
||
* @param string Identifier for this specific cache entry
|
||
* @param string Data to be stored
|
||
* @param array Tags to associate with this cache entry
|
||
* @param integer Lifetime of this cache entry in seconds. If NULL is specified, default lifetime is used. "0" means unlimited lifetime.
|
||
* @param string $entryIdentifier Identifier for this specific cache entry
|
||
* @param string $data Data to be stored
|
||
* @param array $tags Tags to associate with this cache entry
|
||
* @param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, default lifetime is used. "0" means unlimited lifetime.
|
||
* @return void
|
||
* @throws InvalidArgumentException if identifier is not valid
|
||
* @throws t3lib_cache_Exception_InvalidData if data is not a string
|
||
... | ... | |
*
|
||
* Scales O(1) with number of cache entries
|
||
*
|
||
* @param string 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
|
||
* @throws InvalidArgumentException if identifier is not a string
|
||
* @author Christopher Hlubek <hlubek@networkteam.com>
|
||
... | ... | |
*
|
||
* Scales O(1) with number of cache entries
|
||
*
|
||
* @param string Identifier specifying the cache entry
|
||
* @param string $entryIdentifier Identifier specifying the cache entry
|
||
* @return boolean TRUE if such an entry exists, FALSE if not
|
||
* @throws InvalidArgumentException if identifier is not a string
|
||
* @author Christopher Hlubek <hlubek@networkteam.com>
|
||
... | ... | |
* Scales O(1) with number of cache entries
|
||
* Scales O(n) with number of tags
|
||
*
|
||
* @param string Specifies the cache entry to remove
|
||
* @param string $entryIdentifier Specifies the cache entry to remove
|
||
* @return boolean TRUE if (at least) an entry could be removed or FALSE if no entry was found
|
||
* @throws InvalidArgumentException if identifier is not a string
|
||
* @author Christopher Hlubek <hlubek@networkteam.com>
|
||
... | ... | |
* Scales O(1) with number of cache entries
|
||
* Scales O(n) with number of tag entries
|
||
*
|
||
* @param string The tag to search for
|
||
* @param string $tag The tag to search for
|
||
* @return array An array of entries with all matching entries. An empty array if no entries matched
|
||
* @throws InvalidArgumentException if tag is not a string
|
||
* @author Christopher Hlubek <hlubek@networkteam.com>
|
||
... | ... | |
*
|
||
* Scales O(n) with number of tags
|
||
*
|
||
* @param array Array of tags to search for
|
||
* @param array $tags Array of tags to search for
|
||
* @return array An array with identifiers of all matching entries. An empty array if no entries matched
|
||
* @author Christopher Hlubek <hlubek@networkteam.com>
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
... | ... | |
* Scales O(1) with number of cache entries
|
||
* Scales O(n^2) with number of tag entries
|
||
*
|
||
* @param string Tag the entries must have
|
||
* @param string $tags Tag the entries must have
|
||
* @return void
|
||
* @throws InvalidArgumentException if identifier is not a string
|
||
* @author Christopher Hlubek <hlubek@networkteam.com>
|
||
... | ... | |
* Scales O(1) with number of cache entries
|
||
* Scales O(n^2) with number of tags
|
||
*
|
||
* @param array Tags the entries must have
|
||
* @param array $tags Tags the entries must have
|
||
* @return void
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
* @api
|
||
... | ... | |
* Scales O(1) with number of cache entries
|
||
* Scales O(n^2) with number of tags
|
||
*
|
||
* @param array List of identifiers to remove
|
||
* @param array List of tags to be handled
|
||
* @param array $identifiers List of identifiers to remove
|
||
* @param array $tags List of tags to be handled
|
||
* @return void
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
* @author Christopher Hlubek <hlubek@networkteam.com>
|
t3lib/cache/backend/class.t3lib_cache_backend_filebackend.php (working copy) | ||
---|---|---|
/**
|
||
* Constructs this backend
|
||
*
|
||
* @param mixed Configuration options - depends on the actual backend
|
||
* @param array $options Configuration options - depends on the actual backend
|
||
*/
|
||
public function __construct(array $options = array()) {
|
||
parent::__construct($options);
|
t3lib/cache/backend/class.t3lib_cache_backend_pdobackend.php (working copy) | ||
---|---|---|
* @version $Id$
|
||
*/
|
||
class t3lib_cache_backend_PdoBackend extends t3lib_cache_backend_AbstractBackend {
|
||
/**
|
||
* @var string
|
||
*/
|
||
... | ... | |
/**
|
||
* Constructs this backend
|
||
*
|
||
* @param mixed $options Configuration options - depends on the actual backend
|
||
* @param array $options Configuration options - depends on the actual backend
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
*/
|
||
public function __construct(array $options = array()) {
|
||
... | ... | |
$this->pdoDriver = $splitdsn[0];
|
||
if ($this->pdoDriver === 'sqlite' && !file_exists($splitdsn[1])) {
|
||
$this->databaseHandle = t3lib_div::makeInstance('PDO', $this->dataSourceName, $this->username, $this->password);
|
||
$this->createCacheTables();
|
||
} else {
|
||
$this->databaseHandle = t3lib_div::makeInstance('PDO', $this->dataSourceName, $this->username, $this->password);
|
||
}
|
||
$this->databaseHandle = t3lib_div::makeInstance('PDO', $this->dataSourceName, $this->username, $this->password);
|
||
$this->databaseHandle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||
if ($this->pdoDriver === 'mysql') {
|
||
$this->databaseHandle->exec('SET SESSION sql_mode=\'ANSI\';');
|
||
}
|
||
} catch (PDOException $e) {
|
||
# $this->createCacheTables();
|
||
}
|
||
}
|
||
... | ... | |
*/
|
||
protected function createCacheTables() {
|
||
try {
|
||
$pdoHelper = t3lib_div::makeInstance('t3lib_PdoHelper', $this->dataSourceName, $this->username, $this->password);
|
||
$pdoHelper->importSql(PATH_t3lib . 'cache/backend/resources/ddl.sql');
|
||
t3lib_PdoHelper::importSql($this->databaseHandle, $this->pdoDriver, PATH_t3lib . 'cache/backend/resources/ddl.sql');
|
||
} catch (PDOException $e) {
|
||
throw new RuntimeException(
|
||
'Could not create cache tables with DSN "' . $this->dataSourceName . '". PDO error: ' . $e->getMessage(),
|
t3lib/cache/backend/class.t3lib_cache_backend_abstractbackend.php (working copy) | ||
---|---|---|
/**
|
||
* Constructs this backend
|
||
*
|
||
* @param mixed Configuration options - depends on the actual backend
|
||
* @param array $options Configuration options - depends on the actual backend
|
||
* @author Robert Lemke <robert@typo3.org>
|
||
*/
|
||
public function __construct(array $options = array()) {
|
t3lib/cache/backend/class.t3lib_cache_backend_apcbackend.php (working copy) | ||
---|---|---|
/**
|
||
* Constructs this backend
|
||
*
|
||
* @param mixed $options Configuration options - unused here
|
||
* @param array $options Configuration options - unused here
|
||
* @author Robert Lemke <robert@typo3.org>
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
*/
|
||
public function __construct($options = array()) {
|
||
public function __construct(array $options = array()) {
|
||
if (!extension_loaded('apc')) {
|
||
throw new t3lib_cache_Exception(
|
||
'The PHP extension "apc" must be installed and loaded in order to use the APC backend.',
|
t3lib/cache/backend/class.t3lib_cache_backend_dbbackend.php (working copy) | ||
---|---|---|
/**
|
||
* Constructs this backend
|
||
*
|
||
* @param mixed Configuration options - depends on the actual backend
|
||
* @param array $options Configuration options - depends on the actual backend
|
||
*/
|
||
public function __construct(array $options = array()) {
|
||
parent::__construct($options);
|
t3lib/cache/last_synched_revision (working copy) | ||
---|---|---|
4443
|
||
d26e82f4de95e96f2e14b6531c8c24a2b05ccfe9
|
t3lib/class.t3lib_pdohelper.php (working copy) | ||
---|---|---|
* @package TYPO3
|
||
* @subpackage t3lib
|
||
* @version $Id$
|
||
* @scope prototype
|
||
*/
|
||
class t3lib_PdoHelper {
|
||
/**
|
||
* @var PDO
|
||
*/
|
||
protected $databaseHandle;
|
||
/**
|
||
* @var string
|
||
*/
|
||
protected $pdoDriver;
|
||
/**
|
||
* Construct the helper instance and set up PDO connection.
|
||
*
|
||
* @param string $dataSourceName
|
||
* @param string $user
|
||
* @param string $password
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
*/
|
||
public function __construct($dataSourceName, $user, $password) {
|
||
$splitdsn = explode(':', $dataSourceName, 2);
|
||
$this->pdoDriver = $splitdsn[0];
|
||
$this->databaseHandle = t3lib_div::makeInstance('PDO', $dataSourceName, $user, $password);
|
||
$this->databaseHandle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||
if ($this->pdoDriver === 'mysql') {
|
||
$this->databaseHandle->exec('SET SESSION sql_mode=\'ANSI_QUOTES\';');
|
||
}
|
||
}
|
||
/**
|
||
* Pumps the SQL into the database. Use for DDL only.
|
||
*
|
||
* Important: key definitions with length specifiers (needed for MySQL) must
|
||
* be given as "field"(xyz) - no space between double quote and parenthesis -
|
||
* so they can be removed automatically.
|
||
*
|
||
* @param PDO $databaseHandle
|
||
* @param string $pdoDriver
|
||
* @param string $pathAndFilename
|
||
* @return void
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
*/
|
||
public function importSql($pathAndFilename) {
|
||
static public function importSql(PDO $databaseHandle, $pdoDriver, $pathAndFilename) {
|
||
$sql = file($pathAndFilename, FILE_IGNORE_NEW_LINES & FILE_SKIP_EMPTY_LINES);
|
||
// Remove MySQL style key length delimiters (yuck!) if we are not setting up a MySQL db
|
||
if ($this->pdoDriver !== 'mysql') {
|
||
if ($pdoDriver !== 'mysql') {
|
||
$sql = preg_replace('/"\([0-9]+\)/', '"', $sql);
|
||
}
|
||
... | ... | |
foreach ($sql as $line) {
|
||
$statement .= ' ' . trim($line);
|
||
if (substr($statement, -1) === ';') {
|
||
$this->databaseHandle->query($statement);
|
||
$databaseHandle->exec($statement);
|
||
$statement = '';
|
||
}
|
||
}
|