Skip to content

Commit b7c0e01

Browse files
authored
Fix the health check (#481)
* only test author urls if authors are enabled * if authors are disabled use the blog user to test webfinger
1 parent 336f3e5 commit b7c0e01

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

includes/class-health-check.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
use WP_Error;
55
use Activitypub\Webfinger;
6+
use Activitypub\Collection\Users;
67

78
use function Activitypub\get_plugin_version;
9+
use function Activitypub\is_user_type_disabled;
810
use function Activitypub\get_webfinger_resource;
911

1012
/**
@@ -25,10 +27,12 @@ public static function init() {
2527
}
2628

2729
public static function add_tests( $tests ) {
28-
$tests['direct']['activitypub_test_author_url'] = array(
29-
'label' => \__( 'Author URL test', 'activitypub' ),
30-
'test' => array( self::class, 'test_author_url' ),
31-
);
30+
if ( ! is_user_type_disabled( 'user' ) ) {
31+
$tests['direct']['activitypub_test_author_url'] = array(
32+
'label' => \__( 'Author URL test', 'activitypub' ),
33+
'test' => array( self::class, 'test_author_url' ),
34+
);
35+
}
3236

3337
$tests['direct']['activitypub_test_webfinger'] = array(
3438
'label' => __( 'WebFinger Test', 'activitypub' ),
@@ -253,8 +257,15 @@ public static function is_author_url_accessible() {
253257
* @return boolean|WP_Error
254258
*/
255259
public static function is_webfinger_endpoint_accessible() {
256-
$user = \wp_get_current_user();
257-
$account = get_webfinger_resource( $user->ID );
260+
$user = \wp_get_current_user();
261+
262+
if ( ! is_user_type_disabled( 'blog' ) ) {
263+
$account = get_webfinger_resource( $user->ID );
264+
} elseif ( ! is_user_type_disabled( 'user' ) ) {
265+
$account = get_webfinger_resource( Users::BLOG_USER_ID );
266+
} else {
267+
$account = '';
268+
}
258269

259270
$url = Webfinger::resolve( $account );
260271
if ( \is_wp_error( $url ) ) {

0 commit comments

Comments
 (0)