Posted by mErilainen on January 7, 2011 at 11:51am
10 followers
| Project: | Date |
| Version: | 6.x-2.x-dev |
| Component: | Date API |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I got this error message when I start to create a reservation (like event I guess).
warning: get_class() called without object from outside a class in ...sites/all/modules/date/date_api.module on line 710.
I can make the reservation anyway, but I couldn't see it on the calendar. Yet. I've just installed the module.
Comments
#1
The same error, but it seems to be the Date module problem (I don't have installed Event Bookings module). The error shows after update to version 2.7, when node with Date CCK field is saved.
#2
Here is the whole error message:
warning: get_class() called without object from outside a class in .../sites/all/modules/date/date_api.module on line 710.Seems to be related to Date API. But I'm not sure if the problem is there or in the Eventbookings module, because I don't get this problem with other content types. I think it's calling the Date API in wrong manner.
#3
Seems to happen if $date is empty, which causes the function to return early. Reversing the tests gets rid of the notice. Attached is a patch.
#4
For me, the problem has gone after change in "date_api.module" (line 710) from:
if (get_class($date) != 'DateTime') {$date = date_make_date($date);
}
if (empty($date)) {
return '';
}
to:
if (empty($date)) {return '';
}
if (get_class($date) != 'DateTime') {
$date = date_make_date($date);
}
Is this correct, or wrong way?
EDIT: Now, I see that the patch from omerida do the same thing :-)
#5
sub
#6
This is a patch for an older version of the code. Everyone is referring to some code that no longer looks the same. Since this part of the code has changed, someone needs to see if there is still a problem in the latest dev version, and if so, provide a patch for that.
#7
The case for get_class being called still exists in the code for the dev snapshot. Attached is a patch to fix it.
#8
#4 & #7 looking good, this seems to fix the problem for me in the 2.7 release.
#9
fixed:
http://drupalcode.org/project/date.git/commit/58c3f6e
Note:
This change made sense and looked pretty simple, so I applied it without really verifying it fixes a problem.
In the future, please provide details on how the error message can be reproduced. Preferably, try reproducing the error on a clean Drupal install.
That way, module maintainers can:
1.) First reproduce the error
2.) apply the patch
3.) then verify that the patch eliminates the error.
I know this takes time and is not always possible. But doing so will CERTAINLY help your issue/patch get implemented.
AT THE VERY LEAST, you should at least mention that you TRIED to reproduce the problem.
The more detail you give, the faster we can react.
#10
Automatically closed -- issue fixed for 2 weeks with no activity.
#11
Sorry to reopen this.
I am experiencing a very similar error:
get_class() expects parameter 1 to be object, string given in /home/.../sites/all/modules/date/date_api.module on line 719.This happens with both 6.x-2.8 and 6.x-2.x-dev when accessing the full node.
I have checked the above patch is in use in my version.
Dates are saved correctly, views and other modules work as expected.
[EDIT2]
It seems this happens only when using Times;This happens because when I use start and end dates, the start date is a string not an object; like:get_class($date)is actually empty$date = '2012-04-25 00:00:00'I have added this check
<?php$date = (is_object($date) ? $date : date_make_date($date));
?>
And the error went away but still, I would like to know what happens!
I am unsure if this is caused by my setup: (updated) default LAMP stack on Ubuntu 10.04 server with PEAR - PHP Extension enabled.
Any hint on how to (properly) solve this problem is welcome.
THanks!!
#12
You should file a new ticket and leave this one closed/fixed.
#13
One year later (almost :-)
I had the exact same problem as #11 with v2.9 (the stable release at the time of writing).
I also have start/end dates.
The quick fix in #11 worked too, adding that line before line 719