Skip to content

Instantly share code, notes, and snippets.

@3D-I
Created August 30, 2019 20:19
Show Gist options
  • Save 3D-I/d7679f1fb1fa9b6c55d876fa7a9c613b to your computer and use it in GitHub Desktop.
Save 3D-I/d7679f1fb1fa9b6c55d876fa7a9c613b to your computer and use it in GitHub Desktop.
<?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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment