I'm trying migrate from Pligg to Drigg. At the moment, I was able to transfer all the materials and users from Pligg with help 'Pligg -> Drigg importer', but there is a problem with the registration of the new users in Drupal.

After submitting the registration form, the system gives an error (look below) and a new user is NOT created, BUT a mail with the one-time login link still goes (!). As a result, the not registered user can change the password for different registered user (in my example with uid = 5).

This error message with wrong SQL query:

user warning: Duplicate entry '5' for key 1 query: INSERT INTO linux2_users (name, mail, pass, init, status, uid, created) VALUES ('777', 'oc@nm.ru', '9c2c94d1762a425f106d6420212bf663', 'oc@nm.ru', 1, 5, 1205704690) in /home/lighttpd/localhost/includes/database.mysql.inc on line 172.

After importing users from Pligg, Drupal try create new users with uid starting from 1 (at import proccess we have only one main user in system).

CommentFileSizeAuthor
#5 drigg.patch6.34 KBsikjoy

Comments

mercmobily’s picture

Hi,

I don't get this.
I observed the very same problem with my own import. And yet, the code seems to be right...
After importing the users, the import script has:

  // Reset the auto_increment so that it doesn't go bananas
  $max=db_result(db_query("SELECT max(uid) FROM {users}"));
  $max ++;
  db_query("UPDATE {sequences} set id=%d WHERE name='users_uid'",$max);

However, either one of these queries surely fails... randomly. Sometimes.
Ugh.

Anyway, if this happens, just run:

SELECT max(uid) FROM users;

See what comes out. If the number for example is 1200, then run:

UPDATE sequences set id=1200 WHERE name='users_uid';

BUT, just check that the sequence table is OK. For example in Drigg I have:

mysql> select * from sequences;
+-------------------------+-------+
| name                    | id    |
+-------------------------+-------+
| users_uid               |   250 | 
| menu_mid                |    80 | 
| vocabulary_vid          |     5 | 
| term_data_tid           |   230 | 
| node_nid                |  2296 | 
| node_revisions_vid      |  2294 | 
| votingapi_vote          |  2742 | 
| votingapi_cache         | 13680 | 
| comments_cid            |    31 | 
| aggregator_category_cid |     2 | 
| aggregator_feed_fid     |    10 | 
| aggregator_item_iid     |   484 | 
| files_fid               |     1 | 
+-------------------------+-------+
13 rows in set (0.00 sec)

If some of these are low (like node_nid), you have a problem...

Please report back here!

Merc

osminogin’s picture

Hey man, you have a error in you code

  // Reset the auto_increment so that it doesn't go bananas
  $max=db_result(db_query("SELECT max(uid) FROM {users}"));
  $max ++;
  db_query("UPDATE {sequences} set id=%d WHERE name='users_uid'",$max);

Look at my {sequences} tables fileds and you see why you db query wrong (for me)

+----------------------------+-------+
| name                       | id    |
+----------------------------+-------+
| linux2_users_uid           |     9 | 
| linux2_menu_mid            |    92 | 
| linux2_vocabulary_vid      |     3 | 
| linux2_node_revisions_vid  |   821 | 
| linux2_term_data_tid       |  1229 | 
| linux2_votingapi_vote      |  2686 | 
| linux2_votingapi_cache     | 19526 | 
| linux2_comments_cid        |     1 | 
| linux2_aggregator_feed_fid |     1 | 
| linux2_aggregator_item_iid |    20 | 
| linux2_node_nid            |     2 | 
+----------------------------+-------+
11 rows in set (0.00 sec)

I think this is not the only place in the Drigg code where there is a problem with database prefixes...
What do you think about the fact that Drupal sends a mail with registration data while it is not checking the user actually created?

// wbr

osminogin’s picture

Title: Can't create new users in Drupal after Pligg import » Bad support of Drupal database names with prefixes
krevetko% cd drigg
krevetko% grep -n db_query *.module | grep -v '{' | grep -v '}'
drigg.module:417:  $vid=db_result(db_query("select vid from term_data where tid=%d",$tid));
drigg.module:427:    $how_many=db_result(db_query("SELECT count(*) FROM term_node tn LEFT JOIN node n on tn.nid = n.nid WHERE tn.tid=%d and n.type='drigg'",$tid));
...skip...
drigg_pligg_import.module:276:    db_query("INSERT INTO `profile_fields` VALUES (1,'Occupation','profile_occupation','Your occupation','User information','','textfield',0,0,1,3,0,'')");
drigg_pligg_import.module:277:    db_query("INSERT INTO `profile_fields` VALUES (2,'Home page','profile_home_page','Your home page','User information','','textfield',0,0,1,3,0,'') ");
drigg_pligg_import.module:278:    db_query("INSERT INTO `profile_fields` VALUES (3,'Real name','profile_real_name','Your real name','User information','','textfield',0,0,1,3,0,'') ");
drigg_pligg_import.module:279:    db_query("INSERT INTO `profile_fields` VALUES (4,'Public email address','profile_public_email','Your public email address. Note: this will be shown to everybody!','Contact information','','textfield',0,0,1,3,0,'') ");
drigg_pligg_import.module:280:    db_query("INSERT INTO `profile_fields` VALUES (5,'AIM user name','profile_aim_user_name','Your AIM user name','Contact information','','textfield',0,0,1,3,0,'') ");
drigg_pligg_import.module:281:    db_query("INSERT INTO `profile_fields` VALUES (6,'MSN user name','profile_msn_user_name','Your MSN user name','Contact information','','textfield',0,0,1,3,0,'')  ");
drigg_pligg_import.module:282:    db_query("INSERT INTO `profile_fields` VALUES (7,'Yahoo user name','profile_yahoo_user_name','Your Yahoo user name','Contact information','','textfield',0,0,1,3,0,'') ");
drigg_pligg_import.module:283:    db_query("INSERT INTO `profile_fields` VALUES (8,'GTalk user name','profile_gtalk_user_name','Your GTalk user name','Contact information','','textfield',0,0,1,3,0,'') ");
drigg_pligg_import.module:284:    db_query("INSERT INTO `profile_fields` VALUES (9,'Skype user name','profile_skype_user_name','Your Skype user name','Contact information','','textfield',0,0,1,3,0,'') ");
drigg_pligg_import.module:341:  db_query("ALTER TABLE term_data AUTO_INCREMENT=%d",$max);
drigg_pligg_import.module:413:  db_query("ALTER TABLE node AUTO_INCREMENT=%d",$max);
drigg_pligg_import.module:419:  db_query("ALTER TABLE node_revisions AUTO_INCREMENT=%d",$max);

I hope that all places in code...

sikjoy’s picture

Assigned: Unassigned » sikjoy

accepting assignment

sikjoy’s picture

Status: Active » Needs review
StatusFileSize
new6.34 KB

osintsev, you egrep ninja you!

Keep in mind that this patch should be applied against 5.x-1.20. I don't have any pligg data to check this against. Could someone be so kind as to test this for me?

--sicjoy

sikjoy’s picture

Status: Needs review » Fixed

I see this patch has already been committed. Marking fixed.

mercmobily’s picture

Status: Fixed » Closed (fixed)