Skip to content
Permalink
Browse files

Fix #72 - Move extension configuration unserialize to single method a…

…nd check the configuration in front of the unserialize
  • Loading branch information
lochmueller committed Jun 11, 2018
1 parent ed43b3e commit deaf878d79807d834199e08b837544f05cd590d9
Showing with 21 additions and 10 deletions.
  1. +17 −4 Classes/Configuration.php
  2. +4 −6 Classes/Service/ConfigurationService.php
@@ -64,7 +64,7 @@ public static function registerBackendModule()
*/
public static function registerHooks()
{
$configuration = \unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['staticfilecache']);
$configuration = self::getConfiguration();
// Register with "crawler" extension:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['procInstructions']['tx_staticfilecache_clearstaticfile'] = 'clear static cache file';
@@ -76,7 +76,8 @@ public static function registerHooks()
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all']['staticfilecache'] = LogNoCache::class . '->log';
// Add the right cache hook
switch ($configuration['saveCacheHook']) {
$saveCacheHook = isset($configuration['saveCacheHook']) ? $configuration['saveCacheHook'] : '';
switch ($saveCacheHook) {
case 'ContentPostProcOutput':
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output']['staticfilecache'] = ContentPostProcOutput::class . '->insert';
break;
@@ -137,7 +138,7 @@ public static function registerSlots()
*/
public static function registerCachingFramework()
{
$configuration = \unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['staticfilecache']);
$configuration = self::getConfiguration();
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['staticfilecache'] = [
'frontend' => UriFrontend::class,
@@ -149,7 +150,7 @@ public static function registerCachingFramework()
];
// Disable staticfilecache in development if extension configuration 'disableInDevelopment' is set
if ($configuration['disableInDevelopment'] && GeneralUtility::getApplicationContext()->isDevelopment()) {
if (isset($configuration['disableInDevelopment']) && $configuration['disableInDevelopment'] && GeneralUtility::getApplicationContext()->isDevelopment()) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['staticfilecache']['backend'] = NullBackend::class;
}
}
@@ -183,4 +184,16 @@ public static function registerIcons()
]
);
}
/**
* Get the current extension configuration
*
* @return array
*/
public static function getConfiguration() : array {
if(!isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['staticfilecache']) || !is_string($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['staticfilecache'])) {
return [];
}
return (array)\unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['staticfilecache']);
}
}
@@ -5,6 +5,7 @@
declare(strict_types=1);
namespace SFC\Staticfilecache\Service;
use SFC\Staticfilecache\Configuration;
/**
* Handle extension and TS configuration.
@@ -23,12 +24,9 @@ class ConfigurationService extends AbstractService
*/
public function __construct()
{
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['staticfilecache'])) {
$extensionConfig = \unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['staticfilecache']);
if (\is_array($extensionConfig)) {
$this->configuration = \array_merge($this->configuration, $extensionConfig);
}
}
$extensionConfig = Configuration::getConfiguration();
$this->configuration = \array_merge($this->configuration, $extensionConfig);
if (\is_object($GLOBALS['TSFE']) && isset($GLOBALS['TSFE']->tmpl->setup['tx_staticfilecache.']) && \is_array($GLOBALS['TSFE']->tmpl->setup['tx_staticfilecache.'])) {
$this->configuration = \array_merge(
$this->configuration,

0 comments on commit deaf878

Please sign in to comment.
You can’t perform that action at this time.