ivankruchkoff / wp-expiring-posts

GNU General Public License v2.0
2 stars 9 forks source link

Fix for warnings in expiring-posts.php #8

Open lgedeon opened 4 years ago

lgedeon commented 4 years ago

We were seeing thousands of the following error on a WordPress VIP client's site: Warning: implode(): Argument must be an array in /expiring-posts/expiring-posts.php on line 91

The PR https://github.com/ivankruchkoff/wp-expiring-posts/pull/7 fixed the error locally. We would like to add this into the next version of the plugin.

Line numbers may not match exactly because of version differences. This is the line that triggered the error:

$expiry_time = implode( get_post_meta( $post->ID, 'exp_expiration_date' ) );

On this line, get_post_meta() was failing when the global $post was not set, which in turn triggered the warning on implode().

WPprodigy commented 4 years ago

Also noting that it could be an improvement to use the third paramater in get_post_meta() as well: https://developer.wordpress.org/reference/functions/get_post_meta/

Then it will be returned as a string and not as an array that needs to be imploded.