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

CommentFileSizeAuthor
#1 501004_client_key_hotfix.patch563 bytesanarcat

Comments

anarcat’s picture

Title: hosting_client_user table » wrong primary key on hosting_client_user table
Assigned: Unassigned » anarcat
Priority: Normal » Critical
Status: Active » Needs work
Issue tags: +aegir-6.x-0.2, +aegir-0.2, +aegir-0.2-hotfix
StatusFileSize
new563 bytes

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.

anarcat’s picture

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.

hutch’s picture

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

anarcat’s picture

I don't think that query will cause problems.

Status: Fixed » Closed (fixed)
Issue tags: -aegir-6.x-0.2, -aegir-0.2

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