Before submitting an issue please check that you’ve completed the following steps:
Made sure you’re on the latest version:
Used the search feature to ensure that the bug hasn’t been reported before ✅
Describe the bug
User reports warnings like these being logged:
19-Jun-2024 22:36:05 UTC] PHP Warning: Undefined array key "returnvalue" in /home2/yosiga/public_html/wp-content/plugins/wp-rocket/inc/Engine/Common/JobManager/APIHandler/APIClient.php on line 142
Expected behavior
We should do something to protect against this like using isset(). Maybe something like:
return (array) wp_parse_args( ( $result && isset( $result['returnvalue'] ) ) ? (array) $result['returnvalue'] : [], $default );
We should also investigate how/why the $result['returnvalue'] is not set in the result.
Before submitting an issue please check that you’ve completed the following steps:
Describe the bug User reports warnings like these being logged:
19-Jun-2024 22:36:05 UTC] PHP Warning: Undefined array key "returnvalue" in /home2/yosiga/public_html/wp-content/plugins/wp-rocket/inc/Engine/Common/JobManager/APIHandler/APIClient.php on line 142
Relating to this line: https://github.com/wp-media/wp-rocket/blob/5b286ce8c571285bd0924f8f223440e7f9f4c0b4/inc/Engine/Common/JobManager/APIHandler/APIClient.php#L142
To Reproduce Steps to reproduce the behavior:
Expected behavior We should do something to protect against this like using
isset()
. Maybe something like: return (array) wp_parse_args( ( $result && isset( $result['returnvalue'] ) ) ? (array) $result['returnvalue'] : [], $default );We should also investigate how/why the $result['returnvalue'] is not set in the result.
Additional context Ticket - https://secure.helpscout.net/conversation/2630969775/498415 Slack - https://wp-media.slack.com/archives/C43T1AYMQ/p1718982063345219
Acceptance Criteria (for WP Media team use only) Clear instructions for developers, to be added before the grooming