Hi @qriouslad, thanks for responding. I am using shared hosting (Litespeed) and can reproduce the issue under PHP 8.0/8.1. The code executes under PHP 7.4 and earlier versions with some non-breaking issues.
I believe the root cause for the problem is a combination of a configuration limitation of my host under PHP 8.x and a mishandling of the ‘Disk Usage’ string on your end.
1. The configuration limitation is that my host allows exec() but does not have a setting to allow shell_exec() and it makes it impossible to extract the needed values to work with on your end. In both PHP 7.4 and PHP 8.0, your module reports CPU uptime, Load Average, RAM usage and the output of sd_total_disk_space()
as ‘undetectable’.
(I tested that last one by replacing the whole line that populates the ‘Disk Usage’ content with 'content' => $this->sd_total_disk_space()
to see what happens.)
Maybe consider using exec() instead of shell_exec()? I don’t have a lot of experience with PHP but the way I see it, exec() can be made to return the full output of a command as an array, and will even return a stat code for successful operation completion?
2. The problem with your code is that it will use the output of sd_total_disk_space twice on that line regardless of whether it returns a numeric value or ‘undetectable’. PHP 7.4 lets this slide by throwing a series of warnings (non-numeric value detected, division by zero) but PHP 8.x is more strict about casting strings as ints and floats, and will have none of it. That is why under PHP 7.4 I get a <strong>Disk Usage</strong> 1 TB free (INF%) of bytes total
message but under PHP 8.x WordPress breaks completely.
While there is obviously nothing you can do about my host configuration, I believe with this information you will be able to improve the process of reporting disk storage to allow for ‘undetectable’ total disk space.
A separate issue: You have a typo within sd_site_health()
on line 366 in the same file (misspelled $output
as $ouput
in the $issues_total
count check). In case your line numbering has changed, this screenshot refers: https://i.imgur.com/naKHCSZ.jpg
-
This reply was modified 2 years, 8 months ago by Ivan Arnaudov.
-
This reply was modified 2 years, 8 months ago by Ivan Arnaudov. Reason: Improved suggestion