Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
node system
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
27 Nov 2008 at 18:58 UTC
Updated:
30 Apr 2009 at 11:45 UTC
Jump to comment: Most recent file
Comments
Comment #1
kbahey commentedI like this. Less special cases.
Subscribing.
Comment #2
quicksketchI like it also. What advantage do we get by the
drupal_alter('node_view', $node, $teaser, $page);that we don't have with the hook_nodeapi() call directly before it?Comment #3
chx commentedwhy did you remove the $cid argument from comment_render...?
Comment #4
moshe weitzman commented@chx - good catch. I had pushed this patch further so that comment_render() was no longer mixed in with node_show(). I eventually scaled back for now but forgot to remove those bits. New patch attached.
@nate - thats just a place where sites can add some custom fiddling after contrib modules have built up $node->content. It stands in place of the existing nodeapi('alter') hook.
Also, I forgot to mention that this patch does have some deliberate indentation buglets. I left those in order to keep the diff readable. I'll fix that soon - just wanted to get some eyes on this beforehand.
Comment #5
pwolanin commentedI certainly like the general idea of removing the special casing for links.
Comment #6
moshe weitzman commentedOK, here is a patch with proper indentation and with all instances of hook_link('node') converted.
Comment #7
catchThis looks great. Looks like the $teaser parameter to hook_link() is unnecessary now, so that should be removed completely. I think we already have test coverage for at least some of the hook_link implementations so that may be covered.
Comment #8
moshe weitzman commentedThanks catch. If you search for module_invoke_all('link' in comment.module you will see that we still pass $teaser with different values so I don't think we can remove that quite yet. Let me know if I am wrong.
Attached patch adds back the docs for hook_link_alter() since that is still used for comment links.
Comment #9
catchMoshe - are you sure it's used for comment links? - see #112514: hook_link_alter doesn't work for comment links
Comment #10
moshe weitzman commented@catch - see 'drupal_alter('link', $links, $node)' in comment_render() ... there may be additional places that need an alter call but thats not in scope here.
Comment #11
pwolanin commentedThis doesn't really make sense to me:
Probably either here or where links are added, the code should be checking the build mode.
Also, why do you need drupal_alter('link')? You have this new alter hook in node_build_content():
Any module wanting to alter the links should be able to implement this hook, right?
Comment #12
moshe weitzman commentedAttached patch uses NODE_BUILD_PREVIEW instead of $node->preview. I also extinguished two notices.
The drupal_alter('links') pwolanin refers to is for *comment links*, not node links. So it is not replaced by drupal_alter('node_view')
Comment #13
chx commentedIs drupal_render too heavy or not in a preprocess function? You know, logic and presentation separation. I know, preprocess is a bit of a grey between the two. But I think we are better off with putting the rendered pieces back into node.
Comment #14
moshe weitzman commentedIMO, preprocess is clearly code, and not template. Also this is how user profiles work and unifying the two is a good idea.
Comment #15
chx commentedSorry to throw questions at you at such a slow pace -- I think the patch is now good but this is Drupal 7, do we have a means to write tests for this..? Catching the links with a link_alter test module?
Comment #16
moshe weitzman commentedI've added an assertion to upload.test that its link on node teasers is present and accurate. That assures that the link rendering system is working.
Comment #17
chx commentedArchitecture is nice, has a test and it passed.
Comment #18
David_Rothstein commentedThis looks like a really great patch, but I had some comments reading through the code:
I don't understand why this (and its associated code) is being removed. It looks to me like the potential security hole is still there after this patch.
The above seems unrelated to anything else... I'm guessing it wasn't supposed to be left in the final version of the patch?
Maybe I'm just missing it, but I can't find where
$node->content['teaser']would ever get set...A minor point, but the above seems to be passing a parameter that the function does not have.
Minor point, but it seems like it would be cleaner to check for the existence of the array that is actually being rendered, rather than checking
$node->taxonomy.Same comment as above applies here.
Comment #20
moshe weitzman commentedI have incorporated all of david's suggestions except the first one. That is legacy code, which no longer makes sense. It dates back to before CCK when all we had was a body. $node is now a large collection of properties and 99% of them are raw and unfiltered. It is inconsistent to unset one of them because we are afraid of what a theme might do. We are handing the theme a dangerous weapon, and might as well recognize it. Themes for the most part just print $content and other nicely prepared variables. When you stray, it is quite expected that you get see raw values.
Comment #21
moshe weitzman commentedoops
Comment #23
dries commentedThanks Moshe. Committed to CVS HEAD.
Comment #24
moshe weitzman commentedAdded upgrade docs - http://drupal.org/node/224333#node_links
Comment #25
pwolanin commentedplease roll-back. This was CNW, not RTBC due to failing tests.
Comment #26
pwolanin commentedI get I get 2 fails in node revisions, and 1 in Path aliases with translated nodes. So, it's possible that's due to some other core change?
Comment #27
moshe weitzman commentedThe test bot reported one failure in upload test but it seems spurious because it ran fine for both dries and i. i think the current test failures are unrelated to this patch. If I am wrong, let me know and I will fix quickly.
Comment #28
dave reidpwolanin: The node revision failures are #283246: Node revisions test fails if admin has a personal timezone offset.
Comment #29
pwolanin commentedyes, I think that's it - sorry for my confusion.
Comment #30
boombatower commentedThis cause the testing bot to be disabled and took me hours to trace down: #348111: Upload.test fails when run from run-tests.sh. was an issue in run-tests.sh...please trust the bot and save my time.
Comment #31
dave reidThere should probably be some kind of note in the upgrade docs on how to replace hook_link_alter for node links. There's no mention of it in the doc page or any api examples anymore.
Comment #32
moshe weitzman commentedAdded sentence about hook_ndoe_view_alter()
Comment #33
dave reidPlease someone also follow-up with the missing hook_node_view_alter documentation in #349469: Document missing hook_node_view_alter().
Comment #34
swentel commentedFollow up patch:
Changing $variables['taxonomy'] to $variable['terms'] triggers php notices if taxonomy is disabled:
Notice: Undefined variable: taxonomy in include() (line 22 of /var/www/drupal/drupal-cvs/themes/garland/node.tpl.php.
Patch attached changes terms back to taxonomy in theme.inc, or am I missing something completely important here ?
Comment #36
swentel commentedOk, looks like changing theme.inc was a bad move, changing tpl files instead.
Comment #37
moshe weitzman commentedLooks like a good fix.
Comment #38
dries commentedCommitted #34 to CVS HEAD. Setting back to 'code needs review' because we're discussing some other issues, and because it is not clear if all documentation has been updated yet.
Comment #40
David_Rothstein commentedI added a section about the theme changes (removal of the $taxonomy variable in node.tpl.php files) to the "Converting 6.x themes to 7.x" page (http://drupal.org/node/254940#taxonomy). Someone should probably review it for accuracy, though.
I think that's the only missing documentation for this issue, so I'm setting back to "fixed" for now.
Comment #41
catchAs far as I can see, David Rothstein's comment about $node->content['teaser'] wasn't addressed - on both full views and teaser lists, this hunk doesn't run:
Comment #42
moshe weitzman commentedYeah, that looks like cruft from a prior version of the patch. Please review.
Comment #44
catchComment #45
catchRan tests, manually verified in the other issue that this was dead code. RTBC.
Comment #46
dries commentedCommitted to CVS HEAD. Thanks.
Comment #48
AmrMostafa commentedFYI, #367214: hook_node_alter almost disappeared ?