*/ const END_OF_SECURITY_SUPPORT = array( '7.0' => '2019-01-10', '7.1' => '2019-12-01', '7.2' => '2020-11-30', '7.3' => '2021-12-06', '7.4' => '2022-11-28', '8.0' => '2023-11-26', '8.1' => '2025-12-31', '8.2' => '2026-12-31', '8.3' => '2027-12-31', '8.4' => '2028-12-31', '8.5' => '2029-12-31', ); /** * Oldest branch that is supported for more than WARN_DAYS, i.e. a sensible upgrade target. * * @param int $now Current Unix timestamp. * @return string */ public static function recommended( int $now ): string { foreach ( array_keys( self::END_OF_SECURITY_SUPPORT ) as $branch ) { if ( self::SUPPORTED === self::evaluate( (string) $branch, $now )['status'] ) { return (string) $branch; } } return (string) array_key_last( self::END_OF_SECURITY_SUPPORT ); } /** * Evaluates a PHP version. * * @param string $version PHP version, e.g. PHP_VERSION. * @param int $now Current Unix timestamp. * @return array{status: string, branch: string, end: string, days_left: int} */ public static function evaluate( string $version, int $now ): array { $branch = WpVersions::major( $version ); $end = self::END_OF_SECURITY_SUPPORT[ $branch ] ?? ''; if ( '' === $end ) { // Branches newer than the table are fine, older ones are long unsupported. $status = self::UNKNOWN; if ( '' !== $branch ) { $newest = (string) array_key_last( self::END_OF_SECURITY_SUPPORT ); $status = version_compare( $branch, $newest, '>' ) ? self::SUPPORTED : self::ENDED; } return array( 'status' => $status, 'branch' => $branch, 'end' => '', 'days_left' => 0, ); } // End of day UTC. $end_ts = (int) strtotime( $end . ' 23:59:59 UTC' ); $days_left = (int) floor( ( $end_ts - $now ) / 86400 ); if ( $end_ts < $now ) { $status = self::ENDED; } elseif ( $days_left <= self::WARN_DAYS ) { $status = self::ENDING; } else { $status = self::SUPPORTED; } return array( 'status' => $status, 'branch' => $branch, 'end' => $end, 'days_left' => $days_left, ); } }