Issue Bug Closed

#106399DivisionByZeroError in the Backend

Katharina Strasser 03/20/25, 08:57 updated 03/26/25, 12:32

Description

Hello,

as I tried to edit a record I got this:

`typo3/sysext/core/Classes/Imaging/ImageProcessingInstructions.php line 190`

Typo3 Version 13.4.7

The image record/reference might be faulty, but bcause of this error it is impossible to access the Content-Element in the backend.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 11

  1. Katharina Strasser commented <span data-processor="relativetime" data-value="2025-03-20T08:59:33+00:00" > 03/20/25, 08:59 </span>

    More infomation:

    (1/1) DivisionByZeroError

    Division by zero

    /myRootPath/typo3/sysext/core/Classes/Imaging/ImageProcessingInstructions.php line 190

            if (!empty($options['maxHeight'])) {
                if ($height > $options['maxHeight'] || ($height === 0 && $cropArea->getHeight() > $options['maxHeight'])) {
                    $height = (int)$options['maxHeight'];
                    $width = max(1, (int)round($cropArea->getWidth() * ($height / $cropArea->getHeight())));
                }
            }
  2. Garvin Hicking commented and changed category status New Needs Feedback <span data-processor="relativetime" data-value="2025-03-20T09:07:13+00:00" > 03/20/25, 09:07 </span>

    Hey,

    thanks for the report. This sounds like your ‘crop’ information has the ‘height’ set to 0. Can you show the contents of the ‘crop’ field of your sys_file_reference record this happens with?

  3. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-03-20T09:08:59+00:00" > 03/20/25, 09:08 </span>

    We can safe-guard the symptom with something like this:

                    $width = max(1, (int)round($cropArea->getWidth() * ($height / max(1, $cropArea->getHeight()))));

    but I’d really like to know what and how a possibly wrong crop info got saved into the database, because then other things might fail, too.

  4. Katharina Strasser commented <span data-processor="relativetime" data-value="2025-03-20T09:56:08+00:00" > 03/20/25, 09:56 </span>

    Garvin Hicking wrote in #note-2:
    > Hey,
    >
    > thanks for the report. This sounds like your ‘crop’ information has the ‘height’ set to 0. Can you show the contents of the ‘crop’ field of your sys_file_reference record this happens with?

    Hello,
    the content of the crop field for this file is:

    {"default":{"cropArea":{"height":1,"width":0.833,"x":0.088,"y":0},"selectedRatio":"4:3","focusArea":null}}

    This json seems to be correct, but I think is is acually related to a other issue I’ve found in the typo3 instance:

    The file did not had a “sys_file_metadata” record.
    Therefore the system cannot be aware of the image dimensions.

  5. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-03-20T10:27:36+00:00" > 03/20/25, 10:27 </span>

    Ah, thank you for this feedback, this is helpful.

    There is a cleanup task / CLI command that can scan files and will populate their missing file metadata, can you run this and check if the error also goes away then?

  6. Katharina Strasser commented <span data-processor="relativetime" data-value="2025-03-20T11:59:39+00:00" > 03/20/25, 11:59 </span>

    Garvin Hicking wrote in #note-5:
    > Ah, thank you for this feedback, this is helpful.
    >
    > There is a cleanup task / CLI command that can scan files and will populate their missing file metadata, can you run this and check if the error also goes away then?

    The cleanup task does not create the missing meta data. I already have a custom meta-data scanner in place to take care of this.

    But I get an error for the CLI command: “cleanup:missingrelations”

    [ TYPO3\CMS\Extbase\Configuration\Exception\NoServerRequestGivenException ]
    No request given. ConfigurationManager has not been initialized properly.

  7. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-03-20T12:04:52+00:00" > 03/20/25, 12:04 </span>

    > The cleanup task does not create the missing meta data. I already have a custom meta-data scanner in place to take care of this.

    Sorry, I never use the right name for this task. I mean “File Abstraction Layer: Extract metadata in storage”.

    > But I get an error for the CLI command: “cleanup:missingrelations“
    >
    > [ TYPO3\CMS\Extbase\Configuration\Exception\NoServerRequestGivenException ]
    > No request given. ConfigurationManager has not been initialized properly.

    This could actually be caused by other things in your setup, extensions trying to access Extbase at a point where it is not available (CLI context). The Core CLI command itself does not access extbase, so it must come from a third-party extension, maybe you can debug which one.

    Do other CLI tasks run properly?

  8. Katharina Strasser commented <span data-processor="relativetime" data-value="2025-03-20T12:27:06+00:00" > 03/20/25, 12:27 </span>

    Garvin Hicking wrote in #note-7:
    > Do other CLI tasks run properly?
    Yes, other Tasks run, I disabled every 3rd party extension the also the mentioned task run without issue.

    Garvin Hicking wrote in #note-8:
    > Sorry, I never use the right name for this task. I mean “File Abstraction Layer: Extract metadata in storage”.
    This task runs, it finds other files (creates the meta data), but not for the one file (which is present in the system).

  9. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-03-20T12:50:09+00:00" > 03/20/25, 12:50 </span>

    What kind of file is the failing one? Maybe image/graphics magick is failing to read the files. You might want to try to manually call the convert/fileinfo binary on it? Could be too large dimensions, incompatible color profile or so…?

  10. Katharina Strasser commented <span data-processor="relativetime" data-value="2025-03-20T12:59:33+00:00" > 03/20/25, 12:59 </span>

    Its a normal image (js) with a 1920×1080 resolution.

    I have tested now this:
    Uploaded a random image -> MetaData gets created.
    Everthing works fine.

    To mimic the Problem I have to delete the created MetaData record.
    I cannot rescan the image with Typo3 itself.

    I have to reupload the file or use a custom metadata scanner.

    I think there was a problem with the initial file during uploading years ago

  11. Garvin Hicking commented and changed status Needs Feedback Closed <span data-processor="relativetime" data-value="2025-03-26T12:32:24+00:00" > 03/26/25, 12:32 </span>

    Thanks for your feedback. I hope it is okay to close this issue with a note that the data integrity was the actual problem here?

    Maybe extensions like dbdoctor could help catch these kind of records.