#44002 closed defect (bug) (duplicate)
fread(): Length parameter must be greater than 0 - Happens on all updates to core, plugins, themes.
Reported by: | mopsyd | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.9.5 |
Component: | Upgrade/Install | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
I'm getting this error in my log every time updates are run. It occurs regardless of whether any plugins or non-wordpress issued themes are active. I am using Sentry on my live site to catch pretty much all errors, and this consistently turns up every time anything updates.
As a test measure, I disabled app 3rd-party plugins and themes, and ran an update against an older version of the twentyfifteen theme as an isolated case. The issue still occurs in lieu of any other 3rd party modifications.
array(4) { ["type"]=> int(2) ["message"]=> string(48) "fread(): Length parameter must be greater than 0" ["file"]=> string(66) "/xxx/xxx/xxx/xxx/redacted.com/wp-admin/includes/class-pclzip.php" ["line"]=> int(4212) }
This appears to be a core bug with the updater. The issue has been consistent since at least 4.9.0, probably earlier.
This component needs to be using fstat to check the size prior to attempting to read. Something like this:
$f = fopen('file', 'r+'); $stat = fstat($f); $size = $stat['size']; if ( $size > 0 ) { // The file is non-zero length and safe to read. $contents = fread( $f ); // Carry on. } else { // Do not fread an empty file. Return, throw an exception, whatever's clever. }
Change History (5)
#2
@
4 years ago
@mopsyd I believe this problem was fixed in WP 5.7, as part of #52018.
Can you please confirm whether you are still experiencing this (assuming you've updated the site in question to 5.7)?
Is this blocking your upgrades? I did not look into the log yet though.