We were having issues with empty (un)publish dates returning "The 'publish on' value does not match the expected format of %time" errors when saving nodes programmatically.

The problem was that the values would come through as arrays, instead of strings, which would then get passed to the trim() function. This returned the string "array", instead of NULL, which would throw off _scheduler_strtotime(). It would return FALSE and throw the error, preventing a node save.

Just adding a check in _scheduler_strtotime() that the passed $str value was indeed a string fixed it. (patch attached)

scheduler_empty_dates_fix.patch456 bytesbreathingrock
Members fund testing for the Drupal project. Drupal Association Learn more


jonathan1055’s picture

Version: 6.x-1.8 » 7.x-1.0
Status: Active » Needs work

I've not replicated your error obviously because I do not have the custom code you are using to programatically save the nodes, but the change you suggest looks reasonable. In fact it may not actually require the plain $str test, just is_string($str) && trim($str) != "" may be sufficient. Would we ever get the string '0' or 'NULL' passed in?

This has to be fixed in the D7 version first, but the code lines are the same, so the patch should apply ok with an offset of ~30 lines. Do you have the means to test it in D7?


breathingrock’s picture

Sorry for the late reply.

I doubt I would be able to reproduce this behavior without porting a lot of our site to D7 first, which just isn't feasible.

But there's no doubt that that argument needs to be a string. I couldn't see the harm in making sure it is one.

Sorry I can't be of help.

szy’s picture

Version: 7.x-1.0 » 6.x-1.x-dev

6.x is the proper branch of the patch.


jonathan1055’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

Hi szy.
Yes the patch was made against the D6 scheduler but we have to correct the D7 version first. Only then, can we port the fix back to D6. Otherwise we risk the correction being lost when you upgrade to D7.
As per my comment, the patch should work in both versions.

szy’s picture

I've changed the version, because when searching issues
for 6.x with the word 'empty', this thread isn't shown.


jonathan1055’s picture

Status: Needs work » Fixed


This has been fixed in a slightly different way in #1319410: Fix "warning: trim() expects parameter 1 to be string" when entering date with no time - read from #15 onwards. The function scheduler_node_validate() will no longer call _scheduler_strtotime() if $node->publish_on is still an array. So your problem should be fixed in 7.x

You are welcome to re-open this issue if you are still having problems, or if you need that patch ported to 6.x


Status: Fixed » Closed (fixed)

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