publishpress / PublishPress-Future

This plugin was known as "Post Expirator", and now it is called "PublishPress Future".
https://wordpress.org/plugins/post-expirator/
7 stars 11 forks source link

How to handle the expiration date on status change #129

Open stevejburge opened 3 years ago

stevejburge commented 3 years ago

This one may require some careful thought:

This seems to be a new issue that started after the most recent update, just in case that helps – we’ve been using the plug in for a couple of years and it hadn’t happened before.

https://wordpress.org/support/topic/scheduled-posts-remove-expiry-date-time-when-published/

We've noticed an issue after the last update with regards to scheduled posts - if a post is scheduled to be published at a future time and you have it set to expire, the expiration date/time is cleared when the post is published meaning that the post never expires.

A less important, but possibly related issue, is that we've also noticed that when a post expires the expiration date is also removed. Obviously this isn't really a problem as the post has been unpublished, although it was nice to be able to see and sort by those times so see the ones that had recently been unpublished.

I'm guessing these two things are connected. Ie: When the post status changes (from schedule to published or published to draft) the expiration value is deleted.

See screenshot here: https://snipboard.io/eIK2FE.jpg

contactashish13 commented 3 years ago

@stevejburge

if a post is scheduled to be published at a future time and you have it set to expire, the expiration date/time is cleared when the post is published meaning that the post never expires.

I cannot replicate this. The expiration date and all associate post meta is not cleared when a scheduled post is published.

is that we've also noticed that when a post expires the expiration date is also removed

Cannot replicate this either. The expiration date and all associate post meta is not cleared when a post expires.

gjbrendeke commented 3 years ago

@contactashish13 I can replicate this issue, on a local multisite installation (running a wamp environment) with al plugins at latest version. The "postexpirator_update_post_meta" is fired when a scheduled post gets published. This will start "postexpirator_unschedule_event". I've enabled debugging and can confirm that this is the sequense of events.

contactashish13 commented 3 years ago

@gjbrendeke thanks! Can you confirm that this only happens in a multisite?

gjbrendeke commented 3 years ago

@contactashish13 Hi, for what it's worth: I've created a clean (Vagrant/VCCW based) single WordPress installation. Nothing installed, except the "Post Expirator" plugin. In this environment the expiration date/time is not removed when the post gets published.

gjbrendeke commented 3 years ago

@contactashish13 Whow, after installing the "Classic Editor" plugin the scheduled date gets deleted when a post is Published. Don't understand the code logic yet, but when using the Gutenberg blcok editor, the postexpirator_update_post_meta (hich is hooked to the save_post action) will exit due to this code: // we want to make sure we don't fire the save_post action when we are inside the block editor // but this should not stop quick/bulk edit if ( PostExpirator_Util::is_gutenberg_active() && PostExpirator_Facade::show_gutenberg_metabox() && ! isset( $_POST['expirationdate_quickedit'] ) && ! isset( $_POST['expirationdate_formcheck'] ) ) { return; } Obviously, using "classic editor" this " return" statement is not triggerd.

gjbrendeke commented 3 years ago

Solved it on my production systems: make it two seperate code blocks, one to test the "gutenberg" condition and another to test the quickedit/formcheck condition.