self::MAX_PATH_LENGTH || self::is_declared_bot( $user_agent ) ) { return false; } foreach ( self::SERVICE_PREFIXES as $prefix ) { if ( $path === $prefix || 0 === strpos( $path, $prefix . '/' ) ) { return false; } } // Feeds: /feed, /category/x/feed, /post/feed/atom ... if ( preg_match( '#(^|/)feed(/|$)#', $path ) ) { return false; } $extension = strtolower( pathinfo( $path, PATHINFO_EXTENSION ) ); return ! in_array( $extension, self::SKIPPED_EXTENSIONS, true ); } /** * Which row is least worth keeping when the log is full: the one asked * for least often, and among those the one not seen for longest. * * @param array $rows Log rows. * @return int|null ID of the row to evict, null for an empty list. */ public static function eviction_candidate( array $rows ): ?int { if ( array() === $rows ) { return null; } usort( $rows, static function ( array $a, array $b ): int { return array( (int) $a['hits'], (string) $a['last_seen'] ) <=> array( (int) $b['hits'], (string) $b['last_seen'] ); } ); return (int) $rows[0]['id']; } }