S3-Uploads icon indicating copy to clipboard operation
S3-Uploads copied to clipboard

fix readdir bug from PHP 8 substr change

Open sc0tth0lden opened this issue 2 years ago • 0 comments

As of PHP 8.0, substr will return empty string rather than false in certain circumstances.

From https://www.php.net/manual/en/function.substr.php : 8.0.0 The function returns an empty string where it previously returned false.

Due to this change, this implementation of readdir in S3-Uploads behaves incorrectly. In particular, this common pattern: while (($file = readdir($dh)) !== false){ which is used in gravityforms, becomes an infinite loop since the while loop just keeps getting an empty string rather than false.

This can lead to a crazy high AWS S3 list line item on your monthly bill. I recommend merging in this change right away to avoid this situation.

sc0tth0lden avatar Jan 11 '24 13:01 sc0tth0lden