User Updates causes error and wipes data from phplist user table

chewy_gore - March 3, 2009 - 10:18
Project:phplist Integration Module
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Upon installation and config, Synchronizing seems to work just fine. However after making changes to any user field and saving Drupal displays the following errors:

+++++++++++++++++
* user warning: Duplicate entry '' for key 2 query: INSERT INTO phplist_user_user (email, entered, htmlemail, confirmed, uniqid) VALUES('', NOW(), 1, 1, 'eb1e3216abd9cd49c6da82334aa16518') in /home/username/public_html/website.com/sites/all/modules/phplist/phplist.module on line 642.
* warning: Invalid argument supplied for foreach() in /home/username/public_html/website.com/sites/all/modules/phplist/phplist.module on line 654.

The changes have been saved.
+++++++++++++++++

After this the username/email address (possibly more data too) is/are missing from the phplist users table.

Any Ideas?

#1

paulbeaney - March 9, 2009 - 10:06

Hi,

Please try the latest D6-DEV version as this should address the problem you are facing.

Regards,

- Paul

#2

photographicon - March 19, 2009 - 06:58
Component:Miscellaneous» Code
Category:support request» bug report

Hi

I'm getting the same error using:

  • Drupal v6.10
  • Phplist v2.10.9 (also tested with v2.10.8)
  • Phplist Integration Module v6.x-1.x-dev (packaged 2009-03-14)

As per chewy_gore's report the initial synchronisation works, and repeatedly editing a user's email address in the Drupal profile is correctly auto-replicated to the associated phplist user. The problem comes when editing an item on a profile category other than on the built-in "Account" category... the following seems to be happening:

  • On first save, the email address of the associated phplist user is replaced with a null value ('')
  • On subsequent saves, the "Duplicate entry..." error reported by chewy_gore is produced.

I've not delved into the code... where is the Integration Module picking up the email address it uses?... from the form itself?... if so, the field named "mail" only appears on the "Account" category so would produce a null value on all other categories... just an idea ;-)

---
LITL.W/L
Dominic

#3

paulbeaney - March 19, 2009 - 15:16

Thanks for the info, Dominic.

What you are saying makes perfect sense. I know where the problem is now and will fix it asap.

Regards,

- Paul

#4

paulbeaney - March 19, 2009 - 15:40

Ok, I have just updated the D6-DEV release with a fix for this. If anyone can tell me why I would need to be using $user->init instead of $user->mail in _phplist_sync_user() when updating the user profile pages ($user->mail is empty...), I would be very interested to know!

Regards,

- Paul

#5

photographicon - March 19, 2009 - 16:39

Nice one Paul :) I'm not configured for direct CVS access so I shall try the update as soon as it appears in the dev snapshot.

---
LITL.W/L
Dominic

#6

photographicon - March 20, 2009 - 09:31

Hi Paul,

The dev snapshot of 2009-03-20 now contains your update... at first the reported problem seemed to have gone. However some deeper tests have shown it to still be there in a modified form. Additionally I have discovered a new (but possibly related) bug which I'll call the Buffered Data Problem. Here are some instructions to reproduce the issues:

For clarity, start with an empty user table in PHPlist and a single list, plus a populated Drupal user table and all the necessary settings / permissions. Do not do an initial synchronise. This way we keep the PHPlist user table short and sweet).

  1. Select for editing a Drupal user profile
  2. From the “Account” category press save – the user is correctly created in PHPlist. Subsequent presses of save do not have any further effect.
  3. From the “My newsletters” category press save a couple of times – correctly there is no effect.
  4. Click Subscribe – the user is correctly subscribed to the list in PHPlist. Subsequent presses of save do not have any further effect.

So far so good. But…

  1. From the “Account” category change the user’s email and press save – the email is correctly changed in both Drupal and PHPlist. Subsequent presses of save do not have any further effect.
  2. From the “My newsletters” category note that the user is still correctly subscribed.
  3. Press save – the user now incorrectly shows as not subscribed. However PHPList shows the user as being subscribed, but the email address has reverted to the original (prior to step 5).
  4. Press save a second time – no apparent effect in Drupal. However PHPlist now has a new user with a blank email address – this is not subscribed, whereas the original user is still subscribed.
  5. Press save a third time – we get the now familiar “user warning: Duplicate entry '' for key 2 query: INSERT INTO phplist_user_user (email, entered, htmlemail, confirmed, uniqid) VALUES('', NOW(), 1, 1, '6f09e5b4c8dae192e47846e84cb7658d') in /srv/data1/www/vhosts/999itstime/test/sites/all/modules/phplist/phplist.module on line 779.”

Clean up and perform another test...

  1. From the “Account” category change the user’s email back to its initial value and press save. Delete the 2 PHPlist users. Press save again in the Drupal profile to recreate the PHPlist user.
  2. From the profile category that holds the user’s real name field(s) change the real name and press save – incorrectly nothing changes in PHPList.
  3. Press save again – this time the real name change is reflected in PHPList. Repeatably there is a “one save” delay / buffering effect.

Hope you can fix these RSN... I'm working on a new Drupal site that needs to be integrated with an existing PHPlist install =)

---
LITL.W/L
Dominic

#7

paulbeaney - March 23, 2009 - 14:04

Hi Dominic,

A *huge* thak you for providing such clear, detailed and precise information. Exactly what a developer needs to debug things quickly and accurately.

I have managed to very quickly find the problem and I think (hope!) provide a definitive solution. I have to rework phplist_user() a bit - I hadn't quite mastered the diffrerent phases of the user update process. I have done lots of testing on my installation and it seems ok now, whichever of the user account tabs you update.

Please download the latest D6-DEV version once the update filters through and let me know how you get on?

Regards,

- Paul

#8

photographicon - March 25, 2009 - 04:43

Fantastico - it works :-)

Thanks for a speedy turn around. I'm new to Drupal, but have a 20 year background in IT management, and have amongst other things developed custom modules for my Gallery 2 installation (http://photographicon.com/)... so I know how to do testing and bug reports =)

LITL.W/L
Dominic
dom (a) photographicon.com

#9

paulbeaney - October 29, 2009 - 10:09
Status:active» fixed

#10

System Message - November 12, 2009 - 10:10
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.