distributor
distributor copied to clipboard
Check return value of get_post_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
- Enable debug logging in wp-config
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
- Run
wp shelland call the function with an invalid post ID:\Distributor\Utils\prepare_meta('bug'); - Open the
debug.logfile in yourwp-contentdirectory 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()
Credits
Props @dhanendran
Checklist:
- [x] I agree to follow this project's Code of Conduct.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my change.
- [ ] All new and existing tests pass.