UpdatePathTestBase saves the root user before updates have run

Created on 31 August 2015, about 9 years ago
Updated 27 January 2023, almost 2 years ago

Problem/Motivation

While I'm opening this as major, as soon as we have a core or contrib update path that fails due to this code, it is going to become critical.

   // Replace User 1 with the user created here.
    // @todo: do this without saving the user account.
    /** @var \Drupal\user\UserInterface $account */
    $account = User::load(1);
    $account->setPassword($this->rootUser->pass_raw);
    $account->setEmail($this->rootUser->getEmail());
    $account->setUsername($this->rootUser->getUsername());
    $account->save();

We try not to save content entities in hook_update_N() because the schema might be out of sync, or hook invocations might rely on other schemas that also aren't outdated yet.

So our upgrade path test base class definitely shouldn't do it before updates have even run.

Proposed resolution

Any of these three would be better than the status quo:

1. Rely on the database dump having predictable values (admin, admin@example.com, pass) etc. and set $this->rootUser so they match.

2. Directly update the database tables with the values

Remaining tasks

User interface changes

API changes

Data model changes

Beta phase evaluation

<!--Uncomment the relevant rows for the issue. -->
📌 Task
Status

Needs review

Version

10.1

Component
Database update 

Last updated 3 days ago

No maintainer
Created by

🇬🇧United Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024