1<?php
2
3function znote_health_issues(): array
4{
5 $issues = array();
6
7 if (!extension_loaded('mysqli')) {
8 $issues[] = array('label' => 'PHP extension', 'detail' => 'mysqli is not loaded.');
9 }
10
11 $root = dirname(__DIR__, 2);
12 $free = @disk_free_space($root);
13 $total = @disk_total_space($root);
14 if ($free !== false && $total !== false && $total > 0) {
15 $percentFree = ($free / $total) * 100;
16 if ($percentFree < 5 || $free < 524288000) {
17 $issues[] = array(
18 'label' => 'Disk space',
19 'detail' => number_format($free / 1048576, 0) . ' MB free (' . number_format($percentFree, 1) . '%).',
20 );
21 }
22 }
23
24 if (function_exists('znote_migrations_status')) {
25 foreach (znote_migrations_status() as $name => $migration) {
26 if (($migration['state'] ?? '') === 'changed') {
27 $issues[] = array(
28 'label' => 'Migration changed',
29 'detail' => (string) $name . ' was applied but the file no longer matches what ran.',
30 );
31 }
32 }
33 }
34
35 return $issues;
36}
37