diff --git a/typo3/sysext/core/Classes/Cache/Backend/AbstractBackend.php b/typo3/sysext/core/Classes/Cache/Backend/AbstractBackend.php index 9e20e7abd2ed541281b119883b515e7622daee22..641229512d3d8768b26859aa5b7ccc707f9f8876 100644 --- a/typo3/sysext/core/Classes/Cache/Backend/AbstractBackend.php +++ b/typo3/sysext/core/Classes/Cache/Backend/AbstractBackend.php @@ -122,6 +122,8 @@ abstract class AbstractBackend implements BackendInterface, LoggerAwareInterface */ public function flushByTags(array $tags) { + // todo: flushByTag is not necessarily implemented since it's neither defined of the interface, nor defined in + // this class as abstract method. Therefore this potentially triggers a fatal error during runtime. array_walk($tags, [$this, 'flushByTag']); } diff --git a/typo3/sysext/core/Classes/Cache/Backend/FileBackend.php b/typo3/sysext/core/Classes/Cache/Backend/FileBackend.php index b21613fd1a0814df7e78d55042e8ca2173d82bba..d648b1cca38bd2ece47055901edd5c9ea0881472 100644 --- a/typo3/sysext/core/Classes/Cache/Backend/FileBackend.php +++ b/typo3/sysext/core/Classes/Cache/Backend/FileBackend.php @@ -107,7 +107,7 @@ class FileBackend extends SimpleFileBackend implements FreezableBackendInterface parent::setCache($cache); if (file_exists($this->cacheDirectory . 'FrozenCache.data')) { $this->frozen = true; - $this->cacheEntryIdentifiers = unserialize(file_get_contents($this->cacheDirectory . 'FrozenCache.data')); + $this->cacheEntryIdentifiers = unserialize((string)file_get_contents($this->cacheDirectory . 'FrozenCache.data')); } } @@ -139,9 +139,9 @@ class FileBackend extends SimpleFileBackend implements FreezableBackendInterface } $this->remove($entryIdentifier); $temporaryCacheEntryPathAndFilename = $this->cacheDirectory . StringUtility::getUniqueId() . '.temp'; - $lifetime = $lifetime ?? $this->defaultLifetime; - $expiryTime = $lifetime === 0 ? 0 : $GLOBALS['EXEC_TIME'] + $lifetime; - $metaData = str_pad($expiryTime, self::EXPIRYTIME_LENGTH) . implode(' ', $tags) . str_pad(strlen($data), self::DATASIZE_DIGITS); + $lifetime = (int)($lifetime ?? $this->defaultLifetime); + $expiryTime = $lifetime === 0 ? 0 : (int)($GLOBALS['EXEC_TIME'] + $lifetime); + $metaData = str_pad((string)$expiryTime, self::EXPIRYTIME_LENGTH) . implode(' ', $tags) . str_pad((string)strlen($data), self::DATASIZE_DIGITS); $result = file_put_contents($temporaryCacheEntryPathAndFilename, $data . $metaData); GeneralUtility::fixPermissions($temporaryCacheEntryPathAndFilename); if ($result === false) { @@ -181,12 +181,12 @@ class FileBackend extends SimpleFileBackend implements FreezableBackendInterface } $dataSize = (int)file_get_contents( $pathAndFilename, - null, + false, null, filesize($pathAndFilename) - self::DATASIZE_DIGITS, self::DATASIZE_DIGITS ); - return file_get_contents($pathAndFilename, null, null, 0, $dataSize); + return file_get_contents($pathAndFilename, false, null, 0, $dataSize); } /** @@ -256,12 +256,12 @@ class FileBackend extends SimpleFileBackend implements FreezableBackendInterface $cacheEntryPathAndFilename = $directoryIterator->getPathname(); $index = (int)file_get_contents( $cacheEntryPathAndFilename, - null, + false, null, filesize($cacheEntryPathAndFilename) - self::DATASIZE_DIGITS, self::DATASIZE_DIGITS ); - $metaData = file_get_contents($cacheEntryPathAndFilename, null, null, $index); + $metaData = (string)file_get_contents($cacheEntryPathAndFilename, false, null, $index); $expiryTime = (int)substr($metaData, 0, self::EXPIRYTIME_LENGTH); if ($expiryTime !== 0 && $expiryTime < $now) { continue; @@ -318,12 +318,12 @@ class FileBackend extends SimpleFileBackend implements FreezableBackendInterface } $index = (int)file_get_contents( $cacheEntryPathAndFilename, - null, + false, null, filesize($cacheEntryPathAndFilename) - self::DATASIZE_DIGITS, self::DATASIZE_DIGITS ); - $expiryTime = (int)file_get_contents($cacheEntryPathAndFilename, null, null, $index, self::EXPIRYTIME_LENGTH); + $expiryTime = (int)file_get_contents($cacheEntryPathAndFilename, false, null, $index, self::EXPIRYTIME_LENGTH); return $expiryTime !== 0 && $expiryTime < $GLOBALS['EXEC_TIME']; } diff --git a/typo3/sysext/core/Classes/Cache/Backend/PdoBackend.php b/typo3/sysext/core/Classes/Cache/Backend/PdoBackend.php index 1735580d28253142ccb237a782ac73ae0ac7d098..070fbf143eb5c7198827451b9b7fd7b08d11b433 100644 --- a/typo3/sysext/core/Classes/Cache/Backend/PdoBackend.php +++ b/typo3/sysext/core/Classes/Cache/Backend/PdoBackend.php @@ -284,6 +284,9 @@ class PdoBackend extends AbstractBackend implements TaggableBackendInterface protected function importSql(\PDO $databaseHandle, string $pdoDriver, string $pathAndFilename): void { $sql = file($pathAndFilename, FILE_IGNORE_NEW_LINES & FILE_SKIP_EMPTY_LINES); + if ($sql === false) { + throw new \RuntimeException('Error while reading file "' . $pathAndFilename . '".', 1601021306); + } // Remove MySQL style key length delimiters (yuck!) if we are not setting up a MySQL db if (strpos($pdoDriver, 'mysql') !== 0) { $sql = preg_replace('/"\\([0-9]+\\)/', '"', $sql); diff --git a/typo3/sysext/core/Classes/Cache/Backend/RedisBackend.php b/typo3/sysext/core/Classes/Cache/Backend/RedisBackend.php index fa844a51c48ef1a89f3f41fead6065e6408b2ea2..8bf584537f37005675d4662bf206d6a40dbaf630 100644 --- a/typo3/sysext/core/Classes/Cache/Backend/RedisBackend.php +++ b/typo3/sysext/core/Classes/Cache/Backend/RedisBackend.php @@ -366,7 +366,7 @@ class RedisBackend extends AbstractBackend implements TaggableBackendInterface $storedEntry = $this->redis->get(self::IDENTIFIER_DATA_PREFIX . $entryIdentifier); } if ($this->compression && (string)$storedEntry !== '') { - $storedEntry = gzuncompress($storedEntry); + $storedEntry = gzuncompress((string)$storedEntry); } return $storedEntry; } diff --git a/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php b/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php index d2dbb371fbcf44cb9a170a1f42e609eb228b72b9..72c17a101ffd33135a718d9ba25cf3530a16d66d 100644 --- a/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php +++ b/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php @@ -307,7 +307,7 @@ class SimpleFileBackend extends AbstractBackend implements PhpCapableBackendInte $directory = $this->cacheDirectory; if (is_link($directory)) { // Avoid attempting to rename the symlink see #87367 - $directory = realpath($directory); + $directory = (string)realpath($directory); } if (is_dir($directory)) { diff --git a/typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php b/typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php index af80fc71d02ef04cd037131b5832c6919a620055..a27b5c3c30ad315dc06331616171484ffc7efd1a 100644 --- a/typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php +++ b/typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php @@ -525,12 +525,12 @@ class Typo3DatabaseBackend extends AbstractBackend implements TaggableBackendInt */ public function getTableDefinitions() { - $cacheTableSql = file_get_contents( + $cacheTableSql = (string)file_get_contents( ExtensionManagementUtility::extPath('core') . 'Resources/Private/Sql/Cache/Backend/Typo3DatabaseBackendCache.sql' ); $requiredTableStructures = str_replace('###CACHE_TABLE###', $this->cacheTable, $cacheTableSql) . LF . LF; - $tagsTableSql = file_get_contents( + $tagsTableSql = (string)file_get_contents( ExtensionManagementUtility::extPath('core') . 'Resources/Private/Sql/Cache/Backend/Typo3DatabaseBackendTags.sql' ); diff --git a/typo3/sysext/core/Classes/Cache/CacheManager.php b/typo3/sysext/core/Classes/Cache/CacheManager.php index ec34f469f28b2f31b824ee7ecd5c89e350fa657b..4f39f6d913733beff01f86660d012194e7a7ed78 100644 --- a/typo3/sysext/core/Classes/Cache/CacheManager.php +++ b/typo3/sysext/core/Classes/Cache/CacheManager.php @@ -88,7 +88,7 @@ class CacheManager implements SingletonInterface * If one of the options is not specified, the default value is assumed. * Existing cache configurations are preserved. * - * @param array $cacheConfigurations The cache configurations to set + * @param array<string, array> $cacheConfigurations The cache configurations to set * @throws \InvalidArgumentException If $cacheConfigurations is not an array */ public function setCacheConfigurations(array $cacheConfigurations)