update drupal
This commit is contained in:
@@ -272,8 +272,11 @@ abstract class AccountForm extends ContentEntityForm implements TrustedCallbackI
|
||||
// separately, assume that the user profile data is in the user's preferred
|
||||
// language. This entity builder provides that synchronization. For
|
||||
// use-cases where this synchronization is not desired, a module can alter
|
||||
// or remove this item.
|
||||
$form['#entity_builders']['sync_user_langcode'] = '::syncUserLangcode';
|
||||
// or remove this item. Sync user langcode only when a user registers and
|
||||
// not when a user is updated or translated.
|
||||
if ($register) {
|
||||
$form['#entity_builders']['sync_user_langcode'] = '::syncUserLangcode';
|
||||
}
|
||||
|
||||
$system_date_config = \Drupal::config('system.date');
|
||||
$form['timezone'] = [
|
||||
|
||||
@@ -205,10 +205,10 @@ class PermissionHandler implements PermissionHandlerInterface {
|
||||
|
||||
uasort($all_permissions, function (array $permission_a, array $permission_b) use ($modules) {
|
||||
if ($modules[$permission_a['provider']] == $modules[$permission_b['provider']]) {
|
||||
return $permission_a['title'] > $permission_b['title'];
|
||||
return $permission_a['title'] <=> $permission_b['title'];
|
||||
}
|
||||
else {
|
||||
return $modules[$permission_a['provider']] > $modules[$permission_b['provider']];
|
||||
return $modules[$permission_a['provider']] <=> $modules[$permission_b['provider']];
|
||||
}
|
||||
});
|
||||
return $all_permissions;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Drupal\user\Plugin\Block;
|
||||
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\Security\TrustedCallbackInterface;
|
||||
@@ -155,7 +156,7 @@ class UserLoginBlock extends BlockBase implements ContainerFactoryPluginInterfac
|
||||
public static function renderPlaceholderFormAction() {
|
||||
return [
|
||||
'#type' => 'markup',
|
||||
'#markup' => Url::fromRoute('<current>', [], ['query' => \Drupal::destination()->getAsArray(), 'external' => FALSE])->toString(),
|
||||
'#markup' => UrlHelper::filterBadProtocol(Url::fromRoute('<current>', [], ['query' => \Drupal::destination()->getAsArray(), 'external' => FALSE])->toString()),
|
||||
'#cache' => ['contexts' => ['url.path', 'url.query_args']],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class Roles extends PrerenderList {
|
||||
|
||||
if ($uids) {
|
||||
$roles = user_roles();
|
||||
$result = $this->database->query('SELECT u.entity_id as uid, u.roles_target_id as rid FROM {user__roles} u WHERE u.entity_id IN ( :uids[] ) AND u.roles_target_id IN ( :rids[] )', [':uids[]' => $uids, ':rids[]' => array_keys($roles)]);
|
||||
$result = $this->database->query('SELECT u.entity_id AS uid, u.roles_target_id AS rid FROM {user__roles} u WHERE u.entity_id IN ( :uids[] ) AND u.roles_target_id IN ( :rids[] )', [':uids[]' => $uids, ':rids[]' => array_keys($roles)]);
|
||||
foreach ($result as $role) {
|
||||
$this->items[$role->uid][$role->rid]['role'] = $roles[$role->rid]->label();
|
||||
$this->items[$role->uid][$role->rid]['rid'] = $role->rid;
|
||||
|
||||
@@ -88,7 +88,8 @@ class UserBlocksTest extends BrowserTestBase {
|
||||
$this->assertEqual('MISS', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER));
|
||||
$this->drupalPostForm(NULL, $edit, t('Log in'));
|
||||
$this->assertNoText(t('User login'), 'Logged in.');
|
||||
$this->assertPattern('!<title.*?Compose tips.*?</title>!', 'Still on the same page after login for allowed page');
|
||||
// Verify that we are still on the same page after login for allowed page.
|
||||
$this->assertPattern('!<title.*?Compose tips.*?</title>!');
|
||||
|
||||
// Log out again and repeat with a non-403 page including query arguments.
|
||||
$this->drupalLogout();
|
||||
@@ -96,7 +97,8 @@ class UserBlocksTest extends BrowserTestBase {
|
||||
$this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER));
|
||||
$this->drupalPostForm(NULL, $edit, t('Log in'));
|
||||
$this->assertNoText(t('User login'), 'Logged in.');
|
||||
$this->assertPattern('!<title.*?Compose tips.*?</title>!', 'Still on the same page after login for allowed page');
|
||||
// Verify that we are still on the same page after login for allowed page.
|
||||
$this->assertPattern('!<title.*?Compose tips.*?</title>!');
|
||||
$this->assertStringContainsString('/filter/tips?foo=bar', $this->getUrl(), 'Correct query arguments are displayed after login');
|
||||
|
||||
// Repeat with different query arguments.
|
||||
@@ -105,7 +107,8 @@ class UserBlocksTest extends BrowserTestBase {
|
||||
$this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER));
|
||||
$this->drupalPostForm(NULL, $edit, t('Log in'));
|
||||
$this->assertNoText(t('User login'), 'Logged in.');
|
||||
$this->assertPattern('!<title.*?Compose tips.*?</title>!', 'Still on the same page after login for allowed page');
|
||||
// Verify that we are still on the same page after login for allowed page.
|
||||
$this->assertPattern('!<title.*?Compose tips.*?</title>!');
|
||||
$this->assertStringContainsString('/filter/tips?foo=baz', $this->getUrl(), 'Correct query arguments are displayed after login');
|
||||
|
||||
// Check that the user login block is not vulnerable to information
|
||||
|
||||
@@ -174,4 +174,53 @@ class UserEditTest extends BrowserTestBase {
|
||||
$this->assertSession()->statusCodeEquals(403);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that a user is able to change site language.
|
||||
*/
|
||||
public function testUserChangeSiteLanguage() {
|
||||
// Install these modules here as these aren't needed for other test methods.
|
||||
\Drupal::service('module_installer')->install([
|
||||
'content_translation',
|
||||
'language',
|
||||
]);
|
||||
// Create and login as an admin user to add a new language and enable
|
||||
// translation for user accounts.
|
||||
$adminUser = $this->drupalCreateUser([
|
||||
'administer account settings',
|
||||
'administer languages',
|
||||
'administer content translation',
|
||||
'administer users',
|
||||
'translate any entity',
|
||||
]);
|
||||
$this->drupalLogin($adminUser);
|
||||
|
||||
// Add a new language into the system.
|
||||
$edit = [
|
||||
'predefined_langcode' => 'fr',
|
||||
];
|
||||
$this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add language');
|
||||
$this->assertSession()->pageTextContains('French');
|
||||
|
||||
// Enable translation for user accounts.
|
||||
$edit = [
|
||||
'language[content_translation]' => 1,
|
||||
];
|
||||
$this->drupalPostForm('admin/config/people/accounts', $edit, 'Save configuration');
|
||||
$this->assertSession()->pageTextContains('The configuration options have been saved.');
|
||||
|
||||
// Create a regular user for whom translation will be enabled.
|
||||
$webUser = $this->drupalCreateUser();
|
||||
|
||||
// Create a translation for a regular user account.
|
||||
$this->drupalPostForm('user/' . $webUser->id() . '/translations/add/en/fr', [], 'Save');
|
||||
$this->assertSession()->pageTextContains('The changes have been saved.');
|
||||
|
||||
// Update the site language of the user account.
|
||||
$edit = [
|
||||
'preferred_langcode' => 'fr',
|
||||
];
|
||||
$this->drupalPostForm('user/' . $webUser->id() . '/edit', $edit, 'Save');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class UserPasswordResetTest extends BrowserTestBase {
|
||||
|
||||
// Check successful login.
|
||||
$this->drupalPostForm(NULL, NULL, t('Log in'));
|
||||
$this->assertLink(t('Log out'));
|
||||
$this->assertSession()->linkExists(t('Log out'));
|
||||
$this->assertTitle($this->account->getAccountName() . ' | Drupal');
|
||||
|
||||
// Change the forgotten password.
|
||||
@@ -188,7 +188,7 @@ class UserPasswordResetTest extends BrowserTestBase {
|
||||
$this->drupalPostForm(NULL, $edit, t('Submit'));
|
||||
$reset_url = $this->getResetURL();
|
||||
$this->drupalGet($reset_url . '/login');
|
||||
$this->assertLink(t('Log out'));
|
||||
$this->assertSession()->linkExists(t('Log out'));
|
||||
$this->assertTitle($this->account->getAccountName() . ' | Drupal');
|
||||
|
||||
// Ensure blocked and deleted accounts can't access the user.reset.login
|
||||
@@ -358,7 +358,7 @@ class UserPasswordResetTest extends BrowserTestBase {
|
||||
// Use the last password reset URL which was generated.
|
||||
$reset_url = $this->getResetURL();
|
||||
$this->drupalGet($reset_url . '/login');
|
||||
$this->assertLink(t('Log out'));
|
||||
$this->assertSession()->linkExists(t('Log out'));
|
||||
$this->assertTitle($this->account->getAccountName() . ' | Drupal');
|
||||
$this->drupalLogout();
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class ConvertTokensTest extends MigrateProcessTestCase {
|
||||
* Tests conversion of user tokens.
|
||||
*/
|
||||
public function testConvertTokens() {
|
||||
$value = $this->plugin->transform('Account details for !username at !site', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform('Account details for !username at !site', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertEquals('Account details for [user:name] at [site:name]', $value);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class ConvertTokensTest extends MigrateProcessTestCase {
|
||||
* Tests conversion of user tokens with a NULL value.
|
||||
*/
|
||||
public function testConvertTokensNull() {
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertEquals('', $value);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
(Drupal => {
|
||||
/**
|
||||
* Constucts a password confirm message element
|
||||
* Constructs a password confirm message element
|
||||
*
|
||||
* @return {string}
|
||||
* A string representing a DOM fragment.
|
||||
|
||||
Reference in New Issue
Block a user