Hi all,

I don't know what I could do wrong but I am not able to make that upgrade. I have updated installation of 6.19. I've followed upgrade.txt procedure - even more - I have disable and uninstall all modules except the core ones. But after update.php executed I always get the same results:

The following updates returned messages
user module
Update #7000

    User passwords rehashed to improve security

Update #7002

    Migrated user time zones

node module
Update #7008

    Failed: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'weight' in 'order clause': SELECT r.rid AS rid, r.name AS name FROM {role} r INNER JOIN {role_permission} p ON r.rid = p.rid WHERE (p.permission = :db_condition_placeholder_0) ORDER BY weight ASC, name ASC; Array ( [:db_condition_placeholder_0] => administer nodes ) in user_roles() (line 2741 of /home/www/ciganek.cz/www/modules/user/user.module).

filter module
Update #7003

    Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-filter_autop' for key 1: INSERT INTO {filter} (format, module, name, weight, settings, status) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => filter [:db_insert_placeholder_2] => filter_autop [:db_insert_placeholder_3] => 2 [:db_insert_placeholder_4] => a:0:{} [:db_insert_placeholder_5] => 1 ) in filter_update_7003() (line 334 of /home/www/ciganek.cz/www/modules/filter/filter.install).

system module
Update #7007

    Inserted into {role_permission} the permissions for role ID 1, Inserted into {role_permission} the permissions for role ID 2, Inserted into {role_permission} the permissions for role ID 3

Update #7061

    Upload module has been migrated to File module.

Update #7067

    Failed: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'weight' in 'order clause': SELECT r.rid AS rid, r.name AS name FROM {role} r INNER JOIN {role_permission} p ON r.rid = p.rid WHERE (p.permission = :db_condition_placeholder_0) ORDER BY weight ASC, name ASC; Array ( [:db_condition_placeholder_0] => access administration pages ) in user_roles() (line 2741 of /home/www/ciganek.cz/www/modules/user/user.module).

Thanks for any suggestions.

Tomas

Comments

texis’s picture

Title: Can't upgrade from 6.19 to 7.0 » Can't upgrade from 6.20 to 7.0
gaurangagg’s picture

Did you tried disabling all (3rd party) modules ?

bfroehle’s picture

Status: Active » Needs review
StatusFileSize
new1.06 KB

texis: Try the attached patch. This should resolve some (but maybe not all) of your issues.

rfay’s picture

Status: Needs review » Needs work

Setting to CNW just because the testbot is testing over and over and we need to figure out why. OK to retest later.

texis’s picture

Yes, as I wrote. I have disabled (and even uninstalled) all modules exept the core ones.

pillarsdotnet’s picture

Status: Needs work » Needs review

The patch looks good to me.

texis’s picture

rfay’s picture

Version: 7.0 » 7.x-dev
Component: database system » database update system

I don't believe this needs to go into 8.x, retagging.

nato71’s picture

Summary: Completed patch review. The patch looks good. This is my first review, so please let me know if it needs any modifications or additions.

Pass 1: The "Coder module" pass

- Coding standards are being followed.

Pass 2: The "Bottom up" pass

- Code makes sense.

Pass 3: The "Comments-only" pass

- Comments passed spell check and adequately explain code additions.

Pass 4: The "Actually read the issue" pass

- Patch addresses PDOException present in error log provided by reporter.

Pass 5: The "Does it actually work?" pass

- Yes patch works:

patching file modules/node/node.install
Hunk #1 succeeded at 430 (offset -1 lines).
patching file modules/system/system.install
Hunk #1 succeeded at 1712 (offset -1 lines).

- No errors reported after applying patch and then completing upgrade from 6.20 to 7.x

The following updates returned messages
user module
Update #7000

    * User passwords rehashed to improve security

Update #7002

    * Migrated user time zones

Update #7014

    * Renamed the 'post comments without approval' permission to 'skip comment approval'.

system module
Update #7007

    * Inserted into {role_permission} the permissions for role ID 1, Inserted into {role_permission} the permissions for role ID 2

Pass 6: The "Put it all together" pass

- The patch looks good.

pillarsdotnet’s picture

@rfay -- If we want to support a straight upgrade from 6.x to 8.x then this code does need to go into 8.x. Otherwise, I agree with you.

rfay’s picture

@pillarsdotnet, we always require major-to-major upgrades, so a 6 to 8 would require 6 to 7 and then 7 to 8.

heine’s picture

Category: support » bug
pillarsdotnet’s picture

Status: Needs review » Reviewed & tested by the community
tstoeckler’s picture

This should probably be critical as its related to the upgrade path.

tstoeckler’s picture

Priority: Normal » Critical

Hmmm....

catch’s picture

Status: Reviewed & tested by the community » Needs work

system_update_7067() should not be calling user_roles(), instead there should be a _update_7000_user_roles() or similar function that does a direct query. It might still be necessary to add the dependency, but that should be fixed here as well.

sionescu’s picture

Status: Needs work » Needs review

#3: 1072450.patch queued for re-testing.

catch’s picture

This still needs work per #16.

catch’s picture

Status: Needs review » Needs work
eric_a’s picture

+  $dependencies['system'][7067] = array(
+    'user' => 7007,
+  );

We already have in 7.0:

  // Run all the critical user upgrades before everything.
  $dependencies['system'][7000] = array(
    'user' => 7008,
  );

What happened? Dependencies were not enforced or they were but system_update_7067() was allowed to run before system 7000()?

eric_a’s picture

Issue tags: +D7 upgrade path

Tagging.

I was going to add _update_7000_user_roles(), but what about #20?

catch’s picture

Title: Can't upgrade from 6.20 to 7.0 » system_update_7067() fails

Re-titling so it's more specific, not sure about that dependencies issue.

It would be good to have tests here that reproduce the bug.

eric_a’s picture

This could well be a broken upgrade path due to conflicting update dependency declarations.

Looking at taxonomy_update_dependencies() and user_update_dependencies() is enough to see such a conflict.

The first is trying to accomplish this ordering:

system_update_7049() ---> taxonomy_update_7002() ---> user_update_7006().

And this is from the second hook implementation:

  // Run all the critical user upgrades before everything.
  $dependencies['system'][7000] = array(
    'user' => 7008,
  );

To achieve all this one of the next two must happen:
system_update_7000() runs after system_update_7049()
user_update_7008() runs before user_update_7006()

The last type of scenario seems like one that an upgrade could survive sometimes. The first I don't think so.
What your dependency graph ends up like depends on which modules are installed I guess. (with D7 update dependencies.) Adding more dependencies would not fix the real problem but just hide it for certain cases.

eric_a’s picture

What? A user update depending on a taxonomy update..?

  $dependencies['user'][7006] = array(
    'taxonomy' => 7002,
  );
texis’s picture

OK - as an initiator I will add a few more news:

Meanwhile I moved from 6.19 to 6.22 and tried to upgrade to 7.2. Here is what happened:

1. Followed UPGRADE.txt (major update section)
2. Kept files/ and sites/ folders and one theme in themes/ - deleted everything else.
3. No modules active besides Drupal - core and optional. Garland Theme. Offline mode.
4. At the very begining of the update.php - there is many duplicit warning messages: Warning: Cannot use a scalar value as an array in path-to/modules/locale/locale.module on line 680 - I have not noticed I should disable localization?
5. Continue pressed.
6. The same page displaed but without locale warnings
7. Continue pressed again
8. 122 pending updateds
9. Apply pending updates pressed
10. Results:

node module

Update #7008

    Failed: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'weight' in 'order clause': SELECT r.rid AS rid, r.name AS name FROM {role} r INNER JOIN {role_permission} p ON r.rid = p.rid WHERE (p.permission = :db_condition_placeholder_0) ORDER BY weight ASC, name ASC; Array ( [:db_condition_placeholder_0] => administer nodes ) in user_roles() (line 2735 of /home/www/clients/client20/web51/web/modules/user/user.module).

filter module
Update #7003

    Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-filter_autop' for key 'PRIMARY': INSERT INTO {filter} (format, module, name, weight, settings, status) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => filter [:db_insert_placeholder_2] => filter_autop [:db_insert_placeholder_3] => 2 [:db_insert_placeholder_4] => a:0:{} [:db_insert_placeholder_5] => 1 ) in filter_update_7003() (line 333 of /home/www/clients/client20/web51/web/modules/filter/filter.install).

system module

Update #7067

    Failed: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'weight' in 'order clause': SELECT r.rid AS rid, r.name AS name FROM {role} r INNER JOIN {role_permission} p ON r.rid = p.rid WHERE (p.permission = :db_condition_placeholder_0) ORDER BY weight ASC, name ASC; Array ( [:db_condition_placeholder_0] => access administration pages ) in user_roles() (line 2735 of /home/www/clients/client20/web51/web/modules/user/user.module).

That's all for now. Seems I will have to stay with 6.22 :(

fabianx’s picture

@texis: But what about the patch in #3?

Even while it is not correct due to #16, but does it solve the issue? Can you upgrade with #3 applied?

Best Wishes,

Fabian

pillarsdotnet’s picture

zambrey’s picture

I just did my first D6 upgrade and patch at #3 worked for me.

texis’s picture

Title: system_update_7067() fails » Upgrade from 6.20 to 7.2 - Update #7003 still fails
Version: 7.x-dev » 7.2

@Fabianx: OK with the patch #3 used:

1. Still the same Warnings like mentioned in #25 point 4.
All seems to be OK but Update #7003

Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-filter_autop' for key 'PRIMARY': INSERT INTO {filter} (format, module, name, weight, settings, status) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => filter [:db_insert_placeholder_2] => filter_autop [:db_insert_placeholder_3] => 2 [:db_insert_placeholder_4] => a:0:{} [:db_insert_placeholder_5] => 1 ) in filter_update_7003() (line 333 of /home/www/clients/client20/web51/web/modules/filter/filter.install).

tlangston’s picture

subscribing

catch’s picture

@texis - could you make a sanitized copy of your database or similar available?

Or even just a dump of the Drupal 6 system table may help.

texis’s picture

StatusFileSize
new40.22 KB

OK this is my current filter table:


CREATE TABLE IF NOT EXISTS `filters` (
  `format` int(11) NOT NULL DEFAULT '0',
  `module` varchar(64) NOT NULL DEFAULT '',
  `delta` tinyint(4) NOT NULL DEFAULT '0',
  `weight` tinyint(4) NOT NULL DEFAULT '0',
  `fid` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`fid`),
  KEY `list` (`format`,`weight`,`module`,`delta`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=21 ;


INSERT INTO `filters` (`format`, `module`, `delta`, `weight`, `fid`) VALUES
(1, 'filter', 2, 0, 1),
(1, 'filter', 0, 1, 2),
(1, 'filter', 1, 2, 3),
(2, 'php', 0, 0, 4),
(3, 'filter', 1, 10, 20),
(3, 'filter', 2, 0, 19),
(1, 'filter', 1, 0, 7),
(1, 'filter', 0, 1, 8),
(1, 'php', 0, 2, 9),
(1, 'filter', 2, 10, 10),
(2, 'filter', 1, 0, 11),
(2, 'php', 0, 1, 12),
(2, 'filter', 2, 10, 13),
(1, 'filter', 3, 11, 14),
(3, 'filter', 3, 10, 18);

And system table export is attached. (There are comments in czech but it shouldn't be a problem ;-)

Texis

catch’s picture

@texis:

thanks for the db dump, that helps a bit.

Just restoring the filter dump failed for me before I even tried to upgrade, in the latest Drupal 6 there is a unique key 'fmd' on the filter table, this is not shown in your database dump.

See http://api.drupal.org/api/drupal/modules--filter--filter.install/functio...

So doing a clean install of D6 and then running the insert statement given above produced this error:


ERROR 1062 (23000): Duplicate entry '1-filter-1' for key 'fmd'

Which version of Drupal 6 are you trying to upgrade from? Should be in CHANGELOG.txt if nowhere else.

Also please post the results of this query:


MariaDB [d6]> SELECT schema_version FROM system WHERE name = 'system';
+----------------+
| schema_version |
+----------------+
|           6055 |
+----------------+
1 row in set (0.00 sec)

It looks like the fmd index was added in system_update_6043() - so to me it looks like you are running an older version of Drupal 6.

Alternatively you already had duplicates in your {filter} table before that update was run, in which case it may have failed to create the unique key.

A workaround for this would be ALTER IGNORE TABLE {filter} ADD UNIQUE KEY fmd (etc. etc.) on the D6 databse - however unless you're absolutely desperate to upgrade asap, please hold of doing this until we can figure out what's going on (or keep a full database backup of the database that can't be upgraded).

catch’s picture

@texis sorry reading through your posts you were indeed upgrading from 6.22, so it's not that this update never ran.

Do you remember when you first installed this site (and/or if it started on Drupal 5)?

I think the overall issue at least with this failure, is that we added some unique indexes in Drupal 6, on tables that previously had no unique index, and that update didn't attempt to fix duplicates when adding the index.

By default MySQL will fail to create that index and leave the duplicates in, unless you create it with ALTER IGNORE TABLE which is MySQL-specific syntax.

I'm not sure what we could do about this in Drupal 7- except perhaps try to create the index again, having manually removed duplicates first (or add IGNORE support to the MySQL driver for schema changes).

It looks like there's two distinct issues. I've opened #1211796: Drupal 6 -> 7 upgrade can fail due to unique indexes added in Drupal 6 for the duplicate key error, that is going to be a separate issue to #3.

--

Also looking through the taxonomy dependency that is a bit weird as Eric_A points out.

The idea of those reverse dependencies is that taxonomy module can see "I really want my update to run before user_update_7006() - because that was added after my update was written" - so not a dependency as such, but trying to enforce the order that the updates were added to the system. However all this stuff was added way, way after the actual updates were written, and before we had upgrade tests, so the potential for circular dependencies is definitely there.

texis’s picture

Thanks for all investigation effort. Yes - as far as I can remember I started the site with Drupal 5 so this might be the issue of Drupal 6 as you wrote.

I will try to do suggested workaround - I have set up the periodical backup of my site so there is no problem to get previous Drupal 6 database any time.

I will also try to upgrade different site which has started on Drupal 6 to check the upgrade process there.

The schema version is: 6055

catch’s picture

@texis - let's move this to #1211796: Drupal 6 -> 7 upgrade can fail due to unique indexes added in Drupal 6 - that is a proper core bug, but we should try to get the patch from #3 in here separately.

clemens.tolboom’s picture

StatusFileSize
new310.22 KB

Applying #3 gives us the image below which still did not fix the reported item from #717834: The dependencies declared in core's hook_update_dependencies() implementations aren't actually correct and #211182: Updates run in unpredictable order ... see the second image.

core-7-1072450-patched.png

drupal-7-hook-update-n.png

Image generated with http://drupal.org/project/graphapi and quick patch (to be committed)

drush php-eval "print_r(graphapi_to_dot(_graphapi_devel_system_module_install_layout()));" | dot -Tpng -o../core-7-1072450-patched.png
clemens.tolboom’s picture

catch’s picture

tknospdr’s picture

Status: Closed (duplicate) » Active

I'm trying to update from 6.28 and getting the same error:

Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0-php_code' for key 1: INSERT INTO {filter} (format, module, name, weight, settings, status) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => php [:db_insert_placeholder_2] => php_code [:db_insert_placeholder_3] => 2 [:db_insert_placeholder_4] => a:0:{} [:db_insert_placeholder_5] => 1 ) in filter_update_7003() (line 334 of /Volumes/Data/Users/david/Sites/fpo/modules/filter/filter.install).

I've tried the patch and I get this as output:

patching file modules/node/node.install
Hunk #1 FAILED at 431.
1 out of 1 hunk FAILED -- saving rejects to file modules/node/node.install.rej
patching file modules/system/system.install
Hunk #1 succeeded at 1706 with fuzz 2 (offset -7 lines).

Any help greatly appreciated.

Thanks,
David

clemens.tolboom’s picture

Status: Active » Closed (duplicate)

@tknospdr as this issue was marked as a duplicate you should not reopen it.x

Best think you can do is searching for _open_ issues and if not found try on IRC or file a new issue with cross reference to both this and #1211796: Drupal 6 -> 7 upgrade can fail due to unique indexes added in Drupal 6

parasolx’s picture

I'm having this bugs upgrading from D6 to D7.

Finally i found that the problem is some server unable to change table structure in {users} for "password" from 60 character to 128 characters.

So, I changed it manually in phpmyadmin and solved this problem.