According to http://api.drupal.org/api/function/hook_node_view/7 (and confirmed by looking at the code), hook_node_view() has a $teaser parameter but no longer has a $page parameter.
However, I noticed that many implementations of this hook throughout Drupal core still assume a $page parameter is being passed.
This should be relatively trivial to fix, but some of the implementations still have code that only runs when $page is TRUE, and it's not immediately clear to me if that code is relevant anymore (because if it is, it needs to be moved somewhere else). For example, in book_node_view():
if ($page) {
menu_set_active_trail(book_build_active_trail($node->book));
menu_set_active_menu_name($node->book['menu_name']);
}
Also note that in this particular case, the menu_set_active_menu_name() function no longer even exists in Drupal (it was recently changed to menu_set_active_menu_names).
Marking as critical for now, since I'm reasonably sure something is seriously broken here, just not sure what :)
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | remove_page_from_remaining_hook_node_view.patch | 3.36 KB | brianV |
Comments
Comment #1
brianV commentedThis is done as part of #350984: Kick comment rendering out of node module.
Some quick grepping of the code shows the following functions need to be updated:
I have a patch in the works for this. Trigger, upload and statistics all just need $page pulled out of the function declaration. book.module is a bit more work...
The issue that changed this never should have been committed without updating all the function calls to these functions...
Comment #2
brianV commentedPatch attached to fix up these remaining modules.
In the patch committed in #350984: Kick comment rendering out of node module, they replace
by calling
.
I've followed that convention in this patch. This is a pretty ugly way of doing it, but that is a different issue!
Comment #3
marcingy commentedSetting to code needs review
Comment #5
sunI do not understand why you do not simply replace
$pagewith!$teaser...?Comment #6
Frando commentedWe cannot simply replace $page with !$teaser because on a listing of full nodes, we have $page = FALSE and $teaser = FALSE, I think. So replacing $page with menu_get_object() looks good to me (and has already been done a couple of times in D7 IIRC).
Comment #7
David_Rothstein commentedIt looks like all these were fixed in a recent CVS commit. (I guess someone wrote a patch to fix them without checking the queue for existing issues first, oh well...)
Comment #8
damien tournoud commentedI confirm I fixed the book implementation that as part of #444920: Book breadcrumbs are broken.
However please note that #445902: (bool) menu_get_object() is *not* an equivalent of $page: think about a full-node view called displayed on a node/xxx page.
Comment #9
brianV commentedDamien - is there any dependable method then of determining if we are on a page or not?
Comment #10
brianV commentednever mind - I am reading the issue you linked.