wrong primary key on hosting_client_user table

hutch - June 24, 2009 - 15:36
Project:Hosting
Version:6.x-0.2-beta1
Component:Code
Category:bug report
Priority:critical
Assigned:anarcat
Status:closed
Issue tags:aegir-0.2, aegir-6.x-0.2
Description

I realise that the client feature of hosting module is still buggy and this might solve things a bit
The db schema:

  $schema['hosting_client_user'] = array(
    'fields' => array(
      'user' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'client' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'contact_type' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array('user'),
  );

should be
  $schema['hosting_client_user'] = array(
    'fields' => array(
      'client' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'user' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'contact_type' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array('client'),
  );

this change got rid of the dreaded "Duplicate entry '1' for key 1" when adding a new client

HTH

#1

anarcat - June 24, 2009 - 15:45
Title:hosting_client_user table» wrong primary key on hosting_client_user table
Priority:normal» critical
Assigned to:Anonymous» anarcat
Status:active» needs work

I confirm the bug. This is an oversight in the #371769: allow for n to n and typed user/client relationships feature. The fix is trivial, I'll roll out a patch here for people to hotfix.

This affects only new installs, people upgrading from 0.1 will not suffer from the problem as the update_N function is correct.

AttachmentSize
501004_client_key_hotfix.patch 563 bytes

#2

anarcat - June 24, 2009 - 15:48
Status:needs work» fixed
Issue tags:-aegir-0.2-hotfix

I committed the fix on HEAD. Note that the problem only affects the Drupal 6 version, the Drupal 5 release is fine.

#3

hutch - June 24, 2009 - 16:37

I hope this doesn't cause problems with the insert statements in hosting_client.module, eg

    db_query('INSERT INTO {hosting_client_user} (client, user, contact_type) VALUES (%d, %d, "%s")', $node->nid, $user->uid, '');

This has user and client reversed in the table

#4

anarcat - June 24, 2009 - 16:41

I don't think that query will cause problems.

#5

System Message - July 8, 2009 - 16:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.