When using the print module it generates a page by running all the preprocess hooks and process hooks, including preprocess page.

It doesn't always have a proper node object in its variables though so you can end up with this:

Notice: Undefined property: stdClass::$type in edit_preprocess_page() (line 393 of /sites/all/modules/contrib/edit/edit.module).
Notice: Trying to get property of non-object in edit_preprocess_page() (line 394 of /sites/all/modules/contrib/edit/edit.module).

I would probably think that the edit module should not be doing anything in here for pages being printed so maybe something like:

<?php
if (empty($variables['print'])) {
  // Do edit stuff.
}
?>

I don't really love that solution because other modules could easily add a 'print' variable, however there isn't really a better way to determine when printing.

Possibly you could check for $variables['print']['content'] or something to be a bit more specific.

There is also a semi-related issue of the print module where it adds pseudo node objects to the $variables that don't have things like a node type, which is likely to cause issues with many modules, not just edit.

Not sure how you would want to handle this one.

Comments

rooby’s picture

Added a reference to the semi-related print issue.

rooby’s picture

Issue summary: View changes
Wim Leers’s picture

Wow … this is one confusing/bizarre issue! So it sounds like it's entirely the Print module's fault?

Wim Leers’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)
Wim Leers’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closing due to lack of response. Feel free to reopen.

rooby’s picture

Status: Closed (cannot reproduce) » Active

There is now a response from the print module maintainer in #2177797: Pseudo node used in preprocess functions when there isn't a real node that indicates that it might have to be worked around in the edit module.

Is this something you would be willing to commit?

Wim Leers’s picture

Title: Errors when using the print module » Add support for the Print module
Project: Edit » Quick Edit
Version: 7.x-1.0-rc1 » 7.x-1.x-dev
Category: Support request » Feature request

Sure! If you can provide a patch, I'll definitely commit it. Having read #2177797: Pseudo node used in preprocess functions when there isn't a real node, it sounds like a simple early-returning if-test.