From 034ba0554d40343010a787d8093410500b110bf9 Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Thu, 15 Dec 2022 11:37:00 +0100 Subject: [PATCH] Don't access transient when receiving a WP_Error --- includes/functions.php | 4 ++++ integration/class-friends-feed-parser-activitypub.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/functions.php b/includes/functions.php index 24ebea8..1abb9d1 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -118,6 +118,10 @@ function get_remote_metadata_by_actor( $actor ) { return null; } + if ( is_wp_error( $actor ) ) { + return $actor; + } + $metadata = \get_transient( 'activitypub_' . $actor ); if ( $metadata ) { diff --git a/integration/class-friends-feed-parser-activitypub.php b/integration/class-friends-feed-parser-activitypub.php index 294285a..981c9f4 100644 --- a/integration/class-friends-feed-parser-activitypub.php +++ b/integration/class-friends-feed-parser-activitypub.php @@ -68,7 +68,7 @@ class Friends_Feed_Parser_ActivityPub extends \Friends\Feed_Parser { */ public function update_feed_details( $feed_details ) { $meta = \Activitypub\get_remote_metadata_by_actor( $feed_details['url'] ); - if ( ! $meta && is_wp_error( $meta ) ) { + if ( ! $meta || is_wp_error( $meta ) ) { return $meta; }