Skip to content

Instantly share code, notes, and snippets.

@3D-I
Created August 30, 2019 20:19
Show Gist options
  • Select an option

  • Save 3D-I/d7679f1fb1fa9b6c55d876fa7a9c613b to your computer and use it in GitHub Desktop.

Select an option

Save 3D-I/d7679f1fb1fa9b6c55d876fa7a9c613b to your computer and use it in GitHub Desktop.

Revisions

  1. 3D-I created this gist Aug 30, 2019.
    20 changes: 20 additions & 0 deletions chunck_size.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    <?php
    /**
    * Change get_chunk_size() calculation to correctly calculate limits without
    * letting a zero "unlimited" value always win. Also ensure get_chunk_size()
    * can only return zero if all of the limits were in fact set to unlimited.
    */

    $max = 0;

    $limits = [100, 200, 300];

    foreach ($limits as $limit)
    {
    if ($limit > 0)
    {
    $max = ($max !== 0) ? min($limit, $max) : $limit;
    }
    }

    echo floor($max / 2);