From b8216dee2ad2e14c665210f23cd4e99fc12626e4 Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Fri, 3 Oct 2025 13:59:40 +0300 Subject: [PATCH 1/2] Fix null check in comment author URL retrieval Previously, the method assumed the comment object was always present, which could lead to errors. Added a null check to ensure a fallback to the original URL if the comment object is absent. --- includes/frontend/class-user-profile.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/frontend/class-user-profile.php b/includes/frontend/class-user-profile.php index 5a155640..b1b1381a 100644 --- a/includes/frontend/class-user-profile.php +++ b/includes/frontend/class-user-profile.php @@ -87,14 +87,18 @@ if ( ! class_exists( 'um\frontend\User_Profile' ) ) { /** * Retrieves the user profile URL for the given comment author. * - * @param string $comment_author_url The URL of the comment author. - * @param int $comment_id The ID of the comment. - * @param WP_Comment $comment The comment object. + * @param string $comment_author_url The URL of the comment author. + * @param int $comment_id The ID of the comment. + * @param WP_Comment|null $comment The comment object. * * @return string The user profile URL for the comment author. */ public function change_comment_author_url( $comment_author_url, $comment_id, $comment ) { - return um_user_profile_url( $comment->user_id ); + if ( ! is_null( $comment ) ) { + return um_user_profile_url( $comment->user_id ); + } + + return $comment_author_url; } } } From a33be50a5584d1e23056111afac31afa606831ab Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Tue, 7 Oct 2025 11:56:25 +0300 Subject: [PATCH 2/2] Fix user profile URL logic for comment authors Previously, the profile URL was returned even when the user ID was empty. This change ensures the URL is only generated if the user ID is present, preventing potential errors. --- includes/frontend/class-user-profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/frontend/class-user-profile.php b/includes/frontend/class-user-profile.php index b1b1381a..14a0fca5 100644 --- a/includes/frontend/class-user-profile.php +++ b/includes/frontend/class-user-profile.php @@ -94,7 +94,7 @@ if ( ! class_exists( 'um\frontend\User_Profile' ) ) { * @return string The user profile URL for the comment author. */ public function change_comment_author_url( $comment_author_url, $comment_id, $comment ) { - if ( ! is_null( $comment ) ) { + if ( ! is_null( $comment ) && ! empty( $comment->user_id ) ) { return um_user_profile_url( $comment->user_id ); }