From 19d32e5a3e22afe6abff5869f9a845a5d14e01b4 Mon Sep 17 00:00:00 2001 From: Sergey Zakharchenko Date: Wed, 15 Mar 2023 09:46:41 +0000 Subject: [PATCH] Uncaught PHP error in the admin fix #998 --- php/classes/handlers/class-admin-notifications-handler.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/php/classes/handlers/class-admin-notifications-handler.php b/php/classes/handlers/class-admin-notifications-handler.php index dc36a044..e662a329 100644 --- a/php/classes/handlers/class-admin-notifications-handler.php +++ b/php/classes/handlers/class-admin-notifications-handler.php @@ -3,7 +3,6 @@ namespace SeriouslySimplePodcasting\Handlers; use SeriouslySimplePodcasting\Interfaces\Service; -use SeriouslySimplePodcasting\Repositories\Episode_Repository; // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { @@ -157,11 +156,11 @@ protected function is_nginx() { $server_type = get_transient( 'ssp_server_type' ); if ( ! $server_type ) { $response = $this->get_response( site_url( '/test.mp3' ) ); - $server = $response->get_headers()->offsetGet( 'server' ); + $server = $response ? $response->get_headers()->offsetGet( 'server' ) : ''; $server_type = false !== strpos( $server, 'nginx' ) ? 'nginx' : $server; - set_transient( 'ssp_server_type', $server_type, WEEK_IN_SECONDS ); + set_transient( 'ssp_server_type', $server_type, DAY_IN_SECONDS ); } return 'nginx' === $server_type; @@ -190,7 +189,7 @@ protected function get_host( $url ) { protected function get_response( $url ) { $res = wp_remote_head( $url ); - if ( ! isset( $res['http_response'] ) || ! $res['http_response'] instanceof \WP_HTTP_Requests_Response ) { + if ( ! is_array( $res ) || ! isset( $res['http_response'] ) || ! $res['http_response'] instanceof \WP_HTTP_Requests_Response ) { return null; }