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

pwolanin’s picture

On hook_nodeapi('view') the module should inspect and respect $node->build_mode

jcnventura’s picture

Status: Active » Closed (duplicate)

It'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

jcnventura’s picture

Status: Closed (duplicate) » Active

I was writing my reply while pwolanin actually provided some information. I will take a look at it.

João

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

How can I test this problem?

I have added the following conditions to the 'view' operation in the print_nodeapi calls:

isset($node->build_mode) && $node->build_mode == NODE_BUILD_NORMAL

But I have been unable to find a case where I can test if this is doing anything useful.

João

pwolanin’s picture

If you put that condition, the link should no longer be added on previews.

jcnventura’s picture

That's the problem.. I can't see the link in previews even without that condition..

pwolanin’s picture

Version: 6.x-1.4 » 6.x-1.x-dev
Status: Postponed (maintainer needs more info) » Active

Also, what you are doing in print.pages.inc looks funny. On line 556 you have.

  //alert other modules that we are generating a printer-friendly page, so they can choose to show/hide info
  $node->printing = TRUE;

however, you should use the build mode already provided by core:

modules/book/book.module:943:  $node->build_mode = NODE_BUILD_PRINT;
jcnventura’s picture

@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

jcnventura’s picture

Status: Active » Fixed

Code to use build_mode in hook_nodeapi has just been committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.