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.
Warrnings:
"date() expects parameter 2 to be long, string given .....token_node.inc, line 35 to 46".
and second problem.. when node->created is empty (when creating new node) path for uploaded files is empty too.
I think there should be if statment like this:
token_node.inc:
line 19:
if (empty($node->created)) {
$node->created = time();
}
$values['yyyy'] = date('Y', $node->created);
$values['yy'] = date('y', $node->created);
$values['month'] = date('F', $node->created);
$values['mon'] = date('M', $node->created);
$values['mm'] = date('m', $node->created);
$values['m'] = date('n', $node->created);
$values['ww'] = date('W', $node->created);
$values['date'] = date('N', $node->created);
$values['day'] = date('l', $node->created);
$values['ddd'] = date('D', $node->created);
$values['dd'] = date('d', $node->created);
$values['d'] = date('j', $node->created);
if (!(empty($node->changed))) {
$values['mod-yyyy'] = date('Y', $node->changed);
$values['mod-yy'] = date('y', $node->changed);
$values['mod-month'] = date('F', $node->changed);
$values['mod-mon'] = date('M', $node->changed);
$values['mod-mm'] = date('m', $node->changed);
$values['mod-m'] = date('n', $node->changed);
$values['mod-ww'] = date('W', $node->changed);
$values['mod-date'] = date('N', $node->changed);
$values['mod-day'] = date('l', $node->changed);
$values['mod-ddd'] = date('D', $node->changed);
$values['mod-dd'] = date('d', $node->changed);
$values['mod-d'] = date('j', $node->changed);
}
Comments
Comment #1
gregglesunder what scenarios does this occur?
Comment #2
gregglesPlease respond with an answer to the question of "under what scenarios does this occur" ?
This seems pretty error-prone to me. One option is that the consuming module (e.g. upload path, apparently) could set the $node->created prior to handing the object to token.
Comment #3
dmitrig01 CreditAttribution: dmitrig01 commentedThis was fixed in an earlier commit
Comment #4
(not verified) CreditAttribution: commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #5
yan CreditAttribution: yan commentedI re-open this issue since I still get the same error in 5.x-1.9 (folders are named "[yyyy]/[mm]" instead of replacing the tokens by numbers). I think it's just the following that needs to be included in token_node.inc (and hasn't been so far):
Comment #6
meatbites CreditAttribution: meatbites commentedCan you give an idea on how to reproduce this error? Does upgrading to Token 5.x-1.10 help?
It sounds more like a bug of a node-creating module not setting a creation date. In which case, that'd probably be the best module under which to file this bug.
Comment #7
yan CreditAttribution: yan commentedsorry, clicked twice. edited this one and deleted double info.
Comment #8
yan CreditAttribution: yan commentedI'm using the upload field (file attachments) with upload path module and token module. In upload path settings I put [yyyy]/[mm] as upload folder. When I create a new node and upload an image, $node->created is empty, i.e. the tokens are not replaced by the numbers of the actual date.
No, it doesn't. The problem is still there. I think it has to do with the empty $node->created.
Comment #9
gregglesI don't like this idea in token. If Eaton disagrees then he should feel free to override me, but IMO this is up to the calling module to handle.
Comment #10
yan CreditAttribution: yan commentedCould you tell why?
Which one would that be? The node module? In my understanding it is quite obvious that there is no creation time/date before the creation of the node.
Comment #11
gregglesI think I said why I don't like it in comment #2 and then quoted it in comment #9. To be more clear:
If we add a created time to the node object (which is passed by refererence by default in php5) then we run the risk of messing up the processing by another module. I don't want token to be responsible for that.
I also said that it's up to the consuming module (upload path, apparently) to do the right thing here.
Comment #12
yan CreditAttribution: yan commentedOk greggles, I raised the issue for upload path (the same problem has just been mentioned there):
#219132: Problem with yyyy, mm, dd tokens