Warning: Illegal offset type in isset or empty in drupal_lookup_path() (line 158 of E:\xampp\htdocs\drupal-iwm\trunk\htdocs\www\includes\path.inc).
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 'node/14', 'visits/iwm-london', 'und', '0' AND language IN ('en', 'und') ORDER ' at line 1: SELECT source FROM {url_alias} WHERE alias = :alias_pid, :alias_source, :alias_alias, :alias_language, :alias_pathauto AND language IN (:language, :language_none) ORDER BY language ASC, pid DESC; Array ( [:language] => en [:language_none] => und [:alias_pid] => 443 [:alias_source] => node/14 [:alias_alias] => visits/iwm-london [:alias_language] => und [:alias_pathauto] => 0 ) in drupal_lookup_path() (line 176 of E:\xampp\htdocs\drupal-iwm\trunk\htdocs\www\includes\path.inc).
Debugged this error to discover that other modules are altering the node to load the path field with an array, e.g.
function workbench_moderation_node_data($node) {
...
// Path module is stupid and doesn't load its data in node_load.
if (module_exists('path') && isset($node->nid)) {
$path = array();
...
function pathauto_persist_entity_load($entities, $type) {
...
if (!isset($entities[$id]->path['pathauto'])) {
$entities[$id]->path['pathauto'] = $state;
Whatever the rights and wrongs of modules doing that, it might be wise to check the type of the path field.
function print_controller_html() {
...
//$nodepath = (isset($node->path)) ? drupal_get_normal_path($node->path) : 'node/' . $path;
$nodepath = 'node/' . $path;
if (isset($node->path)) {
if (is_array($node->path)) {
if (isset($node->path['alias'])) {
$nodepath = $node->path['alias'];
}
else if (isset($node->path['source'])) {
$nodepath = $node->path['source'];
}
}
else if (is_string($node->path)) {
$nodepath = drupal_get_normal_path($node->path);
}
}
Comments
Comment #1
jcnventuraHow can one test this problem?
Comment #2
zenlan commentedInstall Workbench Moderation or call hook_node_data in a test module?
Here is the relevant part of the Workbench Moderation code:
Comment #3
jcnventuraComment #4
shawn_smiley commentedHere is a patch for this that works in my local dev environment.
Comment #5
jcnventuraComment #6
swentel commentedCan confirm this works, is RTBC for me.
Note this is not only limited to workbench, we got the error when using page manager overriding the node page view.
Comment #7
jeremy commentedPart of the patch to print_pdf.pages.inc is no longer needed (and correctly fails to apply) -- but the rest of the patch appears necessary. Please apply!
Comment #8
jcnventuraI admit this may be necessary, however taking a look at the code, this is only fixing a path that is used when incrementing the view counter in the print module statistics tables (used for the Most* blocks).
I've installed workbench moderation and used it for a while, but it didn't trigger anything, nor did the ctools page manager.
Setting this to needs work, as I need to:
1. Add the same code to the print_mail module (there's a similar routine there to increment the counter).
2. Reproduce this problem.. I need detailed steps on how to see this problem, please.
Comment #9
rt_davies commentedI can confirm the bug and that applying the partial fix (to print.pages.inc only) from #4 fixes it.
As for how to reproduce, I'm not sure what information will be helpful. These are my Workbench and Print module versions: Workbench 7.x-1.0-beta6, Workbench Moderation 7.x-1.0-beta8 and Printer-friendly pages 7.x-1.0-alpha1. I'm using tcpdf.
To reproduce I merely visit a content node of a custom content type and click on the the printer friendly icon. The content opens as pdf in a new window, and all the content is converted to pdf successfully, but with the error messages from the op at the bottom along with a generic "Server encountered an error...try again" message.
Let me know what other info you think might help. And, as always, thanks for everyone's contributions!
Comment #10
mangelp commentedI can also confirm the bug and that part of the patch works, with the same module versions as rt_davies.
I've manually changed the code as the patch in #4 shows for print.pages.inc and I've also applied that same fix to print_pdf.pages.inc at line 57 and everything seems to work fine printing nodes as pdf. I didn't understand the changes the patch makes to print_pdf.pages.ind, so I haven't used that part.
Comment #11
rbayliss commentedHow about using entity_uri() to get a consistent path without an alias lookup? Note: I left the ctype_digit stuff out of this. It didn't appear to be broken for me.
Comment #12
rbayliss commentedSorry, please disregard this double post.
Comment #13
Vlad Vinnikov commentedThank you, this works for me
Comment #14
Svekke commentedThank you , patch works for me!
Comment #15
jcnventura@rbayliss: I haven't tested the patch, but by reading it, it seems wrong.. There's a reason why it tests if the thing is a node. Sometimes it isn't.. So entity_uri() is certainly not the solution.
The funny thing is, using Drupal 7.8 and trying to follow #9, and several types of "normal" usage having workbench, workbench_moderation and print installed, I've never seen this error anywhere.. I agree there might be a problem, but I need to check when the problem occurs if the fix fixes it properly.
Comment #16
Vlad Vinnikov commentedLine 37 may be incorrect. I get mysql syntax error message:
'node/171', 'content/test-vlad', 'en' AND language IN ('en', 'und')
ORDER BY la'
at line 1:
SELECT source
FROM {url_alias}
WHERE alias = 503, node/171, content/test-vlad, en AND language IN ('en', 'und')
ORDER BY language ASC, pid DESC;
Array ( [:language] => en [:language_none] => und [:alias_pid] => 503 [:alias_source] => node/171 [:alias_alias] => content/test-vlad [:alias_language] => en )
I corrected the problem as following:
watchdog("print_controller_html", 'node %node', array('%node' => print_r($node->path, true)));
//path content/test-vlad
watchdog("print_controller_html", 'path %path', array('%path' => print_r($path, true)));
//node Array ( [pid] => 503 [source] => node/171 [alias] => content/test-vlad [language] => en )
$nodepath = (isset($node->path)) ? drupal_get_normal_path($node->path['alias']) : 'node/' . $path;
Comment #17
jcnventuraStill couldn't find out to reproduce it, but I altered the code to simulate the error and fixed it properly..
The fix is now in git.