wp-media / wp-rocket

Performance optimization plugin for WordPress
https://wp-rocket.me
GNU General Public License v2.0
700 stars 218 forks source link

PHP Warning: Undefined array key "returnvalue" #6735

Open joejoe04 opened 4 months ago

joejoe04 commented 4 months ago

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:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

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

sandyfigueroa commented 4 months ago

Related: https://secure.helpscout.net/conversation/2649637415/502193/