This occurred when I used the Minutes module to add to an Event (the new version with the date format changes).

* warning: date() expects parameter 2 to be long, string given in C:\www\drupal\sites\sbs\modules\token\token_node.inc on line 33.
* warning: date() expects parameter 2 to be long, string given in C:\www\drupal\sites\sbs\modules\token\token_node.inc on line 34.
* warning: date() expects parameter 2 to be long, string given in C:\www\drupal\sites\sbs\modules\token\token_node.inc on line 35.
* warning: date() expects parameter 2 to be long, string given in C:\www\drupal\sites\sbs\modules\token\token_node.inc on line 36.
* warning: date() expects parameter 2 to be long, string given in C:\www\drupal\sites\sbs\modules\token\token_node.inc on line 37.
* warning: date() expects parameter 2 to be long, string given in C:\www\drupal\sites\sbs\modules\token\token_node.inc on line 38.
* warning: date() expects parameter 2 to be long, string given in C:\www\drupal\sites\sbs\modules\token\token_node.inc on line 39.
* warning: date() expects parameter 2 to be long, string given in C:\www\drupal\sites\sbs\modules\token\token_node.inc on line 40.
* warning: date() expects parameter 2 to be long, string given in C:\www\drupal\sites\sbs\modules\token\token_node.inc on line 41.
* warning: date() expects parameter 2 to be long, string given in C:\www\drupal\sites\sbs\modules\token\token_node.inc on line 42.
* warning: date() expects parameter 2 to be long, string given in C:\www\drupal\sites\sbs\modules\token\token_node.inc on line 43.
* warning: date() expects parameter 2 to be long, string given in C:\www\drupal\sites\sbs\modules\token\token_node.inc on line 44.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pukku’s picture

Assigned: Unassigned » pukku

First, I'm sorry I've taken so long to get back to you on this.

Second, I can't replicate this. It looks as though this may have something to do with token.module; do you have token.module enabled on your system?

Ricky

pukku’s picture

Also, did you apply the patch from jonathan_hunt to allow using path-auto with minutes?

NancyDru’s picture

Yes, token is installed and enabled. I did not know anything about a patch for pathauto; however, I do not have pathauto enabled (yet).

NancyDru’s picture

I just looked at his patch, and it is inadequate for my needs. However, I have also been looking at the node auto title module, which I think will do what I need.

pukku’s picture

Hi! Actually, my question was more because I never call date() in my code, so I was wondering if his call to date() might be causing the problem. I will have to download token.module and look at it to figure out what the problem is...

ricflomag’s picture

Project: Minutes » Token
Version: 5.x-1.x-dev » 5.x-1.7
Category: support » bug

I have a fresh drupal install, with Token an Book modules enabled, but i don't use the Minute module. The same error as described by nancyw has occurred on creating my first book page.

I have moved this thread to the "Token" Module.

yan’s picture

I'm getting the same error message using upload path module which uses the token module. It first worked fine like twice but now I get the error message. Plus the data in upload path isn't right. I set it (using tokens) to [yyyy]/[mm] but it always puts 1970/01.

ricflomag’s picture

Assigned: pukku » ricflomag
Status: Active » Needs review
FileSize
3.37 KB

Here is a patch against token_node.inc to avoid the warning.

drewish’s picture

FileSize
3.54 KB

i'd reported a duplicate of this: http://drupal.org/node/166920 and used a different approach for fixing the bug.

greggles’s picture

Version: 5.x-1.7 » 5.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

Applied drewish's last patch to the DRUPAL-5--1 branch (modified slightly, his was for the HEAD version).

Thanks everyone.

Ready to be applied to the DRUPAL-6--1 branch.

David Stosik’s picture

The patch of post #9 doesn't work: I use token module with "Upload Path".
When I submit a node with attachment, the fields 'yyyy', 'yy', 'month', etc. of $values are not filled. Upload path then creates directories named [yyyy]/[mm]/[dd] instead of 2007/08/14 (date of node creation).
Solution suggested here seems better (and it works!).

Another problem of the same kind: when submitting a node, $values['nid'] is not set, as the node has not already a value. Thus, the folder [nid] I wanted to be created is not created.
Is this a token module concern, or does upload path use token module in a wrong manner?

Thanks,
David

greggles’s picture

If $node->created is not set then something else is wrong.

I don't really like the idea of "if the values are empty, populate them with possibly incorrect data".

It could be that uploadpath will need to provide some tokens of it's own for this scenario, which is possible and reasonable.

greggles’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
dennys’s picture

I use upload path too, the patch of #9 doesn't work, but 134168 works.

fago’s picture

Status: Patch (to be ported) » Active

I just ran over the problem with a recent 5.x-1.x-dev version - so the problem isn't solved!
So I set the issue back to active..

$node->changed seems to be a non empty string, so the if doesn't apply. Of course this line fixed the warnings:
$node->changed = (int)$node->changed;

side-note: the indents are quite messy there

greggles’s picture

@fago - perhaps you could provide a patch ;)

fago’s picture

Status: Active » Needs review
FileSize
3.48 KB

of course ;)

scarer’s picture

I can't get any of the patches to work. I'm excuting the patch command via ssh and they keep failing. Any suggestions? Sorry, I'm a bit new at this patch business...

Here's a copy of the .rej file log:

***************
*** 14,52 ****
        $values['type']           = $node->type;
        $values['type-name']      = node_get_types('name', $node->type);
        $values['title']          = check_plain($node->title);
- 
        $values['author-uid']     = $node->uid;
        $values['author-name']    = $node->name;
        if (isset($node->created)) {
- 	$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 (isset($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);
        }
-       
        // Now get the menu related information.
        global $_menu;
        $trail = array();
--- 14,54 ----
        $values['type']           = $node->type;
        $values['type-name']      = node_get_types('name', $node->type);
        $values['title']          = check_plain($node->title);
        $values['author-uid']     = $node->uid;
        $values['author-name']    = $node->name;
+ 
        if (isset($node->created)) {
+         $date = (int)$node->created;
+       	$values['yyyy']           = date('Y', $date);
+       	$values['yy']             = date('y', $date);
+       	$values['month']          = date('F', $date);
+       	$values['mon']            = date('M', $date);
+       	$values['mm']             = date('m', $date);
+       	$values['m']              = date('n', $date);
+       	$values['ww']             = date('W', $date);
+       	$values['date']           = date('N', $date);
+       	$values['day']            = date('l', $date);
+       	$values['ddd']            = date('D', $date);
+       	$values['dd']             = date('d', $date);
+       	$values['d']              = date('j', $date);
        }
  
        if (isset($node->changed)) {
+        	$date = (int)$node->changed;
+       	$values['mod-yyyy']       = date('Y', $date);
+       	$values['mod-yy']         = date('y', $date);
+       	$values['mod-month']      = date('F', $date);
+       	$values['mod-mon']        = date('M', $date);
+       	$values['mod-mm']         = date('m', $date);
+       	$values['mod-m']          = date('n', $date);
+       	$values['mod-ww']         = date('W', $date);
+       	$values['mod-date']       = date('N', $date);
+       	$values['mod-day']        = date('l', $date);
+       	$values['mod-ddd']        = date('D', $date);
+       	$values['mod-dd']         = date('d', $date);
+       	$values['mod-d']          = date('j', $date);
        }
+ 
        // Now get the menu related information.
        global $_menu;
        $trail = array();

greggles’s picture

How do I repeat this bug? I see "use minutes and add an event" but that seems short on real details.

drewish’s picture

try previewing a new node... i don't think they have to be events specifically, it just that $node->created isn't initialized

fago’s picture

I think I ran over it by using autonodetitle or worklfow-ng - of course a module needs to invoke token otherwise the error's won't appear.

greggles’s picture

Assigned: ricflomag » greggles

Guys, I need _more_ details on how to repeat it, not less.

I'm using token with date values on plenty of sites but have never encountered this. So, what more do I need to do.

mlncn’s picture

Bug confirmed when using module workflow-ng

Install workflow-ng.

Create a workflow like this one:

Invoked on event: Content is going to be saved

Conditions

OR group Content has type

AND
Numeric comparison

Actions

Page redirect

Also tried with a string comparison. I'm pretty sure that's what's helping trigger the error, the comparison that uses tokens. In my case I'm trying to compare the changed value of a CCK check box to the unchanged node version of the same CCK checkbox. No date invoked anywhere.

(I'm also replacing the title using node auto title to use the top [term] as the title but I don't think that's what's triggering it.)

Try to create and save a node of the type affected.

mlncn’s picture

FileSize
3.11 KB

Rerolled the patch.

It applies and I can confirm that it fixes the problem. For those who wish to apply and test, put it in the token module directory and from within the token directory:

patch < token_5_reroll.patch

My workflow still doesn't do what I want it to, but I think that's my problem. No more token errors!

(I don't know why Fago's patch stopped applying, but I wonder if the use of tabs instead of spaces in token_node.module could be contributing to messiness?)

NancyDru’s picture

I hope you've notified him of the tabs - they violate Drupal coding standards. The Coder module would have told him that if he had run it, as I do on all my modules.

greggles’s picture

I applied this concept to the 5.x-1.x branch.

@Benjamin - please be sure that you are creating patches against the tip of the DRUPAL-5 branch. Your patch didn't apply for me.

@nancyw - thanks for making sure that we know about the problem and about easy ways to check for them - I recently fixed those whitespace issues based on a patch provided by dmitrit01 - http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/token/token...

greggles’s picture

Status: Needs review » Patch (to be ported)
greggles’s picture

Status: Patch (to be ported) » Fixed

Ported via eaton's work this past weekend.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

davidwhthomas’s picture

Just note for anyone experiencing this problem when using the Uploadpath module with the Token module and using date tokens. The fix passes the node->created timestamp, if not set so the token module handles it properly.
I fixed the issue with a patch to the uploadpath module.
For more information see here : http://drupal.org/node/152089#comment-623461
DT

susata’s picture

I see that the status of this is "closed" and assumed fixed; however, I am getting this error with Token (5.x-1.9) and Pathauto (5.x-2.0), both downloaded from drupal.org yesterday. The error message happens when I attempt to upload an audio file, and it looks like this:

warning: date() expects parameter 2 to be long, string given in /www/example.com/web/sites/all/modules/token/token_node.inc on line ##

example, of course, is our domain
## is different for each printing of the message, and there are MANY--it's a long list that fills the screen.

Is there anything I can do to stop this error from displaying? It looks like the audio file is actually uploaded okay, but the long list of warnings will be very disconcerting to users.

Thanks!

greggles’s picture

susata - are you also using upload path? If so, see the comment in #30. If not, please open a new issue so we can investigate your specific problem (follow up here with a link if you do that).

susata’s picture

No--not using the Upload Path module or even the Upload module.

Here's the link to the new issue:
http://drupal.org/node/214036

Thank you,
s.

susata’s picture

Update: I have installed Upload (but not Upload path). I still get this same error - when I try to upload an audio file. I am posting this to the 'live' thread at http://drupal.org/node/214036.
s.

jcamfield’s picture

I encountered this bug without Token installed; but (manually) applying this patch fixed it; http://drupal.org/node/141172

My problem was with event_views after upgrading to the event dev release. This was the thread that came up in my initial googling so I'm adding my comment here to help anyone else who stumbles across it.