indieweb / indieweb/wordpress-indieweb

Undefined array key in class-hcard-user.php on line 215

Open
#282 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
83
Forks
18
Avg merge
1h 13m
Merged PRs (30d)
1

Description

I've been seeing a lot of this big ol' chungus of an error in my PHP logs.

Got error 'PHP message: PHP Warning: Undefined array key "id" in [snip]/public_html/wp-content/plugins/indieweb/includes/class-hcard-user.php on line 215; PHP message: PHP Fatal error: Uncaught TypeError: array_values(): Argument #1 ($array) must be of type array, false given in [snip]/public_html/wp-content/plugins/indieweb/includes/class-hcard-user.php:215\nStack trace:\n#0 /[snip]/public_html/wp-content/plugins/indieweb/includes/class-hcard-user.php(215): array_values(false)\n#1 /[snip]/public_html/wp-includes/rest-api/endpoints/class-wp-rest-controller.php(439): HCard_User::{closure:HCard_User::rest_fields():214}(Array, 'me', Object(WP_REST_Request), 'user')\n#2 /[snip]/public_html/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php(1122): WP_REST_Controller->add_additional_fields_to_object(Array, Object(WP_REST_Request))\n#3 /[snip]/public_html/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php(519): WP_REST_Users_Controller->prepare_item_for_response(Object(WP_User), Object(WP_REST_Request))\n#4 [snip]...

Contributor guide

Open the contributing guide

Research direction

Start in includes/class-hcard-user.php at line 215 and inspect the rest_fields callback shown in the stack trace, then trace the WordPress REST users response that supplies the user data. Reproduce the warning and fatal error through the users endpoint, and consider the issue done when the response no longer triggers either error, with a regression test covering the missing id case.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.