After re-installing the module, the widgets for the datetime fields are not set to the correct Scheduler-provided widgets 'Datetime Timestamp for Scheduler'. The fields revert to the core widget which provides a default of "now" if no date is entered. This causes the wrong behavior when saving a node edit form. To allow quick and simple diagnosis of this fault a warning can be given explaining how to fix the problem.


Original

The expected behavior of "Save and keep published" is to take no action on changing the status of the node.

When using "Save and keep published" with scheduler enabled, what actually happens is the node becomes unpublished and scheduled for publishing now.

This is not as innocuous as is sounds, because it will only become published again after the site cron or scheduler lightweight cron runs, making the published node disappear for some time. Really bad if your promoted front-page is updated. This problem can occur because the publish_on value will default to now on a published node, even if a value is not specified (or explicitly cleared from the form).

Comments

jdillick created an issue. See original summary.

jdillick’s picture

Particularly when the content type has deselected the "Require scheduled publishing" option, I think the preferred behavior also might be for a "Save and Publish" action to immediately publish the node without scheduling a publish.

jonathan1055’s picture

Hello jdillick,
Thanks for posting and sorry to hear you have a problem. However, I need more info to fully understand your problem. When you say "with scheduler enabled, what actually happens is the node becomes unpublished and scheduled for publishing now" Scheduler will only do anything if a date has been entered in the 'Publish On' date entry field.

If the date is the in future then I don't think there is a problem, as by definition the node should not be published at the moment and only published when the time passes.

Or, if you are entering a date in the past you must also have selected one of the 'past date' advanced options in the content type. This will control what Scheduler does during the node save, either publish immediately or via the next cron. If you do not want to allow past dates to be entered then select the first radio option.

Hope that helps.

Jonathan

jdillick’s picture

Hi Jonathan,

Thanks for the reply. In your response was a clue to the cause of the problem: Looks like for the content type where this problem was occurring, the publish_on field widget was set accidentally to "Date Timestamp" instead of "Date Timestamp with no default".

Turns out that if there is a default publish_on timestamp, no matter what, even if you unset the default date in the node edit form, it will apply a default value of NOW, always preventing manual publishing.

Switching the publish_on field widget back to "Date Timestamp with no default" seems to fix the problem. I might still consider this a minor bug if I were you. Perhaps preventing a default value for these two fields would be wise (if possible), or determine if the value is being set in the form.

Hope that makes sense.

Regards,

John

jdillick’s picture

Title: Saving already published node unpublishes and schedules the node for publishing now » "Date Timestamp" field widget causes published nodes to unpublish on update.
Priority: Critical » Minor
jdillick’s picture

Issue summary: View changes
jonathan1055’s picture

Ah, that makes sense and explains the problem. The widget label has been improved, see #2807081: Better label for TimestampDatetimeNoDefault widget so I have altered the text you added in the summary. However, you won't see that change until 1.0-alpha3 is released.

If the wrong widget is set, I'll have a think to see if that can be detected and a warning given.

Thanks for your feedback.

jonathan1055’s picture

Title: "Date Timestamp" field widget causes published nodes to unpublish on update. » Detect when wrong "Date Timestamp" field widget is selected
Category: Bug report » Feature request

Changing the title to reflect the new aim of this issue.

jonathan1055’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new105.71 KB
new2.26 KB

I worked out how to detect which widget is assigned to the form fields. Here's a patch which gives a warning message and a link to the content type 'Manage Form Display' tab for an admin to fix the problem.
warning for wrong widget

Interesting, for the link I wanted to use the preferred function Url::fromRoute('route.to.the.page') instead of hard-coding the url part. But I discovered that the route for url '/admin/structure/types/manage/{node_type}/form-display' has not been included in the core node.routing.yml file. I think this must be an oversight and there is no reason why it should not be added to that file. I have started a discussion before raising an issue in the core queue.

So for now, this patch adds the missing route (using our own scheduler.routing.yml file)

Status: Needs review » Needs work

The last submitted patch, 9: 2848213-9.warning-for-wrong-widget.patch, failed testing.

jonathan1055’s picture

Title: Detect when wrong "Date Timestamp" field widget is selected » Give warning when wrong datetime field widget is set
Priority: Minor » Normal
Status: Needs work » Needs review
StatusFileSize
new2.26 KB

My fault. Blank line in patch. Try again

jonathan1055’s picture

StatusFileSize
new2.39 KB

Patch re-rolled following the changes in #2861902: Fix coding standards violations in 8.x codebase

  • jonathan1055 committed 5524e17 on 8.x-1.x
    Issue #2848213 by jonathan1055: Give warning when wrong datetime field...
jonathan1055’s picture

I have raised core issue #2865983: Add missing route for /admin/structure/types/manage/{node_type}/form-display to add the missing route, but in the meantime (as that may take ages to be committed, or may be rejected) I have added the route into scheduler.routing.yml, with a @todo to remove it if/when it gets into core.

jonathan1055’s picture

Status: Fixed » Needs review
StatusFileSize
new2.54 KB

The route is provided in core, by field_ui module, but as it is dynamic it is not contained in any routing.yml files hence I did not know it existed.

  • jonathan1055 committed 018e108 on 8.x-1.x
    Issue #2848213 by jonathan1055: Warning for wrong datetime field widget...
jonathan1055’s picture

Status: Needs review » Fixed

This has turned out to be useful in another way, as we probably should have had field_ui module as a requirement anyway. In the standard profile it is loaded by default so mostly we would not have noticed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.