Invalid argument supplied for foreach()
Closed this issue · 1 comments
Bug Report
PHP Warning: Invalid argument supplied for foreach() in /srv/www/example.com/releases/20191210030834/web/wp/wp-includes/rest-api/endpoints/class-wp-rest-controller.php on line 295
Warning: Invalid argument supplied for foreach() in /srv/www/example.com/releases/20191210030834/web/wp/wp-includes/rest-api/endpoints/class-wp-rest-controller.php on line 295
Executed the cron event 'recovery_mode_clean_expired_keys' in 0.008s.
Executed the cron event 'action_scheduler_run_queue' in 0.012s.
Executed the cron event 'calderawp_calderaforms_cf2_jobs_databaseconnection' in 0.025s.
Success: Executed a total of 3 cron events.
Is your bug report directly related to a specific command?
wp cron event run --due-now
Are you unsure about what repository to post the bug report into?
Just head over to the wp-cli/wp-cli
repository and create a new issue in that repository. The maintainers can still move the bug report into the correct repository later on.
--- ✅ If you are in the correct location now... --->
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
PHP warnings when invoking that WP CLI core command (each time, also for subsequent times).
Describe how other contributors can replicate this bug
The warning is emitted when triggering the WordPress cron (roots.io Trellis with a Bedrock WordPress site; system cron job) and checking the output. It doesn't seem to cause other problems, but I don't like PHP warning messages in command output.
Describe what you would expect as the correct outcome
No PHP warnings when the WP CLI cron command is used.
Let us know what environment you are running this on
OS: Linux 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php7.3
PHP version: 7.3.12-1+ubuntu18.04.1+deb.sury.org+1
php.ini used: /etc/php/7.3/cli/php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /srv/www/example.com/releases/20191210030834
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config: /srv/www/example.com/releases/20191210030834/wp-cli.yml
WP-CLI version: 2.2.0
Provide a possible solution
Probably just adding some check for a variable being set and an array in a foreach loop.
But maybe there is a deeper issue that should also be resolved?
Thanks for the report, @strarsis !
It seems like some of the underlying data was corrupt. Were you able to debug this further?