#110076PHP Warning "Undefined array key" in ImageProcessingInstructions::streamlineOptions() when the "crop" option is an empty string
Description
Affected: TYPO3 13.4.32
Problem
Processing an image with an empty crop option ( 'crop' => '' ) makes ImageProcessingInstructions::streamlineOptions() emit three PHP warnings:
PHP Warning: Undefined array key 1/2/3 in .../Imaging/ImageProcessingInstructions.php line 338
With a target width but no height, the same empty crop instead throws a fatal Division by zero at line 174.
Root cause
streamlineOptions() guards the crop handling with isset($options['crop']) , which is true for an empty string. json_decode('') is falsy, so execution reaches:
[$offsetLeft, $offsetTop, $newWidth, $newHeight] = explode(',', $options['crop'], 4); // line 338
explode(',', '', 4) returns a single element → indexes 1/2/3 are undefined (the warnings) and an Area(0, 0, 0, 0) is built. That area is not dropped by the following isEmpty() check, because Area::isEmpty() only matches the full-image area:
return $this->x === 0.0 && $this->y === 0.0 && $this->width === 1.0 && $this->height === 1.0;
So the zero-width area reaches fromCropScaleValues() (line 134) and becomes the divisor at line 174 → Division by zero.
The sibling method getConfigurationForImageCropScaleMask() (line 393) guards the identical explode with a truthy check ( if ($configuration['crop'] ?? null) ), which already skips an empty string — so the two paths are inconsistent.
Why an empty crop is a real input
sys_file_reference.crop stays empty unless it is filled in via the backend image-cropping field (TCA type imageManipulation ). Programmatic creation therefore leaves it empty — e.g. an importer that builds a \TYPO3\CMS\Extbase\Domain\Model\FileReference and persists it via Extbase, as that model has no crop property. The empty value then flows into image processing, e.g. via ContentObjectRenderer::imageLinkWrap() , whose configuration sets crop.data = file:current:crop .
Reproduction (verified on 13.4.33 / PHP 8.4)
use TYPO3\CMS\Core\Resource\ProcessedFile;
$file->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, ['width' => 100, 'height' => 80, 'crop' => '']);
// -> 3x "Undefined array key" (line 338)
$file->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, ['width' => 100, 'crop' => '']);
// -> fatal "Division by zero" (line 174)
Expected
An empty crop string should be treated as “no crop”, without warnings or errors.
Suggested fix
In streamlineOptions (), treat an empty crop as absent — e.g. guard with !empty($options['crop']) instead of isset(...) , matching the sibling method. Optionally harden both explode() calls with a count(...) === 4 check.