diff --git a/core/modules/comment/src/CommentViewsData.php b/core/modules/comment/src/CommentViewsData.php index 7d7403d73fbdd4cd67df5bdaa4ce038609f3bef6..e853a58d8a9d6d9234fc4ff7dba79b5d775d62eb 100644 --- a/core/modules/comment/src/CommentViewsData.php +++ b/core/modules/comment/src/CommentViewsData.php @@ -189,7 +189,6 @@ public function getViewsData() { $data['comment_field_data']['uid']['relationship']['title'] = t('Author'); $data['comment_field_data']['uid']['relationship']['help'] = t("The User ID of the comment's author."); $data['comment_field_data']['uid']['relationship']['label'] = t('author'); - $data['comment_field_data']['uid']['field']['id'] = 'user'; $data['comment_field_data']['pid']['title'] = t('Parent CID'); $data['comment_field_data']['pid']['relationship']['title'] = t('Parent comment'); diff --git a/core/modules/comment/src/Tests/Views/CommentViewsFieldAccessTest.php b/core/modules/comment/src/Tests/Views/CommentViewsFieldAccessTest.php index f8633bd991f1610721214258775742b90233b84d..2400dd0fd0eb8d56d1e23cfde492a23ed1636b78 100644 --- a/core/modules/comment/src/Tests/Views/CommentViewsFieldAccessTest.php +++ b/core/modules/comment/src/Tests/Views/CommentViewsFieldAccessTest.php @@ -72,7 +72,7 @@ public function testCommentFields() { $this->assertFieldAccess('comment', 'name', 'anonymous'); $this->assertFieldAccess('comment', 'mail', 'test@example.com'); $this->assertFieldAccess('comment', 'homepage', 'https://example.com'); - // $this->assertFieldAccess('comment', 'uid', $comment->uid->target_id); + $this->assertFieldAccess('comment', 'uid', $user->getUsername()); // $this->assertFieldAccess('comment', 'created', \Drupal::service('date.formatter')->format(123456)); // $this->assertFieldAccess('comment', 'changed', \Drupal::service('date.formatter')->format(REQUEST_TIME)); $this->assertFieldAccess('comment', 'status', 'On'); diff --git a/core/modules/node/src/NodeViewsData.php b/core/modules/node/src/NodeViewsData.php index 2d3bf8da3444e4bf818e2336cd98a32af332fb16..aecaec26c78efe5dd39c1f87ef9e388b85c3f2de 100644 --- a/core/modules/node/src/NodeViewsData.php +++ b/core/modules/node/src/NodeViewsData.php @@ -225,7 +225,6 @@ public function getViewsData() { $data['node_field_data']['uid']['help'] = t('The user authoring the content. If you need more fields than the uid add the content: author relationship'); $data['node_field_data']['uid']['filter']['id'] = 'user_name'; - $data['node_field_data']['uid']['field']['id'] = 'user'; $data['node_field_data']['uid']['relationship']['title'] = t('Content author'); $data['node_field_data']['uid']['relationship']['help'] = t('Relate content to the user who created it.'); $data['node_field_data']['uid']['relationship']['label'] = t('author'); diff --git a/core/modules/node/src/Tests/Views/NodeViewsFieldAccessTest.php b/core/modules/node/src/Tests/Views/NodeViewsFieldAccessTest.php index 93772f9cae70205113d1401e2532a5e3adcc3ae6..379cf306f1c78a96c52e199d04ab89741c4414ff 100644 --- a/core/modules/node/src/Tests/Views/NodeViewsFieldAccessTest.php +++ b/core/modules/node/src/Tests/Views/NodeViewsFieldAccessTest.php @@ -48,6 +48,7 @@ public function testNodeFields() { $node = Node::create([ 'type' => 'article', 'title' => 'Test title', + 'uid' => $user->id(), 'status' => 1, 'promote' => 1, 'sticky' => 0, @@ -64,7 +65,7 @@ public function testNodeFields() { $this->assertFieldAccess('node', 'type', $node->type->entity->label()); $this->assertFieldAccess('node', 'langcode', $node->language()->getName()); $this->assertFieldAccess('node', 'title', 'Test title'); - // $this->assertFieldAccess('node', 'uid', $user->getUsername()); + $this->assertFieldAccess('node', 'uid', $user->getUsername()); // @todo Don't we want to display Published / Unpublished by default, // see https://www.drupal.org/node/2465623 $this->assertFieldAccess('node', 'status', 'On'); diff --git a/core/modules/user/src/Plugin/views/field/User.php b/core/modules/user/src/Plugin/views/field/User.php deleted file mode 100644 index bb665d8c09a1ac52a131191b2a664c8e38ea0b80..0000000000000000000000000000000000000000 --- a/core/modules/user/src/Plugin/views/field/User.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php - -/** - * @file - * Definition of Drupal\user\Plugin\views\field\User. - */ - -namespace Drupal\user\Plugin\views\field; - -use Drupal\Core\Form\FormStateInterface; -use Drupal\views\Plugin\views\field\FieldPluginBase; -use Drupal\views\Plugin\views\display\DisplayPluginBase; -use Drupal\views\ResultRow; -use Drupal\views\ViewExecutable; - -/** - * Field handler to provide simple renderer that allows linking to a user. - * - * @ingroup views_field_handlers - * - * @ViewsField("user") - */ -class User extends FieldPluginBase { - - /** - * {@inheritdoc} - */ - public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) { - parent::init($view, $display, $options); - - if (!empty($this->options['link_to_user'])) { - $this->additional_fields['uid'] = 'uid'; - } - } - - /** - * {@inheritdoc} - */ - protected function defineOptions() { - $options = parent::defineOptions(); - $options['link_to_user'] = array('default' => TRUE); - return $options; - } - - /** - * Provide link to node option - */ - public function buildOptionsForm(&$form, FormStateInterface $form_state) { - $form['link_to_user'] = array( - '#title' => $this->t('Link this field to its user'), - '#description' => $this->t("Enable to override this field's links."), - '#type' => 'checkbox', - '#default_value' => $this->options['link_to_user'], - ); - parent::buildOptionsForm($form, $form_state); - } - - /** - * Prepares a link to the user. - * - * @param string $data - * The XSS safe string for the link text. - * @param \Drupal\views\ResultRow $values - * The values retrieved from a single row of a view's query result. - * - * @return string - * Returns a string for the link text. - */ - protected function renderLink($data, ResultRow $values) { - if (!empty($this->options['link_to_user']) && $this->view->getUser()->hasPermission('access user profiles') && ($entity = $this->getEntity($values)) && $data !== NULL && $data !== '') { - $this->options['alter']['make_link'] = TRUE; - $this->options['alter']['url'] = $entity->urlInfo(); - } - return $data; - } - - /** - * {@inheritdoc} - */ - public function render(ResultRow $values) { - $value = $this->getValue($values); - return $this->renderLink($this->sanitizeValue($value), $values); - } - -} diff --git a/core/modules/user/src/Tests/Views/UserViewsFieldAccessTest.php b/core/modules/user/src/Tests/Views/UserViewsFieldAccessTest.php index 546f31ab19481818a67096a331ec5528f99c9ad9..37f5597415e9d0f16c8f6f4a0ff4adb561aa8765 100644 --- a/core/modules/user/src/Tests/Views/UserViewsFieldAccessTest.php +++ b/core/modules/user/src/Tests/Views/UserViewsFieldAccessTest.php @@ -56,7 +56,7 @@ public function testUserFields() { // @todo Expand the test coverage in https://www.drupal.org/node/2464635 - // $this->assertFieldAccess('user', 'uid', $user->id()); + $this->assertFieldAccess('user', 'uid', $user->id()); $this->assertFieldAccess('user', 'uuid', $user->uuid()); $this->assertFieldAccess('user', 'langcode', $user->language()->getName()); $this->assertFieldAccess('user', 'preferred_langcode', 'Spanish'); diff --git a/core/modules/user/src/UserViewsData.php b/core/modules/user/src/UserViewsData.php index 5affb649a9a685a22b684367b4e4a2dd0223cb79..edbdb99fe0d2bab5432e0143e498d150b91abf1b 100644 --- a/core/modules/user/src/UserViewsData.php +++ b/core/modules/user/src/UserViewsData.php @@ -25,7 +25,6 @@ public function getViewsData() { $data['users_field_data']['table']['wizard_id'] = 'user'; - $data['users_field_data']['uid']['field']['id'] = 'user'; $data['users_field_data']['uid']['argument']['id'] = 'user_uid'; $data['users_field_data']['uid']['argument'] += array( 'name table' => 'users_field_data', diff --git a/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_field_permission.yml b/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_field_permission.yml index 7fd0c080e404d12588f079c126f4a192785ef04c..7ddb9d2f437eb59fd6794d69b20078ab3233466c 100644 --- a/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_field_permission.yml +++ b/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_field_permission.yml @@ -82,7 +82,6 @@ display: empty_zero: false hide_alter_empty: true plugin_id: field - type: user entity_type: user entity_field: uid permission: