I have used this module on a couple of sites, and it just now came to my attention that it stopped working at some point. I'm not sure if it's when this module was upgraded, or Drupal core was but, no matter what date or time I put in, I get the error: "'unpublish on' value does not match the expected format." The module is using the default date format with no changes and I still get this error. I've looked through the forum and none of the advice seems to work for me. I even tried using the most recent dev version, to no avail. Any help would be much appreciated!
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | _1804508_20.cleanup_whitespace_in_format.d6.patch | 1.16 KB | jonathan1055 |
| #14 | 1804508_14.scheduler.cleanup_whitespace_in_format.patch | 467 bytes | jonathan1055 |
| #6 | _scheduler.1854388_6.cleanup_whitespace_in_format.patch | 771 bytes | jonathan1055 |
Comments
Comment #1
jonathan1055 commentedHi,
A few questions to get things started:
1. What Drupal version are you using?
2. Can you show us a screen shot of the form item when you get the error. In particular, what does it show as the example date format beneath the text entry box?
3. Are you using the popup date calendar or just plain text entry?
4. Do you have scheduled publishing enabled?
5. If the amswer to 4 is yes, then does this error happen for that field too?
Jonathan
Comment #2
lebachai commentedHi Jonathan,
HTH!
Comment #3
jonathan1055 commentedHello,
I think I can see your problem, and I have even replicated it myself. In your first screenshot, when you set the date format in admin/settings, I noticed a rather large gap between the i and the a. I think you have two spaces or more in there. I have just tested that theory, and the code (currently) does not do anything special with spaces, so if you enter the time with only one space between the minutes and the 'am' it complains! I set my format to have two spaces, entered the time with only one space between, and got your error. Then I added an extra space and the time was accepted.
Can you verify that this is the cause of your problem? Obviously we will need to make a slight fix to the code to cater for this, as it is not very user-friendly. Maybe always reduce multiple spaces to one space in the admin format setting, and likewise on the text entry. But first, if you can confirm that this is the fault, at least we know what the cause is.
Jonathan
ps. Fixed the title because it was 'Publish on' not 'Unpublish on' for which you had the problem.
Comment #4
lebachai commentedI think you nailed it. I just added the extra space when setting the "Publish on" time, and there was no error. Thanks so much for digging into this one--just another proof that an extra pair of eyes is important. I do hope you'll add something in a future version to check for the extra space but, meanwhile, I believe the module is back in business!
Comment #5
jonathan1055 commentedThat's good.
Instead of adding the extra space when entering the date and time, you could remove the extra space in the admin settings, then you would not need to remember to keep adding it.
We will alter the code to eliminate this little difficulty.
Jonathan
Comment #6
jonathan1055 commentedHere is a patch which adjusts the date format in scheduler_admin_validate() before it is saved. Multiple whitespaces (including tabs and newlines) are replaced by a single space. Just for good measure the value is also trimmed for leading or trailing spaces. The new line is:
Jonathan
Comment #7
lebachai commentedWill try this, thanks!
Comment #8
jonathan1055 commentedThe patch was made against D7 code, but the source for this bit is identical in D6. So it should apply ok, just with a note about offset lines.
Comment #9
jonathan1055 commentedHi lebachai,
Did you manage to try the patch? I'm reasonably happy with it, and have tested it with all manner of multiple spaces and tabs, but would be good if Eric or Rick (or anyone) would confirm it works and mark it RTBC.
Thanks
Jonathan
Comment #10
lebachai commentedSorry, I haven't been able to. Perhaps someone else can review it?
Comment #11
rickmanelius commentedI can confirm this works as expected. Setting to RBTC
Comment #12
rickmanelius commentedCommitted http://drupalcode.org/project/scheduler.git/commit/261820c
Comment #13
jonathan1055 commentedI was about to create a patch to port this to D6, but it occurred to me that maybe we should also do the same treatment of removing multiple spaces in the values entered by the user. The input value is trimmed, which does half the job of the change we made in #6. But I think we should match the tidying up just like when the admin specifies the format.
This could be done in _scheduler_strtotime() so that:
becomes
What do you think?
Comment #14
jonathan1055 commentedHere is a patch which makes the additional change in #13.
Comment #15
jonathan1055 commentedI know it is bad form to mark one's own patch as tested, but the additional change in the patch in #14 is really exactly the same as the change already committed in #12
No-one else around here is doing any testing and I really want to get some of these 'needs review' issues ready for the next batch of commits. The open issue queue is now down to 50, the lowest it has been for a few years. At least we can now see all issues on the one page :-)
Jonathan
Comment #16
ericclaeren commentedThis might be related with this issue, I'm getting an error on submitting the date without a time:
Warning: trim() expects parameter 1 to be string, array given in _scheduler_strtotime() (line 482 of /modules/contrib/scheduler/scheduler.module).
I did apply this patch to test if it might do something with this error but that was not the case.
Comment #17
jonathan1055 commentedHi Dreamlabs,
No that is not related to this issue. See #1319410: Fix "warning: trim() expects parameter 1 to be string" when entering date with no time which was fixed in the latest dev version on 27th July and will be in the 7.x-1.2 release.
Seeing as you have applied this patch, could you test and confirm it, please? ;-)
Jonathan
Comment #18
ericclaeren commentedHi Jonathan,
Thanks for your reply, The patch in https://drupal.org/node/1319410#comment-7368706 did work for me. Thanks!
Comment #19
rickmanelius commentedCommitted: http://drupalcode.org/project/scheduler.git/commitdiff/7ea9b0e
Comment #20
jonathan1055 commentedGiven that issue was originally reported in D6, here is a patch for exactly the same fixes as done in #12 and #19 above. The patch is against 6.x-1.9+4 of 28th July.
The fix was confirmed by the original poster, and I have just tested it again, hence marking this RTBC for D6
Jonathan
Comment #21
pfrenssenGreat, thanks! Committed 7cdb376.