Closed (fixed)
Project:
Printer, email and PDF versions
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Apr 2009 at 18:55 UTC
Updated:
29 Apr 2009 at 19:50 UTC
filing this issue based on comments from pwolanin, while troubleshooting a solr search problem (a beta site reported that some search results contain verbiage generated by the print module):
"The print module has possibly multiple bugs in its approach to hook_link and hook_nodeapi:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/print/print...
It's basically doing on hook_nodeapi() what you'd normally do on hook_link, or alternating - dunno [didn't have a lot of time to look into it].
We should file a bug report against print module for its failure to check the node build_mode in hook_nodeapi."
Comments
Comment #1
pwolanin commentedOn hook_nodeapi('view') the module should inspect and respect
$node->build_modeComment #2
jcnventuraIt's doing on hook_nodeapi stuff that would normally be done in hook_link, as there are two options on where to insert the link:
1. Normal link area: uses code in hook_link
2. Content corner: uses code in hook_nodeapi (which looks very similar to the code in hook_link indeed).
In D7, hook_link was abolished and I was able to simplify that code A LOT. If someone would wish to backport the hook_link banishment to D6, I would be more than happy to backport the simplification also. Until then, there's nothing that can be done about it.
As to build_mode, that was tried, merged and created enough problems (#349991: Use node build_mode instead of custom property for customizing node fields) that I reverted the patch. I am marking this as a duplicate because I would rather that issues related to build_mode be followed in that thread.
Please file specific issues if there's actually any bug that I can try to reproduce/fix.
João
Comment #3
jcnventuraI was writing my reply while pwolanin actually provided some information. I will take a look at it.
João
Comment #4
jcnventuraHow can I test this problem?
I have added the following conditions to the 'view' operation in the print_nodeapi calls:
But I have been unable to find a case where I can test if this is doing anything useful.
João
Comment #5
pwolanin commentedIf you put that condition, the link should no longer be added on previews.
Comment #6
jcnventuraThat's the problem.. I can't see the link in previews even without that condition..
Comment #7
pwolanin commentedAlso, what you are doing in print.pages.inc looks funny. On line 556 you have.
however, you should use the build mode already provided by core:
Comment #8
jcnventura@pwolanin: please note that the $node->printing flag is ancient (I think it was pre-Drupal 5).
The use of build_node is sufficiently new that for instance moshe weitzman submitted a patch in which the build_mode would be 'print' (#349991: Use node build_mode instead of custom property for customizing node fields).
While studying my reply to your comment in #1, I had also reached the conclusion that I should indeed define build_mode as NODE_BUILD_PRINT. Anyway, it's nice when someone that knows core Drupal a lot better than I do confirms that it is the correct mode.
Thanks,
João
Comment #9
jcnventuraCode to use build_mode in hook_nodeapi has just been committed.