I have created a new content type with a Date CCK field.
When I create or edit a node of this content type, and save or preview, then I get these errors:
* warning: date_format() expects parameter 1 to be DateTime, null given in /var/www/sites/all/modules/date/date/date.module on line 355.
* warning: date_timezone_set() expects parameter 1 to be DateTime, null given in /var/www/sites/all/modules/date/date/date.module on line 357.
* warning: date_format() expects parameter 1 to be DateTime, null given in /var/www/sites/all/modules/date/date/date.module on line 359.
* warning: date_offset_get() expects parameter 1 to be DateTime, null given in /var/www/sites/all/modules/date/date/date.module on line 361.
Otherwise it seems to work ok.
Currently I don't use the date field yet for a calendar or anything. I just use the tokens for pathauto. Which doesn't run when I preview an edit anyway.
Drupal version: 6.13
Updated Date module to latest version and followed troubleshooting instructions on http://drupal.org/project/date
Using PHP5
Export of my custom content type:
$content['type'] = array ( 'name' => 'Foutparkeerder', 'type' => 'foutparkeerder', 'description' => 'Heb je een foutparkeerder gespot? Meld het hier. Je kan foto\'s meesturen, en op een kaartje aanduiden waar je de foutparkeerder gezien hebt. Zet er ook een beetje uitleg bij over wat er verkeerd of gevaarlijk is aan de verkeerssituatie. Wij kijken je inzending na en zorgen er voor dat die zo snel mogelijk op de voorpagina verschijnt.', 'title_label' => 'Titel', 'body_label' => 'Berichttekst', 'min_word_count' => '10', 'help' => '
Geef een korte beschrijving van de situatie.
', 'node_options' => array ( 'promote' => true, 'status' => false, 'sticky' => false, 'revision' => false, ), 'language_content_type' => '0', 'upload' => '0', 'old_type' => 'foutparkeerder', 'orig_type' => '', 'module' => 'node', 'custom' => '1', 'modified' => '1', 'locked' => '0', 'comment' => '2', 'comment_default_mode' => '4', 'comment_default_order' => '2', 'comment_default_per_page' => '50', 'comment_controls' => '3', 'comment_anonymous' => '2', 'comment_subject_field' => '1', 'comment_preview' => '1', 'comment_form_location' => '1', ); $content['fields'] = array ( 0 => array ( 'label' => 'Tijdstip', 'field_name' => 'field_datetime', 'type' => 'datetime', 'widget_type' => 'date_popup', 'change' => 'Change basic information', 'weight' => '-2', 'default_value' => 'now', 'default_value2' => 'same', 'default_value_code' => '', 'default_value_code2' => '', 'input_format' => 'd/m/Y - H:i', 'input_format_custom' => '', 'year_range' => '-100:+0', 'increment' => '5', 'advanced' => array ( 'label_position' => 'above', 'text_parts' => array ( 'year' => 0, 'month' => 0, 'day' => 0, 'hour' => 0, 'minute' => 0, 'second' => 0, ), ), 'label_position' => 'above', 'text_parts' => array ( ), 'description' => 'Wanneer heb je de foto genomen?', 'required' => 1, 'multiple' => '0', 'repeat' => 0, 'todate' => '', 'granularity' => array ( 'year' => 'year', 'month' => 'month', 'day' => 'day', 'hour' => 'hour', 'minute' => 'minute', ), 'default_format' => 'foutparkeerder_datetime', 'tz_handling' => 'site', 'timezone_db' => 'UTC', 'op' => 'Veldinstellingen indienen', 'module' => 'date', 'widget_module' => 'date', 'columns' => array ( 'value' => array ( 'type' => 'datetime', 'not null' => false, 'sortable' => true, 'views' => true, ), ), 'display_settings' => array ( 'weight' => '-2', 'parent' => '', 'label' => array ( 'format' => 'above', ), 'teaser' => array ( 'format' => 'hidden', 'exclude' => 0, ), 'full' => array ( 'format' => 'default', 'exclude' => 0, ), 4 => array ( 'format' => 'default', 'exclude' => 0, ), 2 => array ( 'format' => 'default', 'exclude' => 0, ), 3 => array ( 'format' => 'default', 'exclude' => 0, ), 'token' => array ( 'format' => 'default', 'exclude' => 0, ), ), ), ); $content['extra'] = array ( 'title' => '-5', 'body_field' => '1', 'menu' => '-3', 'taxonomy' => '-4', 'attachments' => '2', );
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 518816-5.date_format_date_warnings.patch | 606 bytes | dww |
Comments
Comment #1
patricio.keilty commentedsubscribing
Comment #2
Rosamunda commented+1 similar unknown problem :S
Comment #3
knightnet commentedSame here.
One thought though - is this a PHP 5.3 type issue? I am using a development environment using Uniform Server on Windows - I notice that there are other issues related to differences between PHP 5.2 and 5.3
Comment #4
dwwUser recrit over at #772180-16: "date_format() expects parameter 1 to be DateTime, string given" warnings when creating/editing nodes with date fields posted date-772180-element-description-1.patch which myself and many others have confirmed is a working solution to this problem. This was the oldest issue open I found about the bug, so I'm consolidating everything into here to clean up the issue queue a bit...
Comment #5
dwwAlso note, user jurgenhaas posted a different solution to the same problem at #798772: Call of date_format requires param 1 to be DateTime, String given. The same patch applies to D6 and is possibly a better solution to the bug here -- inside date_format_date() itself, if the input is a string, convert it to a DateTime object right there. I'll leave it to KarenS to decide which one to commit. There's no real harm in committing both, in fact. I re-rolled the #798772 patch to be more properly formatted and am attaching here for comparison with date-772180-element-description-1.patch.
Comment #6
jurgenhaasThis patch works fine for me, thanks.
Comment #7
recrit commented@dww - I agree that both patches date-772180-element-description-1.patch and #518816 would be a complete solution since mine only addresses bad calls to date_format() from the date module and 518816 patch catches any calls from any module. 772180 should still get committed so that the date module uses its own functions correctly.
Comment #8
Spark_man commentedI have applied the latest patch (518816-5.date_format_date_warnings.patch) and running the latest dev version of Date (6.x-2.x-dev (2010-May-01)) is still giving me:
warning: get_class() expects parameter 1 to be object, string given in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\drupal-6.16\sites\all\modules\date\date_api.module on line 651.
Comment #9
dwwThanks for testing, Spark_man. What version of PHP are you using? I tried with PHP 5.2 and the patches both worked fine.
Comment #10
Spark_man commentedPHP Version 5.3.2
BTW: Looked at this thread with fresh eyes this morning and also applied date-772180-element-description-1.patch and that cleared up the problem. Sorry for not reading more closely. It occurs to me that there should be a better way of figuring out which patches to apply to resolve a problem, but then again ... READING is good too! Thanks!
Comment #11
recrit commentedit appears the catch all patch 518816-5.date_format_date_warnings.patch will run into this problem for PHP 5.3.0 as stated below from a comment on the PHP manual page
http://us.php.net/manual/en/function.get-class.php
Comment #12
likewhoa commentedsubscribing
Comment #13
xkater commentedsub
Comment #14
adamo commentedThe patch referenced in #10 seems to have done the trick for me.
Comment #15
mariafromatoz commentedExcellent! Patch 5 worked for me for PHP 5.2 and PHP 5.3 and patch 10 sorted the extra warnings for PHP 5.3.
Ta.
Comment #16
bkno commentedPatch in #10 worked for me.
Comment #17
likewhoa commentedpatch works for me.
Comment #18
dwwIf you're going to comment here saying "works for me", please be specific about two things:
1) exactly what patch you tried
2) what version of PHP your site is using
Thanks,
-Derek
Comment #19
rolfmeijer commentedsubscribing
Comment #20
larskleiner commentedPatch #10 works for me on PHP 5.2.6-1+lenny8.
Comment #21
butler360 commentedSubscribing
Comment #22
jared12 commentedsubscribing
Comment #23
bibo commented* I applied both patches in #5 (or lets say the other was in #10)
* Platform used is Apache/2.2.8 (Ubuntu) PHP/5.2.12 mod_ssl/2.2.8 OpenSSL/0.9.8g (Zend Server)
==> The issues seem to have been fixed. Thanks.
I'd like to set this to "reviewed and tested by the community", but since dww is handling this, I'll just leave it as it is :)
On a sidenote, I'm wondering why critical date-module patches like this don't make it to the module faster. I know people are busy, but there are so many committers to the module.
Comment #24
Offlein commentedPatched with Both #5 and #10 .. (Is that right?) on PHP 5.2.6.
The errors when creating a content with a date field were gone with #5. It just seemed like I should see if #10 broke anything even though I wasn't having Spark_Man's problem from #8. It doesn't appear to have had a negative reaction.
Comment #25
danny englanderSubscribing
Comment #26
giorgio79 commentedJust tried #5 and got this on a node creation screen with date field:
warning: get_class() expects parameter 1 to be object, string given in ...\date\date_api.module on line 651.
PS:
Notice #10 had the same and the patch there fixed this too...
Comment #27
AndyThornton commentedPatch #10 works (Windows 7, PHP 5.2.9-2, Apache 2.2.11). Thank you.
Comment #28
mnzaki commentedI applied both patches and warnings cleared. Drupal 6.17 on PHP 5.2
Comment #29
jmiccolis commentedI've tested date-772180-element-description-1.patch on php 5.3. To me that patch looks like the way to go. Either way however, these patches look good.
Comment #30
tdimg commentedboth patches mentioned in #5 applied individually remove the errors from node/add for me.
my config:
Date 6.x-2.x-dev (2010-May-02)
PHP 5.2.10
CCK Datetime Field with Popup
Comment #31
darrellduane commentedI've applied patches #5 and #10 listed above with PHP 5.3.2 (php-5.3.2-2.fc13.x86_64) and the errors have disappeared. Date 6.x-2.x-dev (2010-May-02)
Comment #32
danny englanderJust curious when an updated version might be coming out that incorporates the patches. I'm deciding do I patch 5 different sites or wait for an update?
Comment #33
giorgio79 commentedComment #34
emilyf commentedsubscribe
Comment #35
kaynen commentedThe attached patch in #5 worked for me. Running Drupal 7.0-alpha5.
Comment #36
deadman commentedI also had to apply patches from #5 and #10 for all warnings to disappear on my PHP 5.3.2 box
Comment #37
Screenack commentedPatch at #5 stopped the errors I was seeing
Comment #38
Patrick Nelson commentedPatch at #5 works for me too.
Comment #39
basvredelingI had to apply patches #5 and #10 to fix the description on the date popup widget and the error messages. Works fine now. The errors were present on php 5.2.12.
Comment #40
Carlos Miranda Levy commentedPatches 5 and 10 did it for me. They do work
Comment #41
kmonty#5 works for me using PHP 5.2.6
+1
Comment #42
greta_drupal commentedI don't mean to sound ungrateful, but how is it that this known-for-some-time error (with quick code fix) was not applied to the July 11, 2010 dev version?
Guess it is job security for me, as my client had planned to do updates herself (having never done them before). She'd have been panicked to have hit these errors.
But, in any case, it would have been nice not to have had to hunt down this error and apply the patch....especially since I expected this very fresh version to have included known bug fixes.
So, thanks for the handy mod, no matter.
Comment #43
eric.chenchao commentedMy PHP version is 5.3.2
When I used #5 patch and I met the get_class warning message like #8
So I changed it like following and for the time being it works for me. Thanks
Comment #44
danny englanderIn regard to comment #42, greta_drupal has a good point, were the patches applied to the new July 11, 2010 dev version? thanks.
Comment #45
mark trappI believe the development snapshots for many modules were regenerated wholesale on July 11th. Many of the dev branch modules I use had an update on July 11th with no apparent changes, and the last time CVS was updated for Date was May 1st, 2010.
Comment #46
mustanggb commented518816-5.date_format_date_warnings.patch on it's own gives #8 warning on PHP 5.3.2
(For me it actually WSOD before commenting out "$date = new DateTime($date);")
date-772180-element-description-1.patch on it's own fixes the issue
Both patches together works fine
However "$date = new DateTime($date);" is never actually called and I worry that is will WSOD again if it ever runs
Please commit date-772180-element-description-1.patch
And possibly a fixed 518816-5.date_format_date_warnings.patch e.g. take a look at #42 or similar solution to the WSOD issue
Comment #47
greta_drupal commentedI can tell you that they were not.
Comment #48
bendiy commentedApplied #5 and #10 and my errors are gone now.
Please Commit this.
Thanks!
Comment #49
lunk rat commentedI am noob when it comes to patching files in subdirectories. #10 seems to move into a date_popup directory. Patching on OSX, how do I tell it to look there. Thanks!
Comment #50
lunk rat commentedduh.
If you are patching core then remember to patch from the drupal root directory and use the -p0 parameter to patch. This will stop patch from asking you which file you wish to patch:
$ patch -p0 < example.patchComment #51
marina_v commentedtyty! applying patches 518816 and date-772180-element-description removed the warning
Comment #52
webchickI applied #5 to the 7.x-1.x release, and it seems to both apply fine with an offset, and also solve the problem (and also clear up some notices in the process). I'm on PHP 5.2.13 here (MAMP 1.9)
I'm going to escalate the priority of this issue to major, as it's pretty bad for the page to be spouting warnings at you, even if it's otherwise working fine.
Comment #53
deng17 commentedWhy do I still have this warning:
warning: get_class() expects parameter 1 to be object, string given in /home/etherune/public_html/bits/sites/all/modules/date/date_api.module on line 651.
I've already applied patch #5 and #10
Comment #54
gooddesignusa commentedI applied patch from #5 and patch from #10 to 6.x-2.x-dev (2010-Jul-11) which seemed to worked for me. Errors are no longer showing up when creating a new date content type.
Platform used is PHP 5.2.13 Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 mod_fcgid/2.3.5
Thanks for everyone's hard work.
Comment #55
zoltán balogh commentedsubscribe
Comment #56
imclean commentedApplied both patches and the problem appears resolved, cheers.
date-772180-element-description-1.patch
518816-5.date_format_date_warnings.patch
Comment #57
myxelf commentedSubscribing....
Comment #58
ethnovode commentedSubscribing
Comment #59
karens commentedBoth fixes are committed. I lost the issue with the patch for the format descriptions because it got marked as a duplicate, but I found and fixed both things. Sorry for the slow response, and thanks for the patches.
Also much thanks to dww for getting on IRC with me to hash out the best solution.
Comment #60
dwwYay, thanks KarenS! Sorry I didn't have time to commit these for you -- it's been a busy few days for me. Just glad to see this finally resolved.
Comment #61
ypogue commentedPlease correct me if I am wrong, but it was stated that the two patches discussed in this thread (see http://drupal.org/node/518816#comment-3225110) were committed to the dev branch. However, when I updated to 6.x-2.x-dev (Aug. 13) version it was not there. I had to re-apply the patches onto date. Can someone please make sure these patches are applied to the future versions. It will be a big help.
Comment #62
karens commentedThey are there. If you are getting your code from a tarball, the tarball is only updated twice a day. There are a ton of changes not yet in the tarball.
Comment #63
basvredelingAre these commits present in the 2.6 release? Or is the dev from Aug 14 not identical to the 2.6 stable from Aug 14?
Comment #64
dwwThe changes were first released in date 6.x-2.5, and are still present in 6.x-2.6.
Comment #65
basvredelingExcellent! many thanks all.
Comment #66
dspring0021 commentedUgh...I'm still getting this in 6.x-2.6, but it's only when I call date_format_date() directly from my own PHP code snippet. The date does get formatted, but I get this ugly error printed to the page a few times.
*** UPDATE ***
Nevermind...I wasn't calling date_make_date() first to create the object. D'oh!
Comment #68
sonicthoughts commentedI have this error on 6.27.
Comment #69
calefilm commentedrecently updated to 6x dev. Is my problem related to this issue (DATE) or with the FullCalendar module?
I get this error with the fullcalendar.module:
warning: date_format() expects parameter 1 to be DateTime, null given in /Users/Cale/Sites/acquia-drupal/sites/all/modules/fullcalendar/fullcalendar.module on line 320.
And the date disappears (along with To and From time) when I click "add another item" in the node add forms (ANY date form). This is only happening when I have a 'From and To' date option selected... is this a separate issue or related to this issue.... Thanks.
UPDATES:
ERROR UPDATE: took care of this error at http://drupal.org/node/1039140 (#5)
DATE DISAPPEARING UPDATE: Took care of this by going back to DATE 6.x.-2.7. Can now add more date items without problems.
Comment #70
bloke_zero commentedI get something similar:
Warning: date_format() expects parameter 1 to be DateTime, boolean given in sites/all/modules/date/includes/date_api_filter_handler.inc on line 325
Date 6.x-2.7 / PHP 5.2.13 - goes away when I switch to PHP 5.3.2
Comment #71
vegemite4me commentedIf someone else encounters this error message and find that none of the patches help, then have a look at your views. I encountered this error message but it was due to the "Date default" value for a view's filter on a date field. I was using a relative value of "now - 1". It should have been "now -1" (no space between the dash and the number).
Comment #72
AlsRight said #71.
Actually this check should be done *before* applying any patch.
I have a similar case: the default value for the exposed date field was set as "< now >" insted of "now" (both without double quotes).
Comment #73
ledom commentedNo errors with php 5.3 but I must go reverse to 5.2 and then this error starts.
#71 works for me
I was using "first day of this month" and "today" as relative date
Clearing relative dates solve the problem without any patch.
Thank you vegemite4me
Comment #74
seethav commentedHI
I very new to drupal.I am created one table using data table module and then i created report page using views.In my report page i am displaying date and time in '2011-06-08 11:20:47' but i want to display in report page link 'day-monthname-year'(08-jun-2011).
How to do this? Help me if any one know this??????????????
Comment #75
rolfmeijer commentedHi seethav, please post your question in the forum.
Comment #76
socialnicheguru commentedin my case i used 'now -1hr' it should be 'now -1hour'. sometimes it's the little things. And spacing does matter.