diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index aa21673..686a785 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1898,7 +1898,7 @@ function drupal_get_user_timezone() { global $user; $config = config('system.timezone'); - if ($user && $config->get('user.configurable') && $user->id() && $user->getTimezone()) { + if ($user && $config->get('user.configurable') && $user->isAuthenticated() && $user->getTimezone()) { return $user->getTimezone(); } else { diff --git a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php index 6948642..08cc693 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php @@ -269,7 +269,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac ); } - $name = $new_translation ? $GLOBALS['user']->name : user_load($entity->translation[$form_langcode]['uid'])->name; + $name = $new_translation ? $GLOBALS['user']->getUsername() : user_load($entity->translation[$form_langcode]['uid'])->getUsername(); $form['content_translation']['name'] = array( '#type' => 'textfield', '#title' => t('Authored by'), diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php index bfe2414..d9604cc 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php @@ -96,8 +96,8 @@ function testRevisions() { // Attach the second file to a user. $user = $this->drupalCreateUser(); - $user->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['target_id'] = $node_file_r3->id(); - $user->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['display'] = 1; + $user->$field_name->target_id = $node_file_r3->id(); + $user->$field_name->display = 1; $user->save(); $this->drupalGet('user/' . $user->id() . '/edit'); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php index 5107337..1200907 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php @@ -72,7 +72,7 @@ function testNodeAccessBasic() { $this->drupalLogin($this->webUser); foreach (array(0 => 'Public', 1 => 'Private') as $is_private => $type) { $edit = array( - 'title' => t('@private_public Article created by @user', array('@private_public' => $type, '@user' => $this->webUser->name)), + 'title' => t('@private_public Article created by @user', array('@private_public' => $type, '@user' => $this->webUser->getUsername())), ); if ($is_private) { $edit['private'] = TRUE; diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php index 8abf538..b31f891 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php @@ -265,7 +265,7 @@ function _testUserRDFa() { // User name. $expected_value = array( 'type' => 'literal', - 'value' => $this->adminUser->name, + 'value' => $this->adminUser->getUsername(), ); $this->assertTrue($graph->hasProperty($this->authorUri, 'http://schema.org/name', $expected_value), "User name was found (schema:name) on user page."); @@ -339,7 +339,7 @@ function _testCommonNodeProperties($graph, $node, $message_prefix) { // Author name. $expected_value = array( 'type' => 'literal', - 'value' => $this->adminUser->name, + 'value' => $this->adminUser->getUsername(), ); $this->assertTrue($graph->hasProperty($this->authorUri, 'http://schema.org/name', $expected_value), "$message_prefix author name was found (schema:name)."); } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/UserAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/UserAttributesTest.php index c5ba5f8..06c3e7f 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/UserAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/UserAttributesTest.php @@ -73,7 +73,7 @@ function testUserAttributesInMarkup() { // User name. $expected_value = array( 'type' => 'literal', - 'value' => $user2->name, + 'value' => $user2->getUsername(), ); $this->assertTrue($graph->hasProperty($account_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'User name found in RDF output (foaf:name).'); @@ -100,7 +100,7 @@ function testUserAttributesInMarkup() { // User name. $expected_value = array( 'type' => 'literal', - 'value' => $user2->name, + 'value' => $user2->getUsername(), ); $this->assertTrue($graph->hasProperty($account_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'User name found in RDF output (foaf:name).'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php index d8412b1..a05d9db 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php @@ -52,6 +52,9 @@ function setUp() { 'Long month name' => array('March' => 'marzo'), )); + $language = new Language(array('id' => static::LANGCODE)); + language_save($language); + $this->refreshVariables(); } @@ -129,7 +132,7 @@ function testFormatDate() { $real_user = $user; $user = user_load($test_user->id(), TRUE); $real_language = $language_interface->id; - $language_interface->id = $user->preferred_langcode; + $language_interface->id = $user->getPreferredLangcode(); // Simulate a Drupal bootstrap with the logged-in user. date_default_timezone_set(drupal_get_user_timezone()); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php index 90ac1da..ae99e9d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php @@ -124,12 +124,12 @@ public function testQuery() { // This returns the 0th entity as that's only one pointing to the 0th // account. $this->queryResults = $this->factory->get('entity_test') - ->condition("user_id.entity.name", $this->accounts[0]->name) + ->condition("user_id.entity.name", $this->accounts[0]->getUsername()) ->execute(); $this->assertResults(array(0)); // This returns the 1st and 2nd entity as those point to the 1st account. $this->queryResults = $this->factory->get('entity_test') - ->condition("user_id.entity.name", $this->accounts[0]->name, '<>') + ->condition("user_id.entity.name", $this->accounts[0]->getUsername(), '<>') ->execute(); $this->assertResults(array(1, 2)); // This returns all three entities because all of them point to an diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php index dd9bcf9..2503aa5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php @@ -69,7 +69,7 @@ public function testUserPictureUpgrade() { // Check the user picture and file usage record. $user = user_load(1); - $file = file_load($user->user_picture[Language::LANGCODE_NOT_SPECIFIED][0]['target_id']); + $file = $user->user_picture->entity; $this->assertEqual('public://user_pictures_dir/faked_image.png', $file->getFileUri()); $usage = file_usage()->listUsage($file); $this->assertEqual(1, $usage['file']['user'][1]); diff --git a/core/modules/system/tests/modules/database_test/database_test.module b/core/modules/system/tests/modules/database_test/database_test.module index 2d14ab6..b390004 100644 --- a/core/modules/system/tests/modules/database_test/database_test.module +++ b/core/modules/system/tests/modules/database_test/database_test.module @@ -231,11 +231,10 @@ function database_test_theme_tablesort($form, &$form_state) { $options = array(); - $status = array(t('blocked'), t('active')); foreach (user_load_multiple($uids) as $account) { $options[$account->id()] = array( 'username' => check_plain($account->getUsername()), - 'status' => $status[$account->status], + 'status' => $account->isActive() ? t('active') : t('blocked'), ); } diff --git a/core/modules/user/lib/Drupal/user/RegisterFormController.php b/core/modules/user/lib/Drupal/user/RegisterFormController.php index 7c4a7a9..d5f5024 100644 --- a/core/modules/user/lib/Drupal/user/RegisterFormController.php +++ b/core/modules/user/lib/Drupal/user/RegisterFormController.php @@ -90,7 +90,7 @@ public function submit(array $form, array &$form_state) { */ public function save(array $form, array &$form_state) { $account = $this->entity; - $pass = $account->pass; + $pass = $account->getPassword(); $admin = $form_state['values']['administer_users']; $notify = !empty($form_state['values']['notify']); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php b/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php index 01cbe05..1dd89b2 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php @@ -40,9 +40,9 @@ function testUserAdmin() { $admin_user = $this->drupalCreateUser(array('administer users')); $this->drupalLogin($admin_user); $this->drupalGet('admin/people'); - $this->assertText($user_a->name, 'Found user A on admin users page'); - $this->assertText($user_b->name, 'Found user B on admin users page'); - $this->assertText($user_c->name, 'Found user C on admin users page'); + $this->assertText($user_a->getUsername(), 'Found user A on admin users page'); + $this->assertText($user_b->getUsername(), 'Found user B on admin users page'); + $this->assertText($user_c->getUsername(), 'Found user C on admin users page'); $this->assertText($admin_user->getUsername(), 'Found Admin user on admin users page'); // Test for existence of edit link in table. @@ -50,23 +50,23 @@ function testUserAdmin() { $this->assertRaw($link, 'Found user A edit link on admin users page'); // Filter the users by name/e-mail. - $this->drupalGet('admin/people', array('query' => array('user' => $user_a->name))); + $this->drupalGet('admin/people', array('query' => array('user' => $user_a->getUsername()))); $result = $this->xpath('//table/tbody/tr'); $this->assertEqual(1, count($result), 'Filter by username returned the right amount.'); - $this->assertEqual($user_a->name, (string) $result[0]->td[1]->span, 'Filter by username returned the right user.'); + $this->assertEqual($user_a->getUsername(), (string) $result[0]->td[1]->span, 'Filter by username returned the right user.'); $this->drupalGet('admin/people', array('query' => array('user' => $user_a->getEmail()))); $result = $this->xpath('//table/tbody/tr'); $this->assertEqual(1, count($result), 'Filter by username returned the right amount.'); - $this->assertEqual($user_a->name, (string) $result[0]->td[1]->span, 'Filter by username returned the right user.'); + $this->assertEqual($user_a->getUsername(), (string) $result[0]->td[1]->span, 'Filter by username returned the right user.'); // Filter the users by permission 'administer taxonomy'. $this->drupalGet('admin/people', array('query' => array('permission' => 'administer taxonomy'))); // Check if the correct users show up. - $this->assertNoText($user_a->name, 'User A not on filtered by perm admin users page'); - $this->assertText($user_b->name, 'Found user B on filtered by perm admin users page'); - $this->assertText($user_c->name, 'Found user C on filtered by perm admin users page'); + $this->assertNoText($user_a->getUsername(), 'User A not on filtered by perm admin users page'); + $this->assertText($user_b->getUsername(), 'Found user B on filtered by perm admin users page'); + $this->assertText($user_c->getUsername(), 'Found user C on filtered by perm admin users page'); // Filter the users by role. Grab the system-generated role name for User C. $roles = $user_c->getRoles(); @@ -74,9 +74,9 @@ function testUserAdmin() { $this->drupalGet('admin/people', array('query' => array('role' => reset($roles)))); // Check if the correct users show up when filtered by role. - $this->assertNoText($user_a->name, 'User A not on filtered by role on admin users page'); - $this->assertNoText($user_b->name, 'User B not on filtered by role on admin users page'); - $this->assertText($user_c->name, 'User C on filtered by role on admin users page'); + $this->assertNoText($user_a->getUsername(), 'User A not on filtered by role on admin users page'); + $this->assertNoText($user_b->getUsername(), 'User B not on filtered by role on admin users page'); + $this->assertText($user_c->getUsername(), 'User C on filtered by role on admin users page'); // Test blocking of a user. $account = user_load($user_c->id()); @@ -90,9 +90,9 @@ function testUserAdmin() { // Test filtering on admin page for blocked users $this->drupalGet('admin/people', array('query' => array('status' => 2))); - $this->assertNoText($user_a->name, 'User A not on filtered by status on admin users page'); - $this->assertNoText($user_b->name, 'User B not on filtered by status on admin users page'); - $this->assertText($user_c->name, 'User C on filtered by status on admin users page'); + $this->assertNoText($user_a->getUsername(), 'User A not on filtered by status on admin users page'); + $this->assertNoText($user_b->getUsername(), 'User B not on filtered by status on admin users page'); + $this->assertText($user_c->getUsername(), 'User C on filtered by status on admin users page'); // Test unblocking of a user from /admin/people page and sending of activation mail $editunblock = array(); @@ -108,10 +108,10 @@ function testUserAdmin() { $account1 = user_load($user_d->id(), TRUE); $this->drupalPost('user/' . $account1->id() . '/edit', array('status' => 0), t('Save')); $account1 = user_load($user_d->id(), TRUE); - $this->assertEqual($account1->status, 0, 'User D blocked'); + $this->assertTrue($account1->isBlocked(), 'User D blocked'); $this->drupalPost('user/' . $account1->id() . '/edit', array('status' => TRUE), t('Save')); $account1 = user_load($user_d->id(), TRUE); - $this->assertEqual($account1->status, 1, 'User D unblocked'); + $this->assertTrue($account1->isActive(), 'User D unblocked'); $this->assertMail("to", $account1->getEmail(), "Activation mail sent to user D"); } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php b/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php index 99bee6e..165b042 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php @@ -102,10 +102,10 @@ function testWhosOnlineBlock() { $content = entity_view($block, 'block'); $this->drupalSetContent(render($content)); $this->assertRaw(t('2 users'), 'Correct number of online users (2 users).'); - $this->assertText($user1->name, 'Active user 1 found in online list.'); - $this->assertText($user2->name, 'Active user 2 found in online list.'); - $this->assertNoText($user3->name, 'Inactive user not found in online list.'); - $this->assertTrue(strpos($this->drupalGetContent(), $user1->name) > strpos($this->drupalGetContent(), $user2->name), 'Online users are ordered correctly.'); + $this->assertText($user1->getUsername(), 'Active user 1 found in online list.'); + $this->assertText($user2->getUsername(), 'Active user 2 found in online list.'); + $this->assertNoText($user3->getUsername(), 'Inactive user not found in online list.'); + $this->assertTrue(strpos($this->drupalGetContent(), $user1->getUsername()) > strpos($this->drupalGetContent(), $user2->getUsername()), 'Online users are ordered correctly.'); } /** diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php index 547f77f..addc7ae 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php @@ -49,8 +49,8 @@ function testUserCancelWithoutPermission() { $this->assertNoRaw(t('Cancel account'), 'No cancel account button displayed.'); // Attempt bogus account cancellation request confirmation. - $timestamp = $account->login; - $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->getLastLoginTime())); + $timestamp = $account->getLastLoginTime(); + $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())); $this->assertResponse(403, 'Bogus cancelling request rejected.'); $account = user_load($account->id()); $this->assertTrue($account->isActive(), 'User account was not canceled.'); @@ -96,7 +96,7 @@ function testUserCancelUid1() { // Verify that uid 1's account was not cancelled. $user1 = user_load(1, TRUE); - $this->assertEqual($user1->status, 1, 'User #1 still exists and is not blocked.'); + $this->assertTrue($user1->isActive(), 'User #1 still exists and is not blocked.'); } /** @@ -124,14 +124,14 @@ function testUserCancelInvalid() { // Attempt bogus account cancellation request confirmation. $bogus_timestamp = $timestamp + 60; - $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account->pass, $bogus_timestamp, $account->getLastLoginTime())); + $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account->getPassword(), $bogus_timestamp, $account->getLastLoginTime())); $this->assertText(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'), 'Bogus cancelling request rejected.'); $account = user_load($account->id()); $this->assertTrue($account->isActive(), 'User account was not canceled.'); // Attempt expired account cancellation request confirmation. $bogus_timestamp = $timestamp - 86400 - 60; - $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account->pass, $bogus_timestamp, $account->getLastLoginTime())); + $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account->getPassword(), $bogus_timestamp, $account->getLastLoginTime())); $this->assertText(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'), 'Expired cancel account request rejected.'); $account = user_load($account->id(), TRUE); $this->assertTrue($account->isActive(), 'User account was not canceled.'); @@ -168,7 +168,7 @@ function testUserBlock() { $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), 'Account cancellation request mailed message displayed.'); // Confirm account cancellation request. - $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->getLastLoginTime())); + $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())); $account = user_load($account->id(), TRUE); $this->assertTrue($account->isBlocked(), 'User has been blocked.'); @@ -206,7 +206,7 @@ function testUserBlockUnpublish() { $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), 'Account cancellation request mailed message displayed.'); // Confirm account cancellation request. - $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->getLastLoginTime())); + $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())); $account = user_load($account->id(), TRUE); $this->assertTrue($account->isBlocked(), 'User has been blocked.'); @@ -256,7 +256,7 @@ function testUserAnonymize() { $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), 'Account cancellation request mailed message displayed.'); // Confirm account cancellation request. - $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->getLastLoginTime())); + $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())); $this->assertFalse(user_load($account->id(), TRUE), 'User is not found in the database.'); // Confirm that user's content has been attributed to anonymous user. @@ -322,7 +322,7 @@ function testUserDelete() { $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), 'Account cancellation request mailed message displayed.'); // Confirm account cancellation request. - $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->getLastLoginTime())); + $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())); $this->assertFalse(user_load($account->id(), TRUE), 'User is not found in the database.'); // Confirm that user's content has been deleted. @@ -436,6 +436,6 @@ function testMassUserCancelByAdmin() { // Verify that uid 1's account was not cancelled. $user1 = user_load(1, TRUE); - $this->assertEqual($user1->status, 1, 'User #1 still exists and is not blocked.'); + $this->assertTrue($user1->isActive(), 'User #1 still exists and is not blocked.'); } } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEditTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEditTest.php index 0c9ded0..0713df0 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserEditTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserEditTest.php @@ -32,7 +32,7 @@ function testUserEdit() { $this->drupalLogin($user1); // Test that error message appears when attempting to use a non-unique user name. - $edit['name'] = $user2->name; + $edit['name'] = $user2->getUsername(); $this->drupalPost("user/" . $user1->id() . "/edit", $edit, t('Save')); $this->assertRaw(t('The name %name is already taken.', array('%name' => $edit['name']))); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php index c89dd26..1363824 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php @@ -7,6 +7,7 @@ namespace Drupal\user\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -39,12 +40,8 @@ function testLocalUserCreation() { // Add predefined language. $langcode = 'fr'; - $edit = array( - 'predefined_langcode' => 'fr', - ); - $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); - $this->assertText('French', 'Language added successfully.'); - $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.'); + $language = new Language(array('id' => $langcode)); + language_save($language); // Set language negotiation. $edit = array( @@ -71,8 +68,8 @@ function testLocalUserCreation() { $this->drupalPost($langcode . '/admin/people/create', $edit, t('Create new account')); $user = user_load_by_name($username); - $this->assertEqual($user->preferred_langcode, $langcode, 'New user has correct preferred language set.'); - $this->assertEqual($user->langcode, $langcode, 'New user has correct profile language set.'); + $this->assertEqual($user->getPreferredLangcode(), $langcode, 'New user has correct preferred language set.'); + $this->assertEqual($user->language()->id, $langcode, 'New user has correct profile language set.'); // Register a new user and check if the language selector is hidden. $this->drupalLogout(); @@ -89,8 +86,8 @@ function testLocalUserCreation() { $this->drupalPost($langcode . '/user/register', $edit, t('Create new account')); $user = user_load_by_name($username); - $this->assertEqual($user->preferred_langcode, $langcode, 'New user has correct preferred language set.'); - $this->assertEqual($user->langcode, $langcode, 'New user has correct profile language set.'); + $this->assertEqual($user->getPreferredLangcode(), $langcode, 'New user has correct preferred language set.'); + $this->assertEqual($user->language()->id, $langcode, 'New user has correct profile language set.'); // Test if the admin can use the language selector and if the // correct language is was saved. diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php index 3935212..38b7abf 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php @@ -116,7 +116,7 @@ function testPasswordRehashOnLogin() { $this->drupalLogout(); // Load the stored user. The password hash should reflect $default_count_log2. $account = user_load($account->id()); - $this->assertIdentical($password_hasher->getCountLog2($account->pass), $default_count_log2); + $this->assertIdentical($password_hasher->getCountLog2($account->getPassword()), $default_count_log2); // Change the required number of iterations by loading a test-module // containing the necessary container builder code and then verify that the @@ -128,7 +128,7 @@ function testPasswordRehashOnLogin() { $this->drupalLogin($account); // Load the stored user, which should have a different password hash now. $account = user_load($account->id(), TRUE); - $this->assertIdentical($password_hasher->getCountLog2($account->pass), $overridden_count_log2); + $this->assertIdentical($password_hasher->getCountLog2($account->getPassword()), $overridden_count_log2); } /** diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php index 4e3d138..97390c7 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php @@ -100,7 +100,7 @@ function testUserPasswordReset() { $timeout = config('user.settings')->get('password_reset_timeout'); $bogus_timestamp = REQUEST_TIME - $timeout - 60; $_uid = $this->account->id(); - $this->drupalGet("user/reset/$_uid/$bogus_timestamp/" . user_pass_rehash($this->account->pass, $bogus_timestamp, $this->account->getLastLoginTime())); + $this->drupalGet("user/reset/$_uid/$bogus_timestamp/" . user_pass_rehash($this->account->getPassword(), $bogus_timestamp, $this->account->getLastLoginTime())); $this->assertText(t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'), 'Expired password reset request rejected.'); } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php index f4a0662..c91eaa7 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php @@ -135,6 +135,6 @@ function saveUserPicture($image) { // Load actual user data from database. $account = user_load($this->web_user->id(), TRUE); - return file_load($account->user_picture[Language::LANGCODE_NOT_SPECIFIED][0]['target_id'], TRUE); + return file_load($account->user_picture->target_id, TRUE); } } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserSearchTest.php b/core/modules/user/lib/Drupal/user/Tests/UserSearchTest.php index 9951068..f255241 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserSearchTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserSearchTest.php @@ -32,7 +32,7 @@ public static function getInfo() { function testUserSearch() { $user1 = $this->drupalCreateUser(array('access user profiles', 'search content', 'use advanced search')); $this->drupalLogin($user1); - $keys = $user1->mail; + $keys = $user1->getEmail(); $edit = array('keys' => $keys); $this->drupalPost('search/user/', $edit, t('Search')); $this->assertNoText($keys); @@ -40,7 +40,7 @@ function testUserSearch() { $user2 = $this->drupalCreateUser(array('administer users', 'access user profiles', 'search content', 'use advanced search')); $this->drupalLogin($user2); - $keys = $user2->mail; + $keys = $user2->getEmail(); $edit = array('keys' => $keys); $this->drupalPost('search/user/', $edit, t('Search')); $this->assertText($keys); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php index c4ff9ff..0d07c40 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php @@ -58,7 +58,7 @@ function testUserTimeZone() { // Change user time zone to Santiago time. $edit = array(); - $edit['mail'] = $web_user->mail; + $edit['mail'] = $web_user->getEmail(); $edit['timezone'] = 'America/Santiago'; $this->drupalPost("user/" . $web_user->id() . "/edit", $edit, t('Save')); $this->assertText(t('The changes have been saved.'), 'Time zone changed to Santiago time.'); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php index f2aa374..cc706ba 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php @@ -82,7 +82,7 @@ function testUserTokenReplacement() { // Generate and test unsanitized tokens. $tests['[user:name]'] = user_format_name($account); - $tests['[user:mail]'] = $account->mail; + $tests['[user:mail]'] = $account->getEmail(); $tests['[current-user:name]'] = user_format_name($global_account); foreach ($tests as $input => $expected) { @@ -105,7 +105,7 @@ function testUserTokenReplacement() { // Generate tokens with the user's preferred language. $account->preferred_langcode = 'de'; $account->save(); - $link = url('user', array('language' => language_load($account->preferred_langcode), 'absolute' => TRUE)); + $link = url('user', array('language' => language_load($account->getPreferredLangcode()), 'absolute' => TRUE)); foreach ($tests as $input => $expected) { $output = $token_service->replace($input, array('user' => $account), array('callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); $this->assertTrue(strpos($output, $link) === 0, "Generated URL is in the user's preferred language."); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php b/core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php index 8379bbe..d8cd059 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php @@ -55,7 +55,7 @@ function testUserValidateCurrentPassCustomForm() { // Submit the custom form with the admin user using the access user's password. $edit = array(); - $edit['user_form_test_field'] = $this->accessUser->name; + $edit['user_form_test_field'] = $this->accessUser->getUsername(); $edit['current_pass'] = $this->accessUser->pass_raw; $this->drupalPost('user_form_test_current_password/' . $this->accessUser->id(), $edit, t('Test')); $this->assertText(t('The password has been validated and the form submitted successfully.')); diff --git a/core/modules/user/user.module b/core/modules/user/user.module index aa3a562..1ab84be 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -623,7 +623,8 @@ function user_validate_current_pass(&$form, &$form_state) { // This validation only works for required textfields (like mail) or // form values like password_confirm that have their own validation // that prevent them from being empty if they are changed. - if ((strlen(trim($form_state['values'][$key])) > 0) && ($form_state['values'][$key] != $account->get($key)->value)) { + $current_value = $account->getPropertyDefinition($key) ? $account->get($key)->value : $account->$key; + if ((strlen(trim($form_state['values'][$key])) > 0) && ($form_state['values'][$key] != $current_value)) { $current_pass_failed = empty($form_state['values']['current_pass']) || !drupal_container()->get('password')->check($form_state['values']['current_pass'], $account); if ($current_pass_failed) { form_set_error('current_pass', t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name))); diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc index 961607e..04bd69c 100644 --- a/core/modules/user/user.pages.inc +++ b/core/modules/user/user.pages.inc @@ -49,7 +49,7 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a drupal_set_message(t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.')); return new RedirectResponse(url('user/password', array('absolute' => TRUE))); } - elseif ($account->isAuthenticated() && $timestamp >= $account->getLastLoginTime() && $timestamp <= $current && $hashed_pass == user_pass_rehash($account->pass, $timestamp, $account->getLastLoginTime())) { + elseif ($account->isAuthenticated() && $timestamp >= $account->getLastLoginTime() && $timestamp <= $current && $hashed_pass == user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())) { // First stage is a confirmation form, then login if ($action == 'login') { // Set the new user. @@ -306,7 +306,7 @@ function user_cancel_confirm($account, $timestamp = 0, $hashed_pass = '') { $account_data = drupal_container()->get('user.data')->get('user', $account->id()); if (isset($account_data['cancel_method']) && !empty($timestamp) && !empty($hashed_pass)) { // Validate expiration and hashed password/login. - if ($timestamp <= $current && $current - $timestamp < $timeout && $account->id() && $timestamp >= $account->getLastLoginTime() && $hashed_pass == user_pass_rehash($account->pass, $timestamp, $account->getLastLoginTime())) { + if ($timestamp <= $current && $current - $timestamp < $timeout && $account->id() && $timestamp >= $account->getLastLoginTime() && $hashed_pass == user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())) { $edit = array( 'user_cancel_notify' => isset($account_data['cancel_notify']) ? $account_data['cancel_notify'] : config('user.settings')->get('notify.status_canceled'), );