[BUGFIX] Cast indexer config to integers before multiplication 46/62846/3
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Fri, 10 Jan 2020 16:32:57 +0000 (17:32 +0100)
committerDaniel Goerz <daniel.goerz@posteo.de>
Tue, 14 Jan 2020 16:00:17 +0000 (17:00 +0100)
If either the options `minAge` or `maxAge` are an empty string, the
corresponding multiplication will fail and a PHP warning is triggered.

As a quick win, the values are casted to integers.

Resolves: #90087
Releases: master, 9.5, 8.7
Change-Id: Ia6861434231e7e338384c3e919a09466b39d425f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62846
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Jörg Bösche <typo3@joergboesche.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
typo3/sysext/indexed_search/Classes/Indexer.php

index d13b7ff..32c1b80 100644 (file)
@@ -451,8 +451,8 @@ class Indexer
         $this->setT3Hashes();
         // Indexer configuration from Extension Manager interface:
         $this->indexerConfig = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('indexed_search');
-        $this->tstamp_minAge = MathUtility::forceIntegerInRange($this->indexerConfig['minAge'] * 3600, 0);
-        $this->tstamp_maxAge = MathUtility::forceIntegerInRange($this->indexerConfig['maxAge'] * 3600, 0);
+        $this->tstamp_minAge = MathUtility::forceIntegerInRange((int)($this->indexerConfig['minAge'] ?? 0) * 3600, 0);
+        $this->tstamp_maxAge = MathUtility::forceIntegerInRange((int)($this->indexerConfig['maxAge'] ?? 0) * 3600, 0);
         $this->maxExternalFiles = MathUtility::forceIntegerInRange($this->indexerConfig['maxExternalFiles'], 0, 1000, 5);
         $this->flagBitMask = MathUtility::forceIntegerInRange($this->indexerConfig['flagBitMask'], 0, 255);
         // Workaround: If the extension configuration was not updated yet, the value is not existing