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

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

How can one test this problem?

zenlan’s picture

Install Workbench Moderation or call hook_node_data in a test module?

function test_node_data($node) {
    $node->path['test'] = 'test';
    //$node->path['alias'] = 'test/alias';)
    //$node->path['source'] = 'test/source';)
}

Here is the relevant part of the Workbench Moderation code:

function test_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();
    $conditions = array('source' => 'node/' . $node->nid);
    if ($node->language != LANGUAGE_NONE) {
      $conditions['language'] = $node->language;
    }
    $path = path_load($conditions);
    if ($path === FALSE) {
      $path = array();
    }
    if (isset($node->path)) {
      $path += $node->path;
    }
    $path += array(
      'pid' => NULL,
      'source' => 'node/' . $node->nid,
      'alias' => '',
      'language' => isset($node->language) ? $node->language : LANGUAGE_NONE,
    );

    $node->path = $path;
  }
}
jcnventura’s picture

Status: Postponed (maintainer needs more info) » Active
shawn_smiley’s picture

StatusFileSize
new2.3 KB

Here is a patch for this that works in my local dev environment.

jcnventura’s picture

Status: Active » Needs review
swentel’s picture

Status: Needs review » Reviewed & tested by the community

Can 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.

jeremy’s picture

Part 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!

jcnventura’s picture

Status: Reviewed & tested by the community » Needs work

I 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.

rt_davies’s picture

I 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!

mangelp’s picture

I 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.

rbayliss’s picture

StatusFileSize
new1.13 KB

How 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.

rbayliss’s picture

StatusFileSize
new1.13 KB

Sorry, please disregard this double post.

Vlad Vinnikov’s picture

Thank you, this works for me

Svekke’s picture

Thank you , patch works for me!

jcnventura’s picture

@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.

Vlad Vinnikov’s picture

Line 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;

jcnventura’s picture

Status: Needs work » Fixed

Still 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.

Status: Fixed » Closed (fixed)

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