74 $this->useIgBinary = extension_loaded(
'igbinary');
90 parent::setCache($cache);
91 if (empty($this->temporaryCacheDirectory)) {
98 $codeOrData = $cache instanceof \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend ?
'Code' :
'Data';
100 if (!is_dir($finalCacheDirectory)) {
103 unset($this->temporaryCacheDirectory);
104 $this->cacheDirectory = $finalCacheDirectory;
105 $this->cacheEntryFileExtension = $cache instanceof \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend ?
'.php' :
'';
107 throw new \TYPO3\CMS\Core\Cache\Exception(
'The length of the temporary cache file path "' . $this->cacheDirectory .
'" exceeds the ' .
'maximum path length of ' . (\
TYPO3\CMS\Core\Utility\
GeneralUtility::getMaximumPathLength() - 23) .
'. Please consider ' .
'setting the temporaryDirectoryBase option to a shorter path.', 1248710426);
133 $documentRoot = PATH_site;
134 if ($open_basedir = ini_get(
'open_basedir')) {
135 if (TYPO3_OS ===
'WIN') {
148 $basedirs = explode($delimiter, $open_basedir);
149 $cacheDirectoryInBaseDir = FALSE;
150 foreach ($basedirs as $basedir) {
151 if (TYPO3_OS ===
'WIN') {
152 $basedir = str_replace(
'\\',
'/', $basedir);
154 if ($basedir[strlen($basedir) - 1] !==
'/') {
158 $documentRoot = $basedir;
160 $cacheDirectoryInBaseDir = TRUE;
164 if (!$cacheDirectoryInBaseDir) {
165 throw new \TYPO3\CMS\Core\Cache\Exception(
'Open_basedir restriction in effect. The directory "' .
$cacheDirectory .
'" is not in an allowed path.');
172 if (TYPO3_OS ===
'WIN') {
173 if (substr(
$cacheDirectory, 0, strlen($documentRoot)) === $documentRoot) {
182 $this->temporaryCacheDirectory = $documentRoot .
$cacheDirectory . $this->cacheIdentifier .
'/';
196 }
catch (\RuntimeException $e) {
197 throw new \TYPO3\CMS\Core\Cache\Exception(
'The directory "' . $finalCacheDirectory .
'" can not be created.', 1303669848, $e);
199 if (!is_writable($finalCacheDirectory)) {
200 throw new \TYPO3\CMS\Core\Cache\Exception(
'The directory "' . $finalCacheDirectory .
'" is not writable.', 1203965200);
227 public function set($entryIdentifier, $data, array $tags = array(), $lifetime = NULL) {
228 if (!is_string($data)) {
229 throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException(
'The specified data is of type "' . gettype($data) .
'" but a string is expected.', 1334756734);
231 if ($entryIdentifier !== basename($entryIdentifier)) {
232 throw new \InvalidArgumentException(
'The specified entry identifier must not contain a path segment.', 1334756735);
234 if ($entryIdentifier ===
'') {
235 throw new \InvalidArgumentException(
'The specified entry identifier must not be empty.', 1334756736);
237 $temporaryCacheEntryPathAndFilename = $this->cacheDirectory . uniqid(
'', TRUE) .
'.temp';
238 $result = file_put_contents($temporaryCacheEntryPathAndFilename, $data);
241 throw new \TYPO3\CMS\Core\Cache\Exception(
'The temporary cache file "' . $temporaryCacheEntryPathAndFilename .
'" could not be written.', 1334756737);
244 rename($temporaryCacheEntryPathAndFilename, $cacheEntryPathAndFilename);
245 if ($this->cacheEntryFileExtension ===
'.php') {
258 public function get($entryIdentifier) {
259 if ($entryIdentifier !== basename($entryIdentifier)) {
260 throw new \InvalidArgumentException(
'The specified entry identifier must not contain a path segment.', 1334756877);
263 if (!file_exists($pathAndFilename)) {
266 return file_get_contents($pathAndFilename);
277 public function has($entryIdentifier) {
278 if ($entryIdentifier !== basename($entryIdentifier)) {
279 throw new \InvalidArgumentException(
'The specified entry identifier must not contain a path segment.', 1334756878);
281 return file_exists($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension);
293 public function remove($entryIdentifier) {
294 if ($entryIdentifier !== basename($entryIdentifier)) {
295 throw new \InvalidArgumentException(
'The specified entry identifier must not contain a path segment.', 1334756960);
297 if ($entryIdentifier ===
'') {
298 throw new \InvalidArgumentException(
'The specified entry identifier must not be empty.', 1334756961);
301 unlink($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension);
327 return file_exists($cacheEntryPathAndFilename) === FALSE;
348 return file_exists($pathAndFilename) ? array($pathAndFilename) : FALSE;
361 if ($entryIdentifier !== basename($entryIdentifier)) {
362 throw new \InvalidArgumentException(
'The specified entry identifier must not contain a path segment.', 1282073037);
364 return file_exists($pathAndFilename) ? require_once $pathAndFilename : FALSE;
static mkdir_deep($directory, $deepDirectory='')
createFinalCacheDirectory($finalCacheDirectory)
findCacheFilesByIdentifier($entryIdentifier)
static isFirstPartOfStr($str, $partStr)
requireOnce($entryIdentifier)
setCacheDirectory($cacheDirectory)
isCacheFileExpired($cacheEntryPathAndFilename)
static clearAllActive($fileAbsPath=NULL)
static fixPermissions($path, $recursive=FALSE)
static getMaximumPathLength()
static flushDirectory($directory, $keepOriginalDirectory=FALSE, $flushOpcodeCache=FALSE)
setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.