false === $free ? null : (int) $free, 'disk_total' => false === $total ? null : (int) $total, 'opcache' => $opcache, 'object_cache' => function_exists( 'wp_using_ext_object_cache' ) && wp_using_ext_object_cache(), ) ); } /** * Pure evaluation. * * @param array{disk_free: int|null, disk_total: int|null, opcache: bool, object_cache: bool} $facts Facts. * @return Result[] */ public static function evaluate( array $facts ): array { $results = array(); if ( null !== $facts['disk_free'] && null !== $facts['disk_total'] && $facts['disk_total'] > 0 ) { $ratio = $facts['disk_free'] / $facts['disk_total']; $label = sprintf( /* translators: 1: free space, 2: total space */ __( 'Disk space: %1$s free of %2$s', 'keepwatch' ), size_format( $facts['disk_free'] ), size_format( $facts['disk_total'] ) ); if ( $ratio < self::DISK_CRIT ) { $results[] = new Result( 'environment.disk', Result::CRITICAL, $label, __( 'The disk is nearly full. Sites stop updating, logging and uploading when space runs out.', 'keepwatch' ) ); } elseif ( $ratio < self::DISK_WARN ) { $results[] = new Result( 'environment.disk', Result::RECOMMENDED, $label, __( 'Free up space or ask your host to expand the volume before updates fill the disk.', 'keepwatch' ) ); } else { $results[] = new Result( 'environment.disk', Result::GOOD, $label ); } } $results[] = $facts['opcache'] ? new Result( 'environment.opcache', Result::GOOD, __( 'PHP OPcache is enabled', 'keepwatch' ) ) : new Result( 'environment.opcache', Result::RECOMMENDED, __( 'PHP OPcache is not enabled', 'keepwatch' ), __( 'OPcache caches compiled PHP and makes WordPress noticeably faster. Ask your host to enable it.', 'keepwatch' ) ); $results[] = $facts['object_cache'] ? new Result( 'environment.object_cache', Result::GOOD, __( 'A persistent object cache is in use', 'keepwatch' ) ) : new Result( 'environment.object_cache', Result::RECOMMENDED, __( 'No persistent object cache detected', 'keepwatch' ), __( 'Redis or Memcached (via a drop-in) reduces database load on busy sites. Optional on small sites.', 'keepwatch' ) ); return $results; } }