Hi. Thank you for great module with so many options included.

We need to keep unpublish_on date all time, to know when a node has been unpublished.
However the field is flushed every time when a node is unpubleshed by scheduler module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

AlexKirienko’s picture

Assigned: AlexKirienko » Unassigned
Status: Active » Needs review
FileSize
3.11 KB

Please check attached patch.

What was changed:
- "Keep unpublish date after unpublishing" option was added in Unpublishing fieldset on content type edit form.
- _scheduler_unpublish() will select only published nodes from db.
- new option checking on unpublishing before removing unpublish_on
- validation for unpublish_on

New option enabled:
- unpublish_on will be kept after unpublishing process.
- no unpublish_on < REQUEST_TIME validation errors for unpublished nodes.
- validation errors if user try to publish node with unpublish_on < REQUEST_TIME

mrded’s picture

Issue summary: View changes
jonathan1055’s picture

Thanks for the patch but I think it is unlikely that we'll change the fundamental way that Scheduler works in 7.x. Too many other things may be relying on the date being removed from the table and the node.

Have you considered storing the date in a custom field? It is very easy to do with Rules, reacting on when Scheduler unpublishes the node to populate your field. I have provided an example in #2492755: Save scheduling date after publishing

AlexKirienko’s picture

Hi, @jonathan1055.

Thank you for replay. We display unpublished date in views with statistic data. With custom field we will need to update all views. We also will need update all existing nodes to save date to new field.

This patch does not change functionality of module. It adds option to save publish date. By default this option disabled.
We use this patch on production site since February. It works great and not affect default functionality.

if you did not agree to add

$query->condition('n.status', NODE_PUBLISHED);

It can be also add as option.

SocialNicheGuru’s picture

I am not sure if this is a bug or feature request but It has to do with this patch. I think.
https://www.drupal.org/node/2701923

I set the time for my content time to be unpublished.
The time passes.
I go back and edit it.
I get this error and cannot save: The 'unpublish on' date must be in the future

I should get a warning instead and be allowed to save the node.

jonathan1055’s picture

The situation you describe in #5 is only marginally related to #2701923: Give warning not an error for unpublish date in the past.

And please, there is no need to post your same problem in two issues. We monitor this queue very ferquently, so it is unlikely we would miss the issue. So please do not make work by posting things twice :-)

jonathan1055’s picture

Status: Needs review » Closed (works as designed)

Hi AlexKirienko,
In reply to #4, I understand your scenario, but this is a fairly marginal case. No other users have wanted this, and as I said before it is a fundamental change to how Scheduler operates, which could well cause us more problems if we implemented this option. The list of scheduled content would also need to be changed. Other users' views would suddenly start showing more content, and that could break existing sites.

I am pleased that you are using your patch sucessfully in production. As I mentioned, you could also use something like the example with rules in #2492755-6: Save scheduling date after publishing. Yes, you would have to update your existing content, but that is only a one-off, and not too difficult. You could also use the Scheduler API functions to react when a node is unpublished.

I am closing this issue now, but I thank you for your comments and ideas for Scheduler, and please do not hesitate to open new issues, we are always happy to help.

Jonathan