Webfinger info: avoid PHP warning when user isn't defined

This should avoid warnings like this one:

```
PHP Warning:  Attempt to read property "user_login" on bool in /var/www/html/wp-content/plugins/activitypub/includes/class-webfinger.php on line 27
```
This commit is contained in:
Jeremy Herve 2023-04-10 13:10:46 +02:00
parent abef17b9ad
commit 643c47dcb7
No known key found for this signature in database
GPG key ID: EF65CC7D9AC11920

View file

@ -23,6 +23,9 @@ class Webfinger {
} }
$user = \get_user_by( 'id', $user_id ); $user = \get_user_by( 'id', $user_id );
if ( ! $user ) {
return '';
}
return $user->user_login . '@' . \wp_parse_url( \home_url(), \PHP_URL_HOST ); return $user->user_login . '@' . \wp_parse_url( \home_url(), \PHP_URL_HOST );
} }