diff --git a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php index 7c4412d..c3c5c9c 100644 --- a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php +++ b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php @@ -99,7 +99,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#type' => 'entity_autocomplete', '#title' => t('Username'), '#target_type' => 'user', - '#selection_setttings' => array( + '#selection_settings' => array( 'include_anonymous' => FALSE, ), '#default_value' => User::load($this->configuration['owner_uid']), diff --git a/core/modules/node/src/Tests/NodeActionsConfigurationTest.php b/core/modules/node/src/Tests/NodeActionsConfigurationTest.php index 7a732c6..fbc120a 100644 --- a/core/modules/node/src/Tests/NodeActionsConfigurationTest.php +++ b/core/modules/node/src/Tests/NodeActionsConfigurationTest.php @@ -81,4 +81,39 @@ public function testAssignOwnerNodeActionConfiguration() { $this->assertFalse($action, 'The node_assign_owner_action action is not available after being deleted.'); } + /** + * Tests if autocomplete field does not show anonymous user. + */ + public function testAssignOwnerNodeActionAnonymous() { + // Create 200 Users, to force the action's configuration page to show up + // an autocomplete field instead of a select field. + for ($i = 0; $i < 200; ++$i) { + $this->drupalCreateUser(); + } + + // Create a user with permission to view the actions administration pages + // and additionally permission to administer users. Otherwise the user would + // not be able to reference the anonymous user anyway. + $user = $this->drupalCreateUser(['administer actions', 'administer users'], 'myadmin'); + $this->drupalLogin($user); + + // Make a POST request to admin/config/system/actions. + $edit = []; + $edit['action'] = Crypt::hashBase64('node_assign_owner_action'); + $this->drupalPostForm('admin/config/system/actions', $edit, t('Create')); + $this->assertResponse(200); + + // Get the autocomplete url of the owner_uid textfield. + $autocomplete_field = $this->xpath('//input[@name="owner_uid"]'); + $autocomplete_url = $this->getAbsoluteUrl($autocomplete_field[0]['data-autocomplete-path']); + + $data = $this->drupalGetJSON( + $autocomplete_url, + ['query' => ['q' => 'Anonymous']] + ); + // We don't want to receive the anonymous user here. + $expected = array(); + $this->assertIdentical($expected, $data); + } + }