If an error occurs during the creation of a new hosting client, then the node may created without a "uname" and there will be no entry in the {hosting_client} table for this client node.

If the client node is edited, and an internal name manually entered, then the update is not saved to the database when the node edit is submitted.

This is because the code in function hosting_client_update (file hosting_client.module) can only perform an update on that table (which of course achieves nothing if there is no original record).

The query that does the update should be replaced with the following code:

    if (db_result(db_query('SELECT uname from {hosting_client} WHERE vid=%d', $node->vid))) {
      db_query('UPDATE {hosting_client} SET nid=%d, uname="%s" WHERE vid=%d',
               $node->nid, $node->uname, $node->vid);
    } else {
      db_query('INSERT INTO {hosting_client} (vid, nid, uname) VALUES (%d, %d, "%s")',
               $node->vid, $node->nid, $node->uname);
    }
  }

Of course, the hosting client node should not have this problem, but it can happen, and allowing it to be manually fixed via a simple edit is useful defensive programming.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jlscott’s picture

Version: 6.x-1.6 » 6.x-1.x-dev
Status: Active » Needs review
FileSize
970 bytes

Patch attached.

jlscott’s picture

The above patch did not make it into release 6.x-1.7, so here is an updated patch.

Steven Jones’s picture

Status: Needs review » Postponed (maintainer needs more info)

If an error occurs during the creation of a new hosting client, then the node may created without a "uname" and there will be no entry in the {hosting_client} table for this client node.

I'd rather fix this bug, rather than try to deal with once consequence of it, could you describe what errors would cause this?

jlscott’s picture

I encountered this condition when I first started using the module "uc_hosting" that integrates support for selling hosting products using the Ubercart store.

There were a number of errors in the uc_hosting module at the time that resulted in incorrect creation of hosting clients. I have attempted to address these errors separately through changes to that module, but raised the issue here as I felt felt that defensive programming should be applied to the hosting module to deal with this situation.

I don't believe that I have had this problem recently.

ergonlogic’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (won't fix)

The 1.x branch is deprecated. If this remains an issue in 3.x, feel free to re-open.