BoldGrid / boldgrid-backup

The Total Upkeep plugin.
GNU General Public License v2.0
11 stars 9 forks source link

Fatal error: Uncaught TypeError: fread() #561

Open SitesByYogi opened 1 year ago

SitesByYogi commented 1 year ago

Describe the bug In reference to this ticket https://www.boldgrid.com/support/question/experiencing-a-backup-error-with-total-upkeep/

ERROR MESSAGES: Fatal error: Uncaught TypeError: fread(): Argument #1 ($stream) must be of type resource, bool given in /data/c/f/cf8377f2-6293-4e48-a3cd-7b172316e806/ekoservislm.sk/web/wp-content/plugins/boldgrid-backup/admin/class-boldgrid-backup-admin-cli.php:139 Stack trace: #0 /data/c/f/cf8377f2-6293-4e48-a3cd-7b172316e806/ekoservislm.sk/web/wp-content/plugins/boldgrid-backup/admin/class-boldgrid-backup-admin-cli.php(139): fread(false, 4096)

Warning: popen(crontab -l > /tmp/boldgrid_backup/crontab 2>/dev/null,r): Permission denied in /data/c/f/cf8377f2-6293-4e48-a3cd-7b172316e806/ekoservislm.sk/web/wp-content/plugins/boldgrid-backup/admin/class-boldgrid-backup-admin-cli.php on line 137

If you look at these lines you'd get a boolean falseif an error occured using popen. We check later down in the file if it was false, but we already tried to freadthe value of popen, which caused the error. We should probably check for that false before we try to fread.

Could also be something weird with this particular users server, because popenlooks like it's available but is erroring out, but we could prevent that fatal if we checked before reading it.

Likely can be resolved by moving line 139 inside of the if ( false !== $handle ) statement.