From 334bb34625b0ff579329b906495cc51cb8b0e1ca Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Jul 2017 13:00:51 +0200 Subject: [PATCH] TASK: Cleanup code Use get and use an try catch. Receiving null through ifExists will result in an php error. --- Classes/Domain/Index/AbstractIndexer.php | 27 ++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Classes/Domain/Index/AbstractIndexer.php b/Classes/Domain/Index/AbstractIndexer.php index 18e1702..51acc12 100644 --- a/Classes/Domain/Index/AbstractIndexer.php +++ b/Classes/Domain/Index/AbstractIndexer.php @@ -21,6 +21,7 @@ namespace Codappix\SearchCore\Domain\Index; */ use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; +use Codappix\SearchCore\Configuration\InvalidArgumentException; use Codappix\SearchCore\Connection\ConnectionInterface; use \TYPO3\CMS\Core\Utility\GeneralUtility; @@ -125,18 +126,22 @@ abstract class AbstractIndexer implements IndexerInterface { $record['search_abstract'] = ''; - $fieldsToUse = GeneralUtility::trimExplode( - ',', - $this->configuration->getIfExists('indexing.' . $this->identifier . '.abstractFields') - ); - if (!$fieldsToUse) { - return; - } - foreach ($fieldsToUse as $fieldToUse) { - if (isset($record[$fieldToUse]) && trim($record[$fieldToUse])) { - $record['search_abstract'] = trim($record[$fieldToUse]); - break; + try { + $fieldsToUse = GeneralUtility::trimExplode( + ',', + $this->configuration->get('indexing.' . $this->identifier . '.abstractFields') + ); + if (!$fieldsToUse) { + return; } + foreach ($fieldsToUse as $fieldToUse) { + if (isset($record[$fieldToUse]) && trim($record[$fieldToUse])) { + $record['search_abstract'] = trim($record[$fieldToUse]); + break; + } + } + } catch (InvalidArgumentException $e) { + return; } }