Problem/Motivation
When activate "me" module get error on blog/% page:
Trying to get property of non-object in blog_menu_local_tasks_alter() (line 155 of ... /modules/blog/blog.module)
Proposed resolution
Solution described in the issue:
- Go to the file blog.module and find the line (154 or 155) in the function blog_menu_local_tasks_alter().
- The line should be:
elseif ($root_path == 'blog/%' && $router_item['page_arguments'][0]->uid == $user->uid) { - Change it to:
elseif ($root_path == 'blog/%' && isset($router_item['page_arguments'][0]->uid) && $router_item['page_arguments'][0]->uid == $user->uid) { - The warning is now fixed.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | blog.patch | 746 bytes | akoepke |
Comments
Comment #1
pingers commentedEasily fixed by doing this, but I think me.module is to blame...
It's adding page arguments... wouldn't the solution be to merge the arrays differently in me.module (in hook_menu_alter())?
Comment #2
chirhotec commentedThe ME module isn't the only one having problems with this issue:
https://drupal.org/node/1160926 (Menu token)
http://www.drupaldeveloper.es/en/trying-to-get-property-of-non-object-in... (Token?)
In my case, I'm encountering this problem when I try to override the built in blog page with one created from views.
Comment #3
akoepke commentedI just encountered this issue doing the same task as chirhotec above. I have create a View to override the default blog page and when using the user UID as a contextual filter, it displays this error message.
Comment #4
akoepke commentedPatch file attached
Comment #5
akoepke commentedComment #6
seren10pity13 commentedHi,
I found the same patch in Menu Token issue queue : https://www.drupal.org/node/1160926#comment-9486777
It's a 3 years old issue, but the bug is still there, and the patch is still working.
Comment #7
klokie commentedComment #8
fabianx commentedThought about it for a moment, but this is fine. If something alters something it needs to check that its assumptions are correct.
Marked for commit.
Comment #10
David_Rothstein commentedThe issue marked duplicate of this one (#1160926: Blog module conflicts with other URL routes beginning with "blog/") had a better title :)
Also adjusting issue credits so some people from that issue get credited here too.
Comment #11
David_Rothstein commentedCommitted to 7.x - thanks!