Skip to content
Snippets Groups Projects
Commit 76131609 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Add clearcache function, some cgl issues

parent 982d5dcf
No related branches found
No related tags found
1 merge request!11Feature security update
......@@ -27,8 +27,10 @@ namespace SGalinski\SgMail\Service;
***************************************************************/
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
/**
* Provides an api for registering your mail templates
......@@ -82,6 +84,7 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
$entry = $cache->get($cacheId);
if (!$entry) {
$this->clearCaches();
$entry = $this->registerExtensions();
if ($entry === NULL) {
......@@ -141,12 +144,12 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
// get file name without folders
$pathAsArray = GeneralUtility::trimExplode('/', $pathToRegistrationFile);
$filename = $pathAsArray[\count($pathAsArray)-1];
$filename = $pathAsArray[\count($pathAsArray) - 1];
$filenameWithoutHash = GeneralUtility::trimExplode('_', $filename)[1];
$hash = md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . '|' . $filenameWithoutHash);
// if the filename doesnt start with the hash value, ignore it
if (strpos($filename, $hash) !== 0) {
continue;
continue;
}
$configArray = (include $pathToRegistrationFile);
......@@ -244,5 +247,20 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
// get the location where automatic registrations should be stored
return 'EXT:' . $tsSettings['mail']['configurationLocation'] . '/' . RegisterService::CONFIG_PATH;
}
/**
* Clear the sgmail register cache
*
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
private function clearCaches() {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$cacheManager = $objectManager->get(CacheManager::class);
/** @var FrontendInterface $cache */
$cache = $cacheManager->getCache(RegisterService::CACHE_NAME);
/** @var FrontendInterface $cache */
$cache->flush();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment