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
Comment #1
rooby CreditAttribution: rooby commentedAdded a reference to the semi-related print issue.
Comment #2
rooby CreditAttribution: rooby commentedComment #3
Wim LeersWow … this is one confusing/bizarre issue! So it sounds like it's entirely the Print module's fault?
Comment #4
Wim LeersComment #5
Wim LeersClosing due to lack of response. Feel free to reopen.
Comment #6
rooby CreditAttribution: rooby commentedThere 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?
Comment #7
Wim LeersSure! 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.