Run wp shell and call the function with an invalid post ID: \Distributor\Utils\prepare_meta('bug');
Open the debug.log file in your wp-content directory and observe the no warning is thrown: PHP Warning: Invalid argument supplied for foreach() in .../includes/utils.php on line 427
Changelog Entry
Fixed - PHP warning about invalid argument supplied for foreach in \Distributor\Utils\prepare_meta()
Description of the Change
Validate the return value of get_post_meta and make sure it is array.
Closes #1107
How to test the Change
wp shell
and call the function with an invalid post ID:\Distributor\Utils\prepare_meta('bug');
debug.log
file in yourwp-content
directory and observe the no warning is thrown:PHP Warning: Invalid argument supplied for foreach() in .../includes/utils.php on line 427
Changelog Entry
Credits
Props @dhanendran
Checklist: