Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
_scheduler_strtotime() throws a trim error from node_presave when one of the fields is not set.
Steps to recreate:
- Using Datepicker Popup
- Create a scheduled node
- Fill in published time
- Save Node
The error is then thrown when the scheduler_node_presave cycles through to the unpublished_on value in the elseif because that value is an array
foreach (array('publish_on', 'unpublish_on') as $key) {
if (empty($node->$key)) {
// Make sure publish_on and unpublish_on are not empty strings.
$node->$key = 0;
}
elseif (!is_numeric($node->$key)) {
dpm($node->$key, $key);
// Convert to unix timestamp, but ensure any failure is converted to zero.
$node->$key = _scheduler_strtotime($node->$key) + 0;
}
}
This was fixed in other places in #1319410: Fix "warning: trim() expects parameter 1 to be string" when entering date with no time but is still an issue in this spot of the code.
Comment | File | Size | Author |
---|---|---|---|
#3 | scheduler-trim-error-2205809-3.patch | 491 bytes | arcaneadam |
Comments
Comment #1
arcaneadam CreditAttribution: arcaneadam commentedComment #2
arcaneadam CreditAttribution: arcaneadam commentedPatch coming...
Comment #3
arcaneadam CreditAttribution: arcaneadam commentedI tracked the error down and realize that it is because of a setting in the Scheduler Workbench module that sets #access on the unpublish_on field to FALSE. This then prevents input in that field which causes it to return as an array rather then a string that is expected.
Since this is something that could be caused by anyone doing a pretty standard form_alter procedure to hide a field, it should probably be taken into account. At the very least should someone else have this problem I'd like them to have a patch available for it.
Comment #4
jonathan1055 CreditAttribution: jonathan1055 commentedHi arcaneadam,
Thanks for the diagnosis and the patch. I've not used Scheduler Workbench, but I think I should take a look at it, given that quite a few people use it with our module. Yes, we should definitely protect that code. Setting to 'needs review' to check the automated testing.
Jonathan
Comment #5
hefox CreditAttribution: hefox commentedPatch is being used on a project with multiple testers/developers and has not presented any problems yet and has fixed the issue.
Comment #7
jonathan1055 CreditAttribution: jonathan1055 commentedThanks hefox for testing. Committed and will become part of 7.x-1.3 in due course.
I tried to give credit to arcaneadam for the patch, and used the syntax
However, this did not have the desired effect, so I'll have to go a research the git syntax a bit more. Sorry you did not get the credit.
Jonathan