Hi,
I get this error message when browsing calendar:
Notice: Undefined property: stdClass::$nid in calendar_get_node_link() (line 420 of /home/webhost/public_html/sites/all/modules/calendar/calendar.module).
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | calendar-7.x-2.x-dev-1087528-2.patch | 4.4 KB | thekevinday |
| #7 | calendar-7.x-2.x-dev-1087528-1.patch | 1007 bytes | thekevinday |
Comments
Comment #1
mcmanisd commentedI am getting this "Notice: Undefined property: stdClass::$id in calendar_build_nodes() (line 663 of /Applications/MAMP/htdocs/sites/all/modules/calendar/calendar.module)."
Anyone know why? I have tried everything I can think of.
Comment #2
mcmanisd commentedfixed it.
Comment #3
jesss commented@mcmanisd: how?
Comment #4
mcmanisd commentedCheck this out. You can use any text editor. Just make sure you get both the @ and //.
http://drupal.org/node/1036332
Comment #5
bjlewis2 commentedok, so that get's rid of the warning, but is there a fix for the actual error?
Comment #6
syntax-2 commentedlatest version (7.x-2.x-dev (2011-Mar-24)) has new one error:
Notice: Undefined property: stdClass::$nid in calendar_get_node_link() (line 424 of /var/www/drupal-7.0/sites/all/modules/calendar/calendar.module).
before:
elseif (empty($node->remote) && is_numeric($node->nid)) {
return url("node/$node->nid", array('absolute' => TRUE));
after:
elseif (empty($node->remote) && is_numeric($node->_field_data['nid']['entity']->nid)) {
return url("node/$node->_field_data['nid']['entity']->nid", array('absolute' => TRUE));
Comment #7
thekevinday commentedI have the same problem, but I have identified the problem to be a result of a different problem altogether.
The error as noted above:
Notice: Undefined property: stdClass::$nid in calendar_get_node_link() (line 427 of sites/all/modules/calendar/calendar.module).This happens for me with the calendar module when the date field is hidden from display.
It appears that the node id is stored in $node->id and not $node->nid.
This immediately solves the issue above.
The question that follows is, then why is $node->nid working when the date field is not excluded from display.
It appears that $node->nid is being initialized to the output of the date field.
This means some part of the date field is overriding the original value of $node->nid with custom text.
For example, the contents of my $node->nid is:
Friday, April 22, 2011 - 16:30 - Friday, April 29, 2011 - 16:30That is clearly not the nid.
The function in question begins like the following:
Notice how it is claiming that the $node is supposed to be a calendar node object.
The structure of my calendar node object looks like the following (when the date field is excluded from display):
What appears to be happening here is that the node object is having object variables being written to, thus overriding node object variables.
This is all well and good, but it still does not explain why a date field is being saved as the node id.
There appears to be 3 locations where the each node is being defined:
1) calendar_multiday/theme/theme.inc:176
2) theme/theme.inc:176
3) calendar_ical/calendar_plugin_style_ical.inc:243
Lets look at #1, because thats where the month view seems to be working from:
The following is the problematic section of code:
The mistake here is the assumption that $field_alias is unique and does not overwrite existing fields.
Any part of the node object could potentially be a database column name.
Now what we have is that something is improperly defining their field_alias to be set to nid. (which is a date field)
Getting closer to the culprit, looking at
modules/field/views_handler_field_field.inc:115:If I were to hack this line to see what happens:
The above hack produces the desired output.
So the problem is directly related to what happens here:
modules/field/views_handler_field_field.inc:115Unfortunately I have not been able to figure out what needs to be done to properly fix this.
For the time being all I have is a patch that uses the proper nid, thus making the symptom go away.
Attached is the said patch.
To sum up this large post:
1) The variable
$node->nidis not actually the nid but a dynamically changeable field row (and therefore cannot be trusted)- the attached patch fixes this to use
$node->idwhich appears to be the guaranteed node id.2) The theme functions (
calendar_multiday/theme/theme.inc and theme/theme.inc) blindly overwrite $node based of field_alias with the assumption that field_alias can never be a reserved/pre-existing node variable name.- I have not supplied a solution to this as it may require a major re-write of the logic (such as putting all of the added fields inside of a sub-array so that fields like nid can be used without overwritting $node->nid.
3) There is a bug noticed in
modules/field/views_handler_field_field.incon line 115 where for nid gets improperly replaced with the output of a given field. (in this case, a date field)- I was unable to find a proper solution to this, it is unclear as to why the field_alias for field_my_custom_date ends up being nid instead of the some name of the field_name (such as field_my_custom_date or field_my_custom_date2)
4) #2 and #3 above are probably issues with the views module (or views and calendar combined) and not the calendar module by itself
Comment #8
karilu_ec commentedsubscribing
Comment #9
darrellhq commentedI have changed the date format from Long to Short and it seems to get rid of the error. I got the idea from looking at the date format for the 'Updated Date' field provided by default. I think the date format may be where the problem exists.
Comment #10
oregonwebsiteservices commentedSubscribing - Same error:
Notice: Undefined property: stdClass::$nid in calendar_get_node_link() (line 424 of /var/www/vhosts/mysacrifice.org/httpdocs/sites/all/modules/calendar/calendar.module)..
It happens when I Exclude the date field from display - if the date field is not excluded the error goes away -
Comment #11
raleigho commentedI was having the same issue as you just described, I tried solution in #6 and it seemed to do the trick. Good luck.
Comment #12
oregonwebsiteservices commentedI deleted all my calendar content, removed and reinstalled unfortunately that was my solution
Comment #13
thekevinday commentedIn continuation from #7: http://drupal.org/node/1087528#comment-4273204
It seems that
calendar_plugin_style_icalpassed the item parameter tocalendar_build_nodes()differently than the rest of the calendar views.The end result is that the
calendar_build_nodes()does not find expected data.This time around, I removed the
calendar_plugin_style_icalcode that generates the$itemvariable and replaced it with the code fromtemplate_preprocess_calendar()found inside ofcalendar/theme/theme.inc.When this is done, more of the errors vanish.
This also solves the following bug:
- ical only shows only 1 event no matter how many are supposed to show
With the attached patch, the errors go away and the mentioned ical bug goes away.
This patch includes the fix from #7 as well.
Comment #14
zabelc commentedI gave thekevinday's patch a try and it got rid of the errors for me in the 2011-04-17 build of calendar-7.x-2.x-dev.
Comment #15
karens commentedI've rewritten lots of this code to use views->style_plugin->render_fields(), among other things. I don't see any errors in the latest code. You can reopen if you see other problems after updating to today's changes.
Comment #16
karens commentedHmm, I missed the big ical patch in here, I'll get this in too.
Comment #17
zabelc commentedHi KarenS, perhaps you committed this patch after the build script ran, but I had to reapply it in the 2011-04-19 dev build.
PS many thanks for the work you've done over the past few days: date/calendar are *much* much more solid now!
Comment #18
karens commentedThere are probably a number of things that haven't made it into the build script yet. I didn't apply this patch as it stands, there were some changes. Everything should be in the next build.