- Issue created by @adrianopulz
- 🇺🇦Ukraine ysamoylenko
Hello @adrianopulz,
I faced the same issue after upgrading our environment to PHP 8.1.
Our Redis instance is on the Azure platform and by simple debugging of
$info
variable I found that our server does not provide the required properties in the output.You can simply check it by changing the code like this
'value' => $this->t('@read read (@percent_read%), @write written (@percent_write%), @commands commands in @connections connections.', [ '@read' => json_encode($info), //'@read' => format_size($info['total_net_output_bytes'] ?? $info['Stats']['total_net_output_bytes']), // '@percent_read' => round(100 / (($info['total_net_output_bytes'] ?? $info['Stats']['total_net_output_bytes']) + ($info['total_net_input_bytes'] ?? $info['Stats']['total_net_input_bytes'])) * ($info['total_net_output_bytes'] ?? $info['Stats']['total_net_output_bytes'])), // '@write' => format_size($info['total_net_input_bytes'] ?? $info['Stats']['total_net_input_bytes']), // '@percent_write' => round(100 / (($info['total_net_output_bytes'] ?? $info['Stats']['total_net_output_bytes']) + ($info['total_net_input_bytes'] ?? $info['Stats']['total_net_input_bytes'])) * ($info['total_net_input_bytes'] ?? $info['Stats']['total_net_input_bytes'])), //'@commands' => $info['total_commands_processed'] ?? $info['Stats']['total_commands_processed'], // '@connections' => $info['total_connections_received'] ?? $info['Stats']['total_connections_received'], ]),
So, looks like the issue is not related to the PHP version update, maybe just partially when the PHP generates a fatal error after throwing the exception.
But you can resolve that at least temporarily while you reconfigure your Redis server.
I've tested several versions of Docker images with Redis and even used Windows ported version but I've not faced the issue experienced on the Azure platform. All tested versions had all the necessary attributes to display.
Tested locally Redis versions: 3.0.504 - 6.0.14 (Not reproducing)
Drupal core: 9.4.8
PHP version: 8.1.14Attaching the patch. Hope it will help you.
- Status changed to Needs review
almost 2 years ago 5:48pm 7 February 2023 - 🇺🇦Ukraine ysamoylenko
Normal info layout in the local environment.
Temporary fix layout.
- 🇧🇷Brazil adrianopulz Florianópolis
Hi @ysamoylenko!
Yeah, that looks great. I'm using Azure Redis as well.
The $info needs to be verified before using it to avoid PHP errors.Thanks for the patch. =)
- Status changed to RTBC
almost 2 years ago 5:24pm 10 February 2023 - 🇺🇦Ukraine ipinchuk
Hi guys,
Thanks for your contribution
@ysamoylenko, your patch works very well.
Changed status to RTBC.
- Status changed to Needs work
almost 2 years ago 11:02pm 23 February 2023 - 🇨🇭Switzerland berdir Switzerland
+++ b/src/Controller/ReportController.php @@ -212,14 +212,16 @@ class ReportController extends ControllerBase { + 'value' => $info['total_net_output_bytes'] || $info['Stats']['total_net_output_bytes'] ?
are the array keys empty or not set? this will cause php notices if they are not set.
Lets wrap it in an !empty() to be extra careful.
- 🇨🇭Switzerland berdir Switzerland
Also seems to be overlapping/very related to ✨ Azure/AWS: Take into account CONFIG command may not work Needs review
- Status changed to Needs review
almost 2 years ago 11:19am 24 February 2023 - 🇺🇦Ukraine ysamoylenko
Hello @Berdir,
Thank you for your response.
These array keys do not exist in the
$info
array.I am adding a new patch with a non-empty evaluation.
According to the mentioned issue, it looks similar but for another section of the report.
In our environment, I have not faced it.
- Merge request !44Fixed the cause uf the PHP error: DivisionByZeroError: Division by zero in... → (Open) created by oushen
- 🇫🇷France karimbou
We are also having this fatal error with PHP8.3.12 and Redis 1.8
On BO: /admin/reports/redis
DivisionByZeroError: Division by zero in Drupal\redis\Controller\ReportController->overview() (line 219 of /var/www/html/web/modules/contrib/redis/src/Controller/ReportController.php).