I have run into a problem trying to update a D6 site to D7. I have successfully updated all core modules without errors, and have a running installation. I previously had mollom running on the old site, and have the authorization key configured properly. The mollom module is enabled as well as dependent modules. The update script generates the following error:

Failed: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'quality' in 'where clause': UPDATE {mollom} SET quality=:db_update_placeholder_0 WHERE (quality = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => 9 [:db_condition_placeholder_0] => ) in mollom_update_7005() (line 564 of /home/pfloggin/domains/test.pflogging.com/public_html/sites/all/modules/mollom/mollom.install).

The fix seems to be attempting to 'Clean up and complete server response columns in {mollom}', but I know how messy such upgrade paths can be. My mollom table has a 'quality_score' field, but no quality field.

Attempts to configure mollom in spite of this error do not work. Any suggestions on how to proceed?

Thanks for your help.

Comments

sun’s picture

Am I guessing right that you previously had 6.x-2.x installed? (and not 6.x-1.x?)

i.e., upgrading from 6.x-2.x to 7.x-2.x?

sun’s picture

Status: Active » Closed (cannot reproduce)

Sorry, without further information this issue can only be closed as not reproducible.

Feel free to re-open this issue if you want to provide further information. Thanks.

sun’s picture

Issue summary: View changes

Updated to reflect examination of database.

dgrant’s picture

Version: 7.x-2.3 » 7.x-2.10
Issue summary: View changes
Status: Closed (cannot reproduce) » Active
dgrant’s picture

The problem is in update 7005:

  // Add {mollom}.spam.
  // When upgrading from 6.x-2.x, this is {mollom}.spamScore already.
  if (!db_field_exists('mollom', 'spam') && !db_field_exists('mollom', 'spamScore')) {
    db_add_field('mollom', 'spam', array(
      'description' => 'Text analysis spam check result.',
      'type' => 'int',
      'size' => 'tiny',
      'not null' => FALSE,
    ));
    // Fill {mollom}.spam with approximate values based on {mollom}.quality.
    // Note that this is just to have some values. 'quality' and 'spam' are
    // completely unrelated otherwise.
    // MOLLOM_ANALYSIS_SPAM (2)

    db_update('mollom')
      ->fields(array('spam' => 2))
      ->condition('quality', 0.5, '<')
      ->execute();
    // MOLLOM_ANALYSIS_UNSURE (3)
    db_update('mollom')
      ->fields(array('spam' => 3))
      ->condition('quality', 0.5, '=')
      ->execute();
    // MOLLOM_ANALYSIS_HAM (1)
    db_update('mollom')
      ->fields(array('spam' => 1))
      ->condition('quality', 0.5, '>')
      ->execute();
  }

The condition('quality') fails because there is no quality field, it is now qualityScore (since update 6200).

dgrant’s picture

StatusFileSize
new1020 bytes

patch attached, tested and it works.

dgrant’s picture

There is another bug during upgrade, update 7008 fails. Patch coming.

dgrant’s picture

StatusFileSize
new6.77 KB

New patch. Lots more issues with 6->7 upgrade fixed.

dgrant’s picture

dgrant’s picture

Category: Support request » Bug report
Priority: Normal » Major

Not sure why this wasn't a bug report.

TonyBy’s picture

As at #6 'update 7008' was failing so installed patch at #7. This got me a lot further, instead of 18 pending updates for mollom it went down to 1 but this one keeps failing:

The following updates returned messages
mollom module
Update #7213

    Failed: DatabaseSchemaObjectExistsException: Cannot rename field <em class="placeholder">mollom</em>.<em class="placeholder">spamScore</em> to <em class="placeholder">spam_score</em>: target field already exists. in DatabaseSchema_mysql->changeField() (line 457 of /var/www/html/awlbackup/includes/database/mysql/schema.inc).
eshta’s picture

It seems like a lot of this patch and some of the problems are based on updates being run multiple times. There are some field names that get renamed and the re-runs already have those fields renamed.

dgrant’s picture

Yep, the problems are based on the fact that the mollom 6.x latest will give you update 6212 which renames all the fields to use underscores instead of camelcase. This causes many of the 7xxx series patches to fail.

TonyBy, I'm not sure why you would still have a spamScore column and a spam_score column. I will add some extra code to my patch to cover the corner case you seem to have found yourself in.

TonyBy’s picture

I dropped the old named duplicate fields that had caused the error.

Then I renamed the following 4 fields in the 'mollom' table with what update 7213 expected to find:

'spam_score' became 'spamScore',
'spam_classification' became 'spamClassification',
'quality_score' became 'qualityScore',
'profanity_score' became 'profanityScore',

Then I ran update.php. It completed without error.

I also had to drop the spurious ‘profanity’ field. Don’t know where that came from.

I enabled the module and can visit its configuration page with problems.

dgrant’s picture

TonyBy, you mean "without problems"?

Submitting updated patch now.

dgrant’s picture

StatusFileSize
new9.99 KB

Latest patch. Updates some of the comments and does more paranoid checking before changing or adding columns.

dgrant’s picture

dgrant’s picture

Tested and works for me with 6.x (latest release) -> 7.x (latest release) upgrade

eshta’s picture

Status: Active » Needs work
+++ b/sites/all/modules/mollom/mollom.install
@@ -1222,9 +1241,8 @@ function mollom_update_7212() {
+  if (db_field_exists('mollom', 'contentId') && !db_field_exists('mollom', 'content_id')) {

Let's also add a check for db_index_exists before dropping for both content and captcha ids. This should have been included the first time around as it is. Other than that it looks pretty good to me.

dgrant’s picture

StatusFileSize
new10.4 KB
dgrant’s picture

Most recent patch updated. Please test and/or commit.

dgrant’s picture

I incorporated eshta's feedback. Thanks.

eshta’s picture

Status: Needs work » Needs review

Go testbots!

Status: Needs review » Needs work

The last submitted patch, 19: mollom.install.patch, failed testing.

dgrant’s picture

StatusFileSize
new10.31 KB

Fixed paths in patch.

eshta’s picture

Status: Needs work » Needs review

Setting status back to "Needs review" to run the test bots :-)

dgrant’s picture

Is the patch good to put the -dev version or something now? Thanks.

dgrant’s picture

Has this been committed yet?

dgrant’s picture

Has this been committed yet?

  • eshta committed 1a58dd4 on 7.x-2.x authored by dgrant
    Issue #1881578 by dgrant, TonyBy: Upgrade problems from drupal 6 to...
eshta’s picture

Status: Needs review » Fixed

So sorry for the silence there. I was battling an issue with the 7.x-2.x branch that was causing test failures for all submitted patches. That has been fixed - and now this has been committed. Thanks for your work :-)

Status: Fixed » Closed (fixed)

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