Make WordPress Core

Ticket #65439: trac-65439.diff

File trac-65439.diff, 942 bytes (added by vedantere, 5 months ago)

Fix: guard against division by zero in wp_dashboard_quota() and display_space_usage()

  • src/wp-admin/includes/dashboard.php

    diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php
    index 778e3de403..6bc193ba2f 100644
    a b function wp_dashboard_quota() {  
    16611661        $quota = get_space_allowed();
    16621662        $used  = get_space_used();
    16631663
     1664        if ( $quota <= 0 ) {
     1665                return;
     1666        }
     1667
    16641668        if ( $used > $quota ) {
    16651669                $percentused = '100';
    16661670        } else {
  • src/wp-admin/includes/ms.php

    diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php
    index be87d05aea..2735078a02 100644
    a b function display_space_usage() {  
    256256        $space_allowed = get_space_allowed();
    257257        $space_used    = get_space_used();
    258258
    259         $percent_used = ( $space_used / $space_allowed ) * 100;
     259        $percent_used = $space_allowed > 0 ? ( $space_used / $space_allowed ) * 100 : 0;
    260260
    261261        $space = size_format( $space_allowed * MB_IN_BYTES );
    262262        ?>