Uncaught PHP Exception DivisionByZeroError: "Division by zero"

Created on 29 February 2024, over 1 year ago

After Updating Core to 10.1.8 some image styles got corrupted

Uncaught PHP Exception DivisionByZeroError: "Division by zero" at /var/www/html/drupal/web/core/modules/image/image.admin.inc line 51, referer: https://example.com/admin/config/media/image-styles?page=1

I created a patch for this issue but still need someone to test it

🐛 Bug report
Status

Needs review

Version

1.0

Component
Image system 

Last updated about 17 hours ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @eyad alanati
  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 5.3 & MySQL 5.5
    last update over 1 year ago
    Patch Failed to Apply
  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    Patch Failed to Apply
  • Status changed to Needs work over 1 year ago
  • The Needs Review Queue Bot tested this issue.

    While you are making the above changes, we recommend that you convert this patch to a merge request . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

  • Status changed to Needs review over 1 year ago
  • Status changed to Postponed: needs info over 1 year ago
  • Please add the exact steps to reproduce to the issue summary.

  • last update over 1 year ago
    Custom Commands Failed
  • Update Core to 10.1.8
    go to image styles
    edit any of the existing image styles
    website will encounter error

  • last update over 1 year ago
    Custom Commands Failed
  • 🇹🇷Turkey loker

    I've experienced the same problem with a number of 10.3.2 installation. I just haven't need to edit styles before so I could only follow the discussion yet.

  • 🇳🇿New Zealand quietone

    @eyad alanati, thanks for providing the steps to reproduce. Can you add them to the issue summary to help others who work on this issue?

    I tested this on Drupal 10.1.8 using the steps in #9 and did not receive any errors. Leaving the 'steps to reproduce' tag because there seems to be something more that needs to be done to reproduce the error.

  • Issue was unassigned.
  • 🇳🇿New Zealand quietone

    Also changing to Unassigned so that others may look at this.

  • Original image height or width is zero.

    What is the image.settings:preview_image config set to on those sites?

  • 🇮🇳India anmolgoyal74

    I am also getting the same error on Drupal 10.2.4. But this error only comes when switching to the ImageMagick toolkit, not with GD.

    image.settings:preview_image: core/modules/image/sample.png

  • 🇳🇿New Zealand quietone

    Drupal 10.1.x is no longer supported. Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.

    Can someone add steps to reproduce in the Issue Summary. I have tried the ones from #9 and did not get the problem.

  • 🇳🇿New Zealand quietone

    Really change to 11.x

  • 🇺🇸United States smustgrave

    Is anyone still experiencing this one? If no follow up in 3 months could be closed out.

  • 🇺🇸United States mjk73

    I'm trying to update some image styles tonight and seeing this issue. I haven't had a reason to edit any of these in a while, so not exactly sure when it was introduced, but trying to edit almost all of my image styles is leading to the following:

    Uncaught PHP Exception DivisionByZeroError: "Division by zero" at /var/www/html/docroot/core/modules/image/image.admin.inc line 77 request_id="v-bcc3ba58-522d-11f0-a348-f768f1d28ced"

    We're on 10.4.5. I'm trying to add Convert to Webp to a bunch of theses styles, and I'm getting this Division by Zero error on essentially every image style. Strangely, they are all editable on my Stage and Dev servers. Somehow corrupted only on Prod. Any thoughts?

    I know that patch associated with this issue is for an older version. Any thoughts on why we might be seeing this error?

  • 🇺🇸United States wmfinck

    I am having this same issue on a relatively new and clean site, but it is along with another issue. Custom fields have no problem storing data in private://* but upon editing a built-in Image Style, or upon creating a new style, the corresponding folders are not created, and I get two messages in the Drupal log:

    Failed to create style directory: private://styles/wide/private/core/modules/image

    and

    DivisionByZeroError: Division by zero in template_preprocess_image_style_preview() (line 77 of /.../web/core/modules/image/image.admin.inc).

    The second error corresponds to an error in the php log. For the first error, there are no entries in either the php or http logs. The directory create failure is always first in the logs, but I cannot find a valid reason for why there is an error. Everything in the system setup and file permissions are fine. The last test was to toggle SELINUX and now I am out of ideas.

Production build 0.71.5 2024