WordPress.org

Make WordPress Core

Changeset 23502


Ignore:
Timestamp:
02/28/2013 05:25:15 AM (9 years ago)
Author:
SergeyBiryukov
Message:

Avoid an undefined offset notice in wp_convert_bytes_to_hr(). props soulseekah. fixes #23626.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/deprecated.php

    r23440 r23502  
    33783378function wp_convert_bytes_to_hr( $bytes ) {
    33793379    _deprecated_function( __FUNCTION__, '3.6', 'size_format()' );
     3380
    33803381    $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
    33813382    $log   = log( $bytes, 1024 );
    33823383    $power = (int) $log;
    3383     $size  = pow( 1024, $log - $power );
    3384     return $size . $units[$power];
    3385 }
     3384
     3385    if ( array_key_exists( $power, $units ) ) {
     3386        $size  = pow( 1024, $log - $power );
     3387        $unit = $units[ $power ];
     3388    } else {
     3389        $size = $bytes;
     3390        $unit = $units[0];
     3391    }
     3392
     3393    return $size . $unit;
     3394}
Note: See TracChangeset for help on using the changeset viewer.