Problem/Motivation

We get this error on one of our servers:

[Mon Dec 11 18:55:15.244348 2023] [proxy_fcgi:error] [pid 2539467:tid 140566251677376] [client 127.0.0.1:56878] AH01071: Got error 'PHP message: Uncaught PHP Exception DivisionByZeroError: "Division by zero" at /home/insite/test/sites/insite-drupal-main/web/modules/contrib/cache_utility/src/Form/SettingsForm.php line 763'

Steps to reproduce

This seems to happen when opcache.file_cache_only is enabled.
opcache_get_status() then returns this:

array(3) {
  ["opcache_enabled"]=>
  bool(false)
  ["file_cache"]=>
  string(29) "/home/insite/php-opcache-cli/"
  ["file_cache_only"]=>
  bool(true)
}

Proposed resolution

SettingsForm::getOPCacheDisplayInfo() should check if $status['opcache_statistics'] exists before trying to use it.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

    Comments

    prudloff created an issue. See original summary.

    viren18febs’s picture

    Status: Active » Needs review
    StatusFileSize
    new584 bytes

    Hi @prudloff

    I have added a patch, please review.
    Thanks

    prudloff’s picture

    Status: Needs review » Needs work

    I don't think $status exists outside getOPCacheDisplayInfo().

    sakthi_dev’s picture

    Status: Needs work » Needs review
    StatusFileSize
    new121.82 KB
    new1.56 KB

    Addressed the comment #3. Please review. I don't have much knowledge on this project but updated the code and it's working properly for me.

    cyoun’s picture

    Status: Needs review » Fixed

    This issue was resolved in version 1.2.0

    cyoun’s picture

    Status: Fixed » Closed (fixed)