The function 'node_page_callback' causes an error notice when it doesn't get a $node object as parameter. (Notice: Trying to get property of non-object in node_page_title() (line 2075 of XXX\modules\node\node.module).

Calling the function 'menu_build_tree' can result in a bunch of these notices. It would be nice, if you could check in the title callback, if the property title exists. I'm adding a patch file which solved the problem in my test environment.

CommentFileSizeAuthor
#7 node-title.patch369 bytesmindbat
node.module.patch405 bytesanschinsan

Comments

itz_andr3’s picture

I try anschinsan patch, and it works for baypass the error notice,
as described by others at the very same problem here http://drupal.org/node/1318210

the cause for this bug is unknown,
and i got this bug, on my fresh D7 complete install, and add my first link to management

Anonymous’s picture

This solved the bug for me as well. I can't seem to trace where the call is coming from.

marcingy’s picture

Status: Active » Postponed (maintainer needs more info)

Please describe how to replicate this issue with a core drupal install.

kristen pol’s picture

Status: Postponed (maintainer needs more info) » Active

I've seen these notices as well though I'm unsure which contrib modules are the culprits in my case. I think it is always a good idea to check data being passed into a function before acting on that data even it's simply:

 function node_page_title($node) {
   if (isset($node->title)) return $node->title;
 }

Here's a related issue:

#1709914: Notice: Trying to get property of non-object in node_page_title() (Zeile 2108 von /var/www/modules/node/node.module).

though there are several others in specific contrib module issue queues.

I'm not sure what the core policy is about checking data prior to using it. I always add in empty() and isset() checks in my code.

marcingy’s picture

Status: Active » Postponed (maintainer needs more info)

Contrib modules are responsible for working with core not the other way round. If this can't be replicated in a core in install it isn't a core bug.

kristen pol’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

I did look at some of the other functions and noticed that, in general, parameters are not checked for empty data. I think the error only is due to contrib modules calling the function with a null parameter so I think it makes sense to mark "works as designed".

mindbat’s picture

Version: 7.12 » 7.18
Status: Closed (works as designed) » Needs review
StatusFileSize
new369 bytes

This bug was still happening for me in 7.18, and it was causing links to nodes in the Management Menu (for admins) to not have any titles (the links were blank).

I've attached the patch I used to fix both the notices and the missing link titles. It checks to see if the incoming param is a number, and treats it as a node id if that's the case.

I've seen Drupal functions that take both nids and objects and respond properly to both. Seems like this function should either handle multiple inputs, or explicitly throw an exception if it gets an improper input.

Marking as needs review.

Status: Needs review » Needs work

The last submitted patch, node-title.patch, failed testing.

marcingy’s picture

Status: Needs work » Postponed (maintainer needs more info)

As per http://drupal.org/node/1477608#comment-6374472 please provide steps to recreate with a core test. Otherwise this a contrib bug that should be fixed in appropriate contribute module. Some functions do, do checks but that is when both inputs are valid.

rooby’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

This seems to be a duplicate of #1697570: _menu_load_objects() is not always called when building menu trees

Feel free to re-open this if you think otherwise.

rix.kostenko’s picture

Hi,

I had this error, quick fix was prefixing custom call to menu_build_tree() with @menu_build_tree().

Hardly a real solution but worked for me.