date() expects parameter 2 to be long, string given in

NancyDru - June 22, 2007 - 01:16
Project:Token
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:greggles
Status:closed
Description

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.

#1

pukku - July 2, 2007 - 16:02
Assigned to:Anonymous» 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

#2

pukku - July 2, 2007 - 16:05

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

#3

NancyDru - July 2, 2007 - 19:30

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

#4

NancyDru - July 2, 2007 - 19:33

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.

#5

pukku - July 2, 2007 - 19:57

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...

#6

ricflomag - July 19, 2007 - 17:43
Project:Minutes» Token
Version:5.x-1.x-dev» 5.x-1.7
Category:support request» bug report

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.

#7

yan - July 20, 2007 - 13:57

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.

#8

ricflomag - July 27, 2007 - 23:11
Assigned to:pukku» ricflomag
Status:active» needs review

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

AttachmentSize
token_node.inc__0.patch 3.37 KB

#9

drewish - August 13, 2007 - 15:42

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

AttachmentSize
token_date_isset_0.patch 3.54 KB

#10

greggles - August 13, 2007 - 16:16
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.

#11

David Stosik - August 14, 2007 - 10:00

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

#12

greggles - August 14, 2007 - 12:41

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.

#13

greggles - August 14, 2007 - 22:49
Status:reviewed & tested by the community» patch (to be ported)

#14

dennys - August 25, 2007 - 15:40

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

#15

fago - September 16, 2007 - 11:34
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

#16

greggles - September 17, 2007 - 18:05

@fago - perhaps you could provide a patch ;)

#17

fago - September 17, 2007 - 19:30
Status:active» needs review

of course ;)

AttachmentSize
token_5.patch 3.48 KB

#18

scarer - September 26, 2007 - 00:57

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();

#19

greggles - October 16, 2007 - 01:58

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

#20

drewish - October 16, 2007 - 04:48

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

#21

fago - October 16, 2007 - 10:36

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.

#22

greggles - October 16, 2007 - 11:40
Assigned to: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.

#23

Benjamin Melançon - October 28, 2007 - 11:43

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.

#24

Benjamin Melançon - October 28, 2007 - 12:18

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?)

AttachmentSize
token_5_reroll.patch 3.11 KB

#25

NancyDru - October 28, 2007 - 13:02

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.

#26

greggles - October 28, 2007 - 16:15

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...

#27

greggles - October 28, 2007 - 16:18
Status:needs review» patch (to be ported)

#28

greggles - October 30, 2007 - 15:21
Status:patch (to be ported)» fixed

Ported via eaton's work this past weekend.

#29

Anonymous - November 13, 2007 - 15:32
Status:fixed» closed

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

#30

davidwhthomas - November 16, 2007 - 13:10

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

#31

susata - January 25, 2008 - 00:29

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!

#32

greggles - January 25, 2008 - 02:16

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).

#33

susata - January 25, 2008 - 05:38

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.

#34

susata - February 10, 2008 - 04:26

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.

#35

jcamfield - November 18, 2008 - 15:36

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.

 
 

Drupal is a registered trademark of Dries Buytaert.