Error in the FileHelper class after switching to PHP 8.0
-
Dear plugin developer(s),
After upgrading my website from PHP 7.3 to PHP 8.0 and testing if everything works, I ran into a PHP error that also led to a JS error.
The loadFile function of the FileHelper class threw an error around line 228, saying that the fread method’s second parameter cannot be zero. This caused the Dashboard settings screen to indicate document.getElementById(“converters”) returns null and document.getElementById(“whitelist”) returns null errors.
As a (possible) solution, I’ve replaced this part of the loadFile function:
$handle = @fopen($filename, “r”);
if ($handle !== false) {
//Return value is either file content or false
$return = @fread($handle, filesize($filename));
fclose($handle);
}with this line:
$return = file_get_contents($filename);This seemingly solved the error. The Settings page loads normally again.
Do you think this – or something similar – is a possible solution? If so, could this error be fixed in the next patch of the plugin?
- The topic ‘Error in the FileHelper class after switching to PHP 8.0’ is closed to new replies.