Skip to content

Commit

Permalink
Fix #64 - take care that getCurrentRatioConfiguration is always strin…
Browse files Browse the repository at this point in the history
…g or a exception is thrown
  • Loading branch information
lochmueller committed Jan 31, 2019
1 parent 5295d89 commit b87c445
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Classes/Xclass/LocalCropScaleMaskHelper.php
Expand Up @@ -90,6 +90,7 @@ public function process(TaskInterface $task)
ObjectAccess::setProperty($task, 'targetFile', $targetFile, true);
}
} catch (\Exception $ex) {
// not handled
}
self::$deepCheck = false;

Expand All @@ -99,20 +100,24 @@ public function process(TaskInterface $task)
/**
* Find the current ratio configuration.
*
* @return string|null
* @return string
* @throws \Exception
*/
protected function getCurrentRatioConfiguration()
protected function getCurrentRatioConfiguration(): string
{
$currentRecord = $GLOBALS['TSFE']->currentRecord;
$parts = GeneralUtility::trimExplode(':', $currentRecord);
if (2 !== sizeof($parts)) {
return null;
throw new \Exception('Invalid count of current record parts', 12367);
}
if ('tt_content' !== $parts[0]) {
return null;
throw new \Exception('Invalid part 0. part 0 have to be tt_content', 127383);
}
$record = BackendUtility::getRecord($parts[0], (int) $parts[1]);
if (!isset($record['image_ratio'])) {
throw new \Exception('No image_ratio found in the current record', 324672);
}

return isset($record['image_ratio']) ? trim($record['image_ratio']) : null;
return trim((string) $record['image_ratio']);
}
}

0 comments on commit b87c445

Please sign in to comment.