The following warning occurs when I UPDATE content in my database. Creating it works fine.

user warning: 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 'WHERE nid = 9629' at line 3 query: UPDATE xmlsitemap_node SET previously_changed = last_changed, last_changed = 1240566086, priority_override = WHERE nid = 9629 in /home/esplanner/beta/includes/database.mysql.inc on line 174.

Clearly the "priority_override" value is missing in the SET part of the update.

Best,

Dick Munroe

Comments

munroe_richard’s picture

In: xmlsitemap_node.module

I "fixed" the problem by changing the UPDATE query to check explicitly for NULL and do the right thing by emitting a NULL in that event. The real problem is that the check for !== FALSE will be TRUE if $node->priority_override is NULL, so the fix should probably be for FALSE to change to NULL (or the operation changed to != instead of !==).

Here's what I did as a work around:

    case 'update':
      if (!isset($node->priority_override)) {
        $priority_override = db_result(db_query("SELECT priority_override FROM {xmlsitemap_node} WHERE nid = %d", $node->nid));
        $node->priority_override = $priority_override !== FALSE ? $priority_override : 'NULL';
      }
      db_query("UPDATE {xmlsitemap_node}
        SET previously_changed = last_changed, last_changed = %d, priority_override = %s
        WHERE nid = %d",
        $node->changed,
        ($node->priority_override === NULL ? 'NULL' : $node->priority_override),
        $node->nid
      );

Here's probably what should happen...

    case 'update':
      if (!isset($node->priority_override)) {
        $priority_override = db_result(db_query("SELECT priority_override FROM {xmlsitemap_node} WHERE nid = %d", $node->nid));
        $node->priority_override = $priority_override != FALSE ? $priority_override : 'NULL';
      }
      db_query("UPDATE {xmlsitemap_node}
        SET previously_changed = last_changed, last_changed = %d, priority_override = %s
        WHERE nid = %d",
        $node->changed,
        $node->priority_override,
        $node->nid
      );

Best,

Dick Munroe

Anonymous’s picture

Actually !== FALSE is correct since the check is for the existence of a DB row. The bug was in the store of NULL in priority_override in xmlsitemap_node to begin with.

Anonymous’s picture

I was wrong the bug is the lack of '' around the %s.

This

SET previously_changed = last_changed, last_changed = %d, priority_override = %s

should read

SET previously_changed = last_changed, last_changed = %d, priority_override = '%s'
Anonymous’s picture

Priority: Normal » Critical
avpaderno’s picture

Component: xmlsitemap.module » Code
Status: Active » Closed (duplicate)

priority_override is a number, not a string; the placeholder used is different because a trick implemented.

This report is a duplicate of #373621: $priority_override doesn't get any value.