From 0fee8243a4fe6b6789b00d30be06c6565599c6ba Mon Sep 17 00:00:00 2001 From: Susanne Moog <look@susi.dev> Date: Thu, 21 May 2020 15:33:36 +0200 Subject: [PATCH] [TASK] Clean up admin panel types Resolves: #91457 Releases: master Change-Id: I29009a9498b050942e34a27815acdf996e6f0539 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64558 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Daniel Goerz <daniel.goerz@posteo.de> Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de> Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de> Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de> --- .../sysext/adminpanel/Classes/Log/InMemoryLogWriter.php | 2 +- typo3/sysext/adminpanel/Classes/Modules/Debug/Events.php | 1 + typo3/sysext/adminpanel/Classes/Modules/Debug/Log.php | 4 ++-- .../Classes/Modules/Debug/QueryInformation.php | 9 +++++++-- .../Classes/Modules/Info/GeneralInformation.php | 2 +- .../adminpanel/Classes/Utility/ResourceUtility.php | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/typo3/sysext/adminpanel/Classes/Log/InMemoryLogWriter.php b/typo3/sysext/adminpanel/Classes/Log/InMemoryLogWriter.php index 19ef85008d89..16ea9089120d 100644 --- a/typo3/sysext/adminpanel/Classes/Log/InMemoryLogWriter.php +++ b/typo3/sysext/adminpanel/Classes/Log/InMemoryLogWriter.php @@ -54,7 +54,7 @@ class InMemoryLogWriter extends AbstractWriter } // Guard: Memory Usage - if (!self::$memoryLock && MemoryUtility::isMemoryConsumptionTooHigh()) { + if (MemoryUtility::isMemoryConsumptionTooHigh()) { $this->lockWriter(); return $this; } diff --git a/typo3/sysext/adminpanel/Classes/Modules/Debug/Events.php b/typo3/sysext/adminpanel/Classes/Modules/Debug/Events.php index 54c38227c8d6..21c41a0d8ec1 100644 --- a/typo3/sysext/adminpanel/Classes/Modules/Debug/Events.php +++ b/typo3/sysext/adminpanel/Classes/Modules/Debug/Events.php @@ -47,6 +47,7 @@ class Events extends AbstractSubModule implements DataProviderInterface public function getDataToStore(ServerRequestInterface $request): ModuleData { + /** @var \TYPO3\CMS\Adminpanel\Service\EventDispatcher $eventDispatcher */ $eventDispatcher = GeneralUtility::makeInstance(EventDispatcherInterface::class); $cloner = new VarCloner(); $cloner->setMinDepth(2); diff --git a/typo3/sysext/adminpanel/Classes/Modules/Debug/Log.php b/typo3/sysext/adminpanel/Classes/Modules/Debug/Log.php index 3c320330deca..94f500400e1f 100644 --- a/typo3/sysext/adminpanel/Classes/Modules/Debug/Log.php +++ b/typo3/sysext/adminpanel/Classes/Modules/Debug/Log.php @@ -143,7 +143,7 @@ class Log extends AbstractSubModule implements DataProviderInterface, ModuleSett */ public function getContent(ModuleData $data): string { - $this->logLevel = $this->getConfigOption('startLevel'); + $this->logLevel = (int)$this->getConfigOption('startLevel'); $view = GeneralUtility::makeInstance(StandaloneView::class); $templateNameAndPath = 'EXT:adminpanel/Resources/Private/Templates/Modules/Debug/Log.html'; $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath)); @@ -180,7 +180,7 @@ class Log extends AbstractSubModule implements DataProviderInterface, ModuleSett */ public function enrich(ServerRequestInterface $request): ServerRequestInterface { - $this->logLevel = $this->getConfigOption('startLevel'); + $this->logLevel = (int)$this->getConfigOption('startLevel'); // set inMemoryLogWriter recursively for all configured namespaces/areas so we don't lose log entries $configWithInMemoryWriter = $this->setLoggingConfigRecursive($GLOBALS['TYPO3_CONF_VARS']['LOG'] ?? []); diff --git a/typo3/sysext/adminpanel/Classes/Modules/Debug/QueryInformation.php b/typo3/sysext/adminpanel/Classes/Modules/Debug/QueryInformation.php index 6b2119b51c4e..325802487ec1 100644 --- a/typo3/sysext/adminpanel/Classes/Modules/Debug/QueryInformation.php +++ b/typo3/sysext/adminpanel/Classes/Modules/Debug/QueryInformation.php @@ -98,7 +98,12 @@ class QueryInformation extends AbstractSubModule implements DataProviderInterfac { $groupedQueries = []; foreach ($queries as $query) { - $identifier = sha1($query['sql']) . sha1(json_encode($query['backtrace'])); + $backtraceString = json_encode($query['backtrace']); + if ($backtraceString === false) { + // skip entry if it can't be encoded + continue; + } + $identifier = sha1($query['sql']) . sha1($backtraceString); if (is_array($query['params'])) { foreach ($query['params'] as $k => $param) { if (is_array($param)) { @@ -123,7 +128,7 @@ class QueryInformation extends AbstractSubModule implements DataProviderInterfac } uasort( $groupedQueries, - function ($a, $b) { + static function ($a, $b) { return $b['time'] <=> $a['time']; } ); diff --git a/typo3/sysext/adminpanel/Classes/Modules/Info/GeneralInformation.php b/typo3/sysext/adminpanel/Classes/Modules/Info/GeneralInformation.php index 96021ca26afd..b9bba534eec3 100644 --- a/typo3/sysext/adminpanel/Classes/Modules/Info/GeneralInformation.php +++ b/typo3/sysext/adminpanel/Classes/Modules/Info/GeneralInformation.php @@ -131,7 +131,7 @@ class GeneralInformation extends AbstractSubModule implements DataProviderInterf $count = 0; $totalImageSize = 0; foreach (GeneralUtility::makeInstance(AssetCollector::class)->getMedia() as $file => $information) { - $fileSize = @filesize($file); + $fileSize = (int)@filesize($file); $imagesOnPage['files'][] = [ 'name' => $file, 'size' => $fileSize, diff --git a/typo3/sysext/adminpanel/Classes/Utility/ResourceUtility.php b/typo3/sysext/adminpanel/Classes/Utility/ResourceUtility.php index a21160b2699a..6004e7316fa6 100644 --- a/typo3/sysext/adminpanel/Classes/Utility/ResourceUtility.php +++ b/typo3/sysext/adminpanel/Classes/Utility/ResourceUtility.php @@ -28,7 +28,7 @@ class ResourceUtility * Get additional resources (css, js) from modules and merge it to * one array - returns an array of full html tags * - * @param \TYPO3\CMS\Adminpanel\ModuleApi\ResourceProviderInterface[] $modules + * @param \TYPO3\CMS\Adminpanel\ModuleApi\ModuleInterface[] $modules * @return array */ public static function getAdditionalResourcesForModules(array $modules): array -- GitLab