Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D7 upgrade: Error in upgrade related to "redirect" and "user_roles" upgrade #6367

Closed
irinaz opened this issue Jan 15, 2024 · 12 comments
Closed

Comments

@irinaz
Copy link

irinaz commented Jan 15, 2024

Description of the bug

I am running an upgrade for a site that does not have any custom modules and I see the following errors in update of the redirect module and in user_roles

Error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'role' in 'field list': SELECT role FROM {users_roles} WHERE uid = :uid; Array ( [:uid] => 1 )

Error message
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'langcode' in 'where clause': SELECT redirect.`rid` AS `rid` FROM {redirect} redirect WHERE ( (`source` LIKE :db_condition_placeholder_0 ESCAPE '\\') OR (`source` = :db_condition_placeholder_1) )AND (`langcode` IN (:db_condition_placeholder_2, :db_condition_placeholder_3)) ; Array ( [:db_condition_placeholder_0] => home [:db_condition_placeholder_1] => [:db_condition_placeholder_2] => en [:db_condition_placeholder_3] => und ) in redirect_load_by_source() (line 477 of /Users/irinazaks/Sites/localhost/coa/core/modules/redirect/redirect.module).
Warning: Invalid argument supplied for foreach() in backdrop_alter() (line 1178 of /Users/irinazaks/Sites/localhost/coa/core/includes/module.inc).

Steps To Reproduce

  1. Set up new backdrop
  2. intall backup and migrate module
  3. import D7 database

At this step I sometimes see error related to users_roles

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'role' in 'field list': SELECT role FROM {users_roles} WHERE uid = :uid; Array ( [:uid] => 1 )

and sometimes

Error message
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'langcode' in 'where clause': SELECT redirect.`rid` AS `rid` FROM {redirect} redirect WHERE ( (`source` LIKE :db_condition_placeholder_0 ESCAPE '\\') OR (`source` = :db_condition_placeholder_1) )AND (`langcode` IN (:db_condition_placeholder_2, :db_condition_placeholder_3)) ; Array ( [:db_condition_placeholder_0] => home [:db_condition_placeholder_1] => [:db_condition_placeholder_2] => en [:db_condition_placeholder_3] => und ) in redirect_load_by_source() (line 477 of /Users/irinazaks/Sites/localhost/coa/core/modules/redirect/redirect.module).
Warning: Invalid argument supplied for foreach() in backdrop_alter() (line 1178 of /Users/irinazaks/Sites/localhost/coa/core/includes/module.inc).

The second error does not show up always, I can provide db where I get this error ( I cannot attach it to this issue due to privacy issues)

If I go to /core/update.php I can begin db upgrade

Actual behavior

I get these errors when I try to run /core/update.php?op=info

Expected behavior

Upgrade continues.

Additional information

Add any other information that could help, such as:

  • Backdrop CMS version: 1.26
  • Web server and its version: using MAMP
  • PHP version: both 8 and 7.4
  • Database sever: MySQL 5
  • Operating System and its version: Mac
  • Browser(s) and their versions: any
@irinaz irinaz changed the title D7 upgrade: Error in redirect upgrade D7 upgrade: Error in upgrade related to "redirect" and "user_roles" upgrade Jan 15, 2024
@irinaz
Copy link
Author

irinaz commented Jan 18, 2024

I was able to move forward with Upgrade by going to /core/update.php after I renamed column to langcode

ALTER TABLE redirectCHANGElanguage langcode VARCHAR(12) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ‘und’ COMMENT ‘The language this redirect is for; if blank, the alias will be used for unknown languages.’;

This is new bug since release 1.26, it was reproduced on several projects from different developers.

@indigoxela
Copy link
Member

I was able to move forward with Upgrade by going to /core/update.php after I renamed column to langcode

However, this renaming of db columns happens automatically when upgrading from Drupal.

If it did not happen, something went substantially wrong with the upgrade, I guess. But there should have been lots of nagging.

As a first step we need a way to reproduce the problem. My suspicion is, that some contrib broke the upgrade workflow at some point. But we need to know which one.

@irinaz
Copy link
Author

irinaz commented Jan 21, 2024

I did more testing locally (with updated steps to reproduce), and some D7 db upgrade redirect table correctly and some do not - @indigoxela , thank you for pointing me in the right direction. I will try to identify which module were in the db that fails redirect upgrade path comparing to those who upgrade correctly.

The following error I get on almost every update.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'role' in 'field list': SELECT role FROM {users_roles} WHERE uid = :uid; Array ( [:uid] => 1 )

@indigoxela
Copy link
Member

The following error I get on almost every update.

Occasionally when upgrading, or always after the upgrade? Because if it's the latter, your users_roles table schema is wrong (not updated).

Please share your findings re failing setups, when you figure out.

@izmeez
Copy link

izmeez commented Jan 23, 2024

Does this bug have anything to do with issue #5496

@irinaz
Copy link
Author

irinaz commented Jan 23, 2024

@izmeez , issue #5496 was caused by version of MySQL and has been fixed. It is very similar to this one, but not the same

@herbdool
Copy link

I saw this on an upgrade too, but there were quite a few modules so hard to debug. Would be good to start with a fresh D7 install and attempt to recreate the bug. And start adding other modules until it appears.

@docwilmot
Copy link
Contributor

Set up new backdrop
intall backup and migrate module
import D7 database

This is expected though @irinaz. You should not be able to restore a Backdrop site with a D7 database without expecting errors. What I suspect happens is that after BAM finishes and tries to reload the page, Backdrop calls _backdrop_session_read() (this is called on every page load), and that function looks for the roles column in the users_roles table, but because youve just swapped the B database with a D7 one, that column doesnt exist (D7 has a rid column instead).

Note this is avoided for example in D2B module by immediate hard redirect to update.php without trying to load Backdrop yet.

@irinaz
Copy link
Author

irinaz commented Jan 24, 2024

@docwilmot , your explanation is very helpful for understanding process of upgrade, but does not explain the issue in "redirect" table. I am working on setting up migrations that would allow me to capture correct scenario where this bug happens.

@docwilmot
Copy link
Contributor

For the redirect error are you performing the same steps:

Set up new backdrop
intall backup and migrate module
import D7 database

@jenlampton
Copy link
Member

@irinaz there is no bug here. There is no issue with the redirect table in Backdrop and there is no issue with the redirect table in Drupal. The problem you are experiencing is because you are expecting Backdrop to know how to use Drupal's redirect table.

You cannot import a Drupal 7 database into a Backdrop site in the same way that you cannot import a Drupal 7 database into a Drupal 8 website or a WordPress website. The code and the database need to know how to communicate with each other.

When upgrading from Drupal to Backdrop the database updates need to be completed before the website communicated with the databse. If you follow the steps for how to upgrade (in the correct order), you will not encounter this error because the Drupal database (including the redirect table) will be converted into a Backdrop database before Backdrop needs to use it.

Set up new backdrop
install backup and migrate module
import D7 database

This is not a workflow that is supported (or expected to work). Proceed at your own risk!

I'm going to close this issue.

@irinaz
Copy link
Author

irinaz commented May 9, 2024

@jenlampton , thanks. Module d2b has proven to be a great tool, so I will move this question into https://github.com/backdrop-contrib/d2b_migrate/
When you say "migrate in correct order" I am not clear what you mean. If we are trying to support site builders with D7 to Backdrop migrations you cannot expect them to use mysql command from terminal.
I have run over ten migrations without any problems using D2B module. I hope that we can figure out solution one way or another.
Thanks again!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants