simplenews_update_6010 function does not handle the db update correctly when updating from 6009 (trying to add the error field again).

User warning is:
Duplicate column name 'error' query: ALTER TABLE simplenews_mail_spool ADD `error` TINYINT NOT NULL DEFAULT 0 in /var/www/.../includes/database.mysql-common.inc on line 298.

Failed: ALTER TABLE {simplenews_mail_spool} ADD `error` TINYINT NOT NULL DEFAULT 0

Comments

jfhovinne’s picture

Confirmed.

Tried to update from 1.0 to 1.2 with Drush and got the following:

The following updates are pending:

simplenews module
6009 - Addition of error to simplenews_mail_cache to mark an email error.
6010 - Correction of field size mismatch caused by simplenews_update_6009().
6200 - description not available

Do you wish to run all pending updates? (y/n): y
ALTER TABLE {simplenews_mail_spool} ADD `error` INT NOT NULL DEFAULT [success]
0
ALTER TABLE {simplenews_mail_spool} ADD `error` TINYINT NOT NULL [error]
DEFAULT 0
Finished performing updates. [ok]
An error occurred at function : drush_core_updatedb [error]

UPDATE finished.

pix_’s picture

this is happening to me too.
from 1.0 to 1.2
any suggestion?

sutharsan’s picture

StatusFileSize
new1.04 KB

I did not have may day when I made this patch :( The attached patch should fix it. You need to run update.php after you have applied this patch. If you test I will make a new release.

sutharsan’s picture

Status: Active » Needs review
daphisto’s picture

yep, same problem here. Going to try the patch.

j0nathan’s picture

Hi,
I updated from 1.0 to 1.2 and got the same error.

The output from update.php:

simplenews module
Update #6009

    * ALTER TABLE {simplenews_mail_spool} ADD `error` INT NOT NULL DEFAULT 0

Update #6010

    * Failed: ALTER TABLE {simplenews_mail_spool} ADD `error` TINYINT NOT NULL DEFAULT 0

Update #6200

    * No queries

I ran update.php two more times without any error before searching and finding out this issue.
I then applied the patch #3 and run update.php again, but it said "No updates available" for simplenews module and no update were done to the DB.

I don't know if the patch changed something or not. Is there a way to know if it worked?

FLAIR4IT’s picture

Hiya!

I'm a bit special; how do I apply this patch? Is simplenews broken UNTIL it's applied? Or is it just a bit smelly?

sutharsan’s picture

To apply a patch see: http://drupal.org/patch/apply

jfhovinne’s picture

@Sutharsan: thanks for the quick reply and patch.

Tested it with a backuped DB, and didn't get any error:

The following updates are pending:

 simplenews module                                                            
 6009 - Addition of error to simplenews_mail_cache to mark an email error.    
 6010 - Faulty update function. Corrected by the next one.   @see             
 simplenews_update_6011().                                                    
 6011 - Correction of field size mismatch caused by simplenews_update_6009(). 
 6200 - description not available                                             

Do you wish to run all pending updates? (y/n): y
ALTER TABLE {simplenews_mail_spool} ADD `error` INT NOT NULL DEFAULT [success]
0
ALTER TABLE {simplenews_mail_spool} CHANGE `error` `error` TINYINT   [success]
NOT NULL DEFAULT 0
Finished performing updates.                                         [ok]

UPDATE finished.

I'm currently testing the module itself.

Cheers.

j0nathan’s picture

Hi,
So in my case (#6), I ran again update.php but this time by manually selecting the update #6011 and it gave me this output without any error:

The following queries were executed
simplenews module
Update #6011

    * ALTER TABLE {simplenews_mail_spool} CHANGE `error` `error` TINYINT NOT NULL DEFAULT 0

Update #6200

    * No queries
esplinter’s picture

Hi,

I also got this error when tried to upgrade.

After the error, I restored my backup database to get the same db state than before the wrong update, applied the patch and tried to run update.php again and everything worked great.

many thanks!

sutharsan’s picture

Status: Needs review » Fixed

Thanks for testing. I committed the patch. If you encounter this error there is no cause for alarm and it will not cause simplenews to break.
Although it is not my habit to make frequent releases, I will break this now and make a 6.x-1.3 release to prevent many people running into this confusing bug.

Status: Fixed » Closed (fixed)

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