- 🇺🇸United States smustgrave
Updated it for D10
Since it's a task does it still need a test?
The last submitted patch, 27: 2560237-27.patch, failed testing. View results →
- 🇮🇳India ankithashetty Karnataka, India
Tried to fix the phpunit errors by replacing the deprecated method
getUsername()
withgetAccountName()
.Thanks!
- Status changed to RTBC
over 1 year ago 4:27pm 29 January 2023 The last submitted patch, 29: 2560237-29.patch, failed testing. View results →
- Status changed to Needs work
over 1 year ago 5:29pm 31 January 2023 - 🇬🇧United Kingdom alexpott 🇪🇺🌍
+++ b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php @@ -298,14 +297,14 @@ protected function runDbTasks() { protected function replaceUser1() { - /** @var \Drupal\user\UserInterface $account */ - // @todo Saving the account before the update is problematic. - // https://www.drupal.org/node/2560237 - $account = User::load(1); - $account->setPassword($this->rootUser->pass_raw); - $account->setEmail($this->rootUser->getEmail()); - $account->setUsername($this->rootUser->getAccountName()); - $account->save(); + Database::getConnection()->update('users_field_data') + ->fields([ + 'name' => $this->rootUser->getAccountName(), + 'pass' => \Drupal::service('password')->hash($this->rootUser->pass_raw), + 'mail' => $this->rootUser->getEmail(), + ]) + ->condition('uid', 1) + ->execute();
I think we could do with a comment to explain why we're doing it like this - so no one thinks this is a good idea to copy and to put into real run-time code.