diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/field/UserBulkForm.php b/core/modules/user/lib/Drupal/user/Plugin/views/field/UserBulkForm.php index 33f07fa..59f3a0d 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/field/UserBulkForm.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/field/UserBulkForm.php @@ -9,6 +9,7 @@ use Drupal\Component\Annotation\PluginID; use Drupal\system\Plugin\views\field\BulkFormBase; +use Drupal\user\Plugin\Core\Entity\User as UserEntity; /** * Defines a user operations bulk form element. @@ -28,6 +29,25 @@ protected function getBulkOptions() { /** * {@inheritdoc} + * + * Provide a more useful title to improve the accessibility. + */ + public function views_form(&$form, &$form_state) { + parent::views_form($form, $form_state); + + if (!empty($this->view->result)) { + foreach ($this->view->result as $row_index => $result) { + $account = $result->_entity; + if ($account instanceof UserEntity) { + $form[$this->options['id']][$row_index]['#title'] = t('Update the user %name', array('%name' => $account->label())); + } + } + } + } + + + /** + * {@inheritdoc} */ public function views_form_validate(&$form, &$form_state) { $selected = array_filter($form_state['values'][$this->options['id']]); @@ -49,11 +69,6 @@ public function views_form_submit(&$form, &$form_state) { $accounts[$account->id()] = $account; } } - // If there are no valid accounts selected, return. - if (empty($accounts)) { - drupal_set_message(t('No updates to perform.')); - return; - } $operations = \Drupal::moduleHandler()->invokeAll('user_operations', array($form_state['values']['action'])); $operation = $operations[$form_state['values']['action']]; @@ -72,7 +87,7 @@ public function views_form_submit(&$form, &$form_state) { $form_state['redirect'] = $operation['redirect']; } else { - drupal_set_message(t('The update has been performed.')); + drupal_set_message(format_plural(count($accounts), 'One account was blocked.', '@count accounts were blocked.')); } } } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCreateTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCreateTest.php index c1c80a6..565e40e 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserCreateTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserCreateTest.php @@ -14,11 +14,6 @@ */ class UserCreateTest extends WebTestBase { - /** - * Modules to enable. - */ - public static $modules = array('views'); - public static function getInfo() { return array( 'name' => 'User create', diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php index 51f9b4a..c582d5e 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php @@ -94,12 +94,15 @@ public function testBulkForm() { // Ensure the anonymous user is found. $this->drupalGet('test-user-bulk-form'); $this->assertText(config('user.settings')->get('anonymous')); + // Attempt to block the anonymous user. $edit = array( 'user_bulk_form[0]' => TRUE, 'action' => 'block', ); $this->drupalPost(NULL, $edit, t('Apply')); + $anonymous_account = user_load(0); + $this->assertFalse($anonymous_account->status, 0, 'Ensure the anonymous user got blocked.'); $this->assertText(t('No updates to perform.')); } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php b/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php index 2262f26..7e392fc 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php @@ -1604,7 +1604,7 @@ function load_entities(&$results) { foreach ($results as $index => $result) { // Store the entity id if it was found. - if (!empty($result->$id_alias)) { + if (isset($result->{$id_alias}) && $result->{$id_alias} != '') { $ids_by_table[$table_alias][$index] = $result->$id_alias; } }