Skip to content

Commit

Permalink
Uncaught PHP error in the admin fix #998
Browse files Browse the repository at this point in the history
  • Loading branch information
zahardev committed Mar 15, 2023
1 parent fbbbe52 commit 19d32e5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions php/classes/handlers/class-admin-notifications-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace SeriouslySimplePodcasting\Handlers;

use SeriouslySimplePodcasting\Interfaces\Service;
use SeriouslySimplePodcasting\Repositories\Episode_Repository;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 19d32e5

Please sign in to comment.