Validation of publish-on and unpublish-on is now not working (for me) and for every date I enter I get the constraint message saying the date must be in the future. This is odd, as I don't know what has changed to cause it.
I added debug to SchedulerPublishOnConstraintValidator
and for manual editing of a node it shows:
$publish_on: 2016-01-26T01:39:00 = not a number
REQUEST_TIME: 1453111532 = Monday, 18 January, 2016 - 10:05:32
and I get the errors
The 'publish on' date must be in the future.
This value should be a valid number.
However, in the automated tests, the same debug shows:
$publish_on: 1453114152 = Monday, January 18, 2016 - 21:49
REQUEST_TIME: 1453110557 = Monday, January 18, 2016 - 20:49
so it is working OK in tests.
What can have caused the date to be returned in the form with the universal timestamp format instead of the unix number we used to have? The constraint is evaluating 2016 against 1453111532 and deducing that it is in the past.
I realise that this might be something in my own setup, but I don't think I have not installed any new modules or changed any config. With this error happening I cannot do any proper manual testing because I cannot save any nodes which are scheduled. I hope someone has an idea ...
Comment | File | Size | Author |
---|---|---|---|
#3 | field widget WRONG after re-install.png | 127.78 KB | jonathan1055 |
#3 | field widget OK when scheduler first installed.png | 84.33 KB | jonathan1055 |
#2 | manage form display.jpg | 89.56 KB | jonathan1055 |
Comments
Comment #2
jonathan1055 CreditAttribution: jonathan1055 commentedI have found the reason for the error, but not the solution (yet). The form widget for the publish-on and unpublish-on fields were set to the standard 'Datetime Timestamp' whereas they should have been Schedulers custom 'Datetime Timestamp no default' widget. This can be seen in Content Type - Manage Fields - Manage Form Display (image attached). After manually changing back to the correct widget everything works fine because in scheduler\Plugin\Field\FieldWidget\TimestampDatetimeNoDefaultWidget we convert the datetime object to a numeric timestamp. This is not done in the plain 'Datetime Timestamp' widget, hence the error I was getting.
Now we need to discover why the settings changed. I think it is most likely due to an uninstall of Scheduler followed by a reinstall. But we should be able to set the correct widget when re-installing, as that is going to be something that our users may well do. The field widget type is defined in hook_entity_base_field_info() so maybe after a re-install the process is slightly different and this does not get executed because the fields pre-existed? The widget definitely gets reset to 'Datetime Timestamp' when Scheduler is uninstalled (I have checked that) but they are not restored to 'Datetime Timestamp no default' after re-installing the module. On a clean install, as is done during the automated testing, I would guess that the widget is correctly set via hook_entity_base_field_info() and everything works fine.
By the way, we might consider renaming the widget to something like 'Datetime Timestamp for Scheduler' as that would mean far more when looking at the choices of widgets. 'Datetime Timestamp no default' may mean something to us developers who know the code, but the users will not realise what it is or where it has come from. But that's another thing. For now, we need to work out how to get the correct widget settings when reinstalling the module.
Comment #3
jonathan1055 CreditAttribution: jonathan1055 commentedI think this is going to cause our users a few problems during site set-up, and we will keep seeing support issues being raised about it. Just to confirm the repo steps:
What this means if any admin/site builder reinstalls Scheduler it will not work correctly. Entering any scheduler date will continually fail validation.
Comment #4
jonathan1055 CreditAttribution: jonathan1055 commentedCore issue #2754477: Unexpected config entity delete due to dependency calculations solves the problem! I had a hunch that this was not the fault of any Scheduler code. I have just checked the steps in #3 and the config is uninstalled cleanly with the patch (which did not happen before). It is much better now - the re-install sets the correct widget and everything works as expected.
Leaving this issue open (but postponed) and will close when #2754477: Unexpected config entity delete due to dependency calculations is fixed.
Comment #5
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedClosed as #2754477: Unexpected config entity delete due to dependency calculations has been committed to core 8.2 and 8.1