diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 0ae880b..4f733ce 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -206,7 +206,7 @@ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $v // indexing or constructing a search result excerpt. $values = field_get_items($entity, $field_name); if (is_array($values) && ($value = reset($values)) && - !empty($value['comment']) && $value['comment'] == COMMENT_OPEN) { + !empty($value['comment']) && $value['comment'] == COMMENT_OPEN) { $comment_form_location = $instance['settings']['comment']['comment_form_location']; if (user_access('post comments')) { // Show the "post comment" link if the form is on another page, or @@ -260,7 +260,7 @@ function comment_entity_bundle_info() { $bundles['comment'][$field_name] = array( 'label' => $field_name, 'admin' => array( - 'path' => 'admin/structure/comments/%comment_field_name', + 'path' => 'admin/structure/comments/%comment_field_name', 'bundle argument' => 3, 'real path' => 'admin/structure/comments/' . strtr($field_name, '_', '-'), ), @@ -427,7 +427,7 @@ function comment_menu() { 'access arguments' => array(3), 'file' => 'comment.pages.inc', ); - // Legacy redirect handler for links of form comment/reply/%nid + // Legacy redirect handler for links of form comment/reply/%nid if (module_exists('node')) { $items['comment/reply/%node'] = array( 'title' => 'Add new comment', @@ -448,7 +448,7 @@ function comment_menu() { * Loads the entity given and entity id and entity type * * @param array $args - * The menu args passed from the %map load argument + * The menu args passed from the %map load argument. * * @return mixed * Returns Drupal\entity\Entity or FALSE if not found. @@ -463,7 +463,7 @@ function comment_entity_reply_load($entity_id, $args) { * * Checks the user has view access to the entity which the comment reply is * against. - + * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity which the comment field is attached to. * @@ -479,11 +479,9 @@ function comment_reply_access(\Drupal\Core\Entity\EntityInterface $entity) { switch ($function) { case 'user_access': return $entity->access('view'); - break; case 'taxonomy_term_access': return user_access('access content'); - break; default: return $function('view', $entity); @@ -509,8 +507,7 @@ function comment_count_unpublished() { } /** - * Creates a comment_body field instance for a given entity type, bundle and - * field name. + * Creates a comment_body field instance. * * @param string $entity_type * Entity type to which the comment field is attached. @@ -518,7 +515,6 @@ function comment_count_unpublished() { * Bundle of entity type to which comment field is attached * @param string $field_name * Name of the comment field attached to the entity type and bundle. - * */ function _comment_body_field_create($entity_type, $bundle, $field_name) { // Create the field if needed. @@ -2059,8 +2055,8 @@ function comment_file_download_access($field, EntityInterface $entity, File $fil // @see http://drupal.org/node/1696660 $function = $entity->entity_type->value . '_access'; if (function_exists($function)) { - $entity = entity_load($comment->entity_type->value, $comment->entity_id->value); - return $function('view', $entity); + $commented_entity = entity_load($entity->entity_type->value, $entity->entity_id->value); + return $function('view', $commented_entity); } // Return NULL as there is no entity access callback for this entity // type, we rely on other modules intervening. diff --git a/core/modules/comment/comment.pages.inc b/core/modules/comment/comment.pages.inc index 1420049..6cfa72e 100644 --- a/core/modules/comment/comment.pages.inc +++ b/core/modules/comment/comment.pages.inc @@ -77,10 +77,6 @@ function comment_reply(Drupal\Core\Entity\EntityInterface $entity, $field_name, drupal_goto($uri['path']); } // Display the parent comment. - $comment->entity_type->value = $entity->entityType(); - $comment->field_name->value = $field_name; - field_attach_load('comment', array($comment->id() => $comment)); - $comment->name->value = $comment->uid->value ? $comment->registered_name : $comment->name->value; $build['comment_parent'] = comment_view($comment); } else { diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index 28b5bbc..f9cf913 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -423,6 +423,17 @@ function comment_views_data() { ), ); + // Entity translation field. + if (drupal_container()->get('module_handler')->moduleExists('translation_entity')) { + $data['comment']['translation_link'] = array( + 'title' => t('Translation link'), + 'help' => t('Provide a link to the translations overview for comments.'), + 'field' => array( + 'id' => 'translation_entity_link', + ), + ); + } + $data['comment_entity_statistics']['table']['group'] = t('Comment Statistics'); // Provide a relationship for each entity type except comment. @@ -446,17 +457,6 @@ function comment_views_data() { } } - // Entity translation field. - if (drupal_container()->get('module_handler')->moduleExists('translation_entity')) { - $data['comment']['translation_link'] = array( - 'title' => t('Translation link'), - 'help' => t('Provide a link to the translations overview for comments.'), - 'field' => array( - 'id' => 'translation_entity_link', - ), - ); - } - // last_comment_timestamp $data['comment_entity_statistics']['last_comment_timestamp'] = array( 'title' => t('Last comment time'), @@ -489,7 +489,7 @@ function comment_views_data() { // comment_count $data['comment_entity_statistics']['comment_count'] = array( 'title' => t('Comment count'), - 'help' => t('The number of comments a node has.'), + 'help' => t('The number of comments an entity has.'), 'field' => array( 'id' => 'numeric', ), @@ -507,7 +507,7 @@ function comment_views_data() { // last_comment_timestamp $data['comment_entity_statistics']['last_updated'] = array( 'title' => t('Updated/commented date'), - 'help' => t('The most recent of last comment posted or node updated time.'), + 'help' => t('The most recent of last comment posted or entity updated time.'), 'field' => array( 'id' => 'comment_ces_last_updated', 'no group by' => TRUE, @@ -538,7 +538,7 @@ function comment_views_data() { // last_comment_uid $data['comment_entity_statistics']['last_comment_uid'] = array( 'title' => t('Last comment uid'), - 'help' => t('The User ID of the author of the last comment of a node.'), + 'help' => t('The User ID of the author of the last comment of an entity.'), 'relationship' => array( 'title' => t('Last comment author'), 'base' => 'users', diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php index 1d21fca..03db901 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\comment\CommentStorageController. + * Contains \Drupal\comment\CommentStorageController. */ namespace Drupal\comment; @@ -15,7 +15,7 @@ /** * Defines the controller class for comments. * - * This extends the Drupal\Core\Entity\DatabaseStorageController class, adding + * This extends the Drupal\Core\Entity\DatabaseStorageControllerNG class, adding * required special handling for comment entities. */ class CommentStorageController extends DatabaseStorageControllerNG { @@ -25,7 +25,7 @@ class CommentStorageController extends DatabaseStorageControllerNG { protected $threadLock = ''; /** - * Overrides Drupal\Core\Entity\DatabaseStorageController::buildQuery(). + * Overrides DatabaseStorageControllerNG::buildQuery(). */ protected function buildQuery($ids, $revision_id = FALSE) { $query = parent::buildQuery($ids, $revision_id); @@ -37,7 +37,7 @@ protected function buildQuery($ids, $revision_id = FALSE) { } /** - * Overrides Drupal\Core\Entity\DatabaseStorageController::attachLoad(). + * Overrides DatabaseStorageControllerNG::attachLoad(). */ protected function attachLoad(&$records, $load_revision = FALSE) { // Set up standard comment properties. @@ -48,7 +48,7 @@ protected function attachLoad(&$records, $load_revision = FALSE) { } /** - * Overrides Drupal\Core\Entity\DatabaseStorageController::preSave(). + * Overrides DatabaseStorageControllerNG::preSave(). * * @see comment_int_to_alphadecimal() * @see comment_alphadecimal_to_int() @@ -148,7 +148,7 @@ protected function preSave(EntityInterface $comment) { } /** - * Overrides Drupal\Core\Entity\DatabaseStorageController::postSave(). + * Overrides DatabaseStorageControllerNG::postSave(). */ protected function postSave(EntityInterface $comment, $update) { $this->releaseThreadLock(); @@ -160,7 +160,7 @@ protected function postSave(EntityInterface $comment, $update) { } /** - * Overrides Drupal\Core\Entity\DatabaseStorageController::postDelete(). + * Overrides DatabaseStorageControllerNG::postDelete(). */ protected function postDelete($comments) { // Delete the comments' replies. @@ -188,7 +188,7 @@ protected function postDelete($comments) { * - comment_count: The total number of approved/published comments on this * entity. * - * @param Drupal\comment\Comment $comment + * @param \Drupal\comment\Plugin\Core\Entity\Comment $comment * The comment being saved. */ protected function updateEntityStatistics($comment) { @@ -266,7 +266,7 @@ protected function releaseThreadLock() { } /** - * Implements \Drupal\Core\Entity\DataBaseStorageControllerNG::basePropertyDefinitions(). + * Implements DatabaseStorageControllerNG::basePropertyDefinitions(). */ public function baseFieldDefinitions() { $properties['cid'] = array( @@ -367,4 +367,5 @@ public function baseFieldDefinitions() { ); return $properties; } + } diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/EntityLink.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/EntityLink.php index 682d2b8..8291821 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/EntityLink.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/EntityLink.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\comment\Plugin\views\field\NodeLink. + * Contains \Drupal\comment\Plugin\views\field\EntityLink. */ namespace Drupal\comment\Plugin\views\field; diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/sort/StatisticsLastCommentName.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/sort/StatisticsLastCommentName.php index caab87f..50797f8 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/sort/StatisticsLastCommentName.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/sort/StatisticsLastCommentName.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\comment\Plugin\views\sort\StatisticsLastCommentName. + * Contains \Drupal\comment\Plugin\views\sort\StatisticsLastCommentName. */ namespace Drupal\comment\Plugin\views\sort; @@ -37,7 +37,7 @@ public function query() { // the table alias. Though if we did that we'd be guessing the relationship name // so that doesn't matter that much. // $this->user_table = $this->query->add_relationship(NULL, $join, 'users', $this->relationship); - $this->user_table = $this->query->ensure_table('ncs_users', $this->relationship, $join); + $this->user_table = $this->query->ensure_table('ces_users', $this->relationship, $join); $this->user_field = $this->query->add_field($this->user_table, 'name'); // Add the field. diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/sort/StatisticsLastUpdated.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/sort/StatisticsLastUpdated.php index 8db2acc..da733cb 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/sort/StatisticsLastUpdated.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/sort/StatisticsLastUpdated.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\comment\Plugin\views\sort\StatisticsLastUpdated. + * Contains \Drupal\comment\Plugin\views\sort\StatisticsLastUpdated. */ namespace Drupal\comment\Plugin\views\sort; @@ -11,7 +11,7 @@ use Drupal\Core\Annotation\Plugin; /** - * Sort handler for the newer of last comment / node updated. + * Sort handler for the newer of last comment / entity updated. * * @ingroup views_sort_handlers * diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php index 658c968..200dc92 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php @@ -93,16 +93,28 @@ function testCommentInterface() { $reply_loaded = comment_load($reply->id()); $this->assertTrue($this->commentExists($reply, TRUE), 'Reply found.'); $this->assertEqual($comment->id(), $reply_loaded->pid->value, 'Pid of a reply to a comment is set correctly.'); - $this->assertEqual(rtrim($comment->thread->value, '/') . '.00/', $reply_loaded->thread->value, 'Thread of reply grows correctly.'); + // Check the thread of reply grows correctly. + $this->assertEqual(rtrim($comment->thread->value, '/') . '.00/', $reply_loaded->thread->value); - // Second reply to comment #3 creating comment #4. + // Second reply to comment #2 creating comment #4. + $this->drupalGet('comment/reply/node/' . $this->node->nid . '/comment/' . $comment->id()); + $this->assertText($comment->subject->value, 'Individual comment-reply subject found.'); + $this->assertText($comment->comment_body->value, 'Individual comment-reply body found.'); + $reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE); + $reply_loaded = comment_load($reply->id()); + $this->assertTrue($this->commentExists($reply, TRUE), 'Second reply found.'); + // Check the thread of second reply grows correctly. + $this->assertEqual(rtrim($comment->thread->value, '/') . '.01/', $reply_loaded->thread->value); + + // Reply to comment #4 creating comment #5. $this->drupalGet('comment/reply/node/' . $this->node->nid . '/comment/' . $reply_loaded->id()); $this->assertText($reply_loaded->subject->value, 'Individual comment-reply subject found.'); $this->assertText($reply_loaded->comment_body->value, 'Individual comment-reply body found.'); $reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE); $reply_loaded = comment_load($reply->id()); $this->assertTrue($this->commentExists($reply, TRUE), 'Second reply found.'); - $this->assertEqual(rtrim($comment->thread->value, '/') . '.01/', $reply_loaded->thread->value, 'Thread of second reply grows correctly.'); + // Check the thread of reply to second reply grows correctly. + $this->assertEqual(rtrim($comment->thread->value, '/') . '.01.00/', $reply_loaded->thread->value); // Edit reply. $this->drupalGet('comment/' . $reply->id() . '/edit'); @@ -111,13 +123,13 @@ function testCommentInterface() { // Correct link count $this->drupalGet('node'); - $this->assertRaw('4 comments', 'Link to the 4 comments exist.'); + $this->assertRaw('5 comments', 'Link to the 5 comments exist.'); // Confirm a new comment is posted to the correct page. $this->setCommentsPerPage(2); $comment_new_page = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE); $this->assertTrue($this->commentExists($comment_new_page), 'Page one exists. %s'); - $this->drupalGet('node/' . $this->node->nid, array('query' => array('page' => 1))); + $this->drupalGet('node/' . $this->node->nid, array('query' => array('page' => 2))); $this->assertTrue($this->commentExists($reply, TRUE), 'Page two exists. %s'); $this->setCommentsPerPage(50); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index 0d74fb6..d45efed 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -25,21 +25,21 @@ /** * An administrative user with permission to configure comment settings. * - * @var Drupal\user\User + * @var \Drupal\user\Plugin\Core\Entity\User */ protected $admin_user; /** * A normal user with permission to post comments. * - * @var Drupal\user\User + * @var \Drupal\user\Plugin\Core\Entity\User */ protected $web_user; /** * A test node to which comments will be posted. * - * @var Drupal\node\Node + * @var \Drupal\node\Plugin\Core\Entity\Node */ protected $node; @@ -83,7 +83,7 @@ function setUp() { /** * Posts a comment. * - * @param Drupal\node\Node|null $node + * @param \Drupal\node\Plugin\Core\Entity\Node|null $node * Node to post comment on or NULL to post to the previusly loaded page. * @param $comment * Comment body. @@ -158,7 +158,7 @@ function postComment($node, $comment, $subject = '', $contact = NULL) { /** * Checks current page for specified comment. * - * @param Drupal\comment\Plugin\Core\Entity\comment $comment + * @param \Drupal\comment\Plugin\Core\Entity\Comment $comment * The comment object. * @param boolean $reply * Boolean indicating whether the comment is a reply to another comment. @@ -184,7 +184,7 @@ function commentExists(Comment $comment = NULL, $reply = FALSE) { /** * Deletes a comment. * - * @param Drupal\comment\Comment $comment + * @param \Drupal\comment\Plugin\Core\Entity\Comment $comment * Comment to delete. */ function deleteComment(Comment $comment) { diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentUserTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentUserTest.php index 5b481ec..f8dc15c 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentUserTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentUserTest.php @@ -6,6 +6,7 @@ */ namespace Drupal\comment\Tests; + use Drupal\comment\Plugin\Core\Entity\Comment; use Drupal\simpletest\WebTestBase; @@ -24,14 +25,14 @@ class CommentUserTest extends WebTestBase { /** * An administrative user with permission to configure comment settings. * - * @var Drupal\user\User + * @var \Drupal\user\Plugin\Core\Entity\User */ protected $admin_user; /** * A normal user with permission to post comments. * - * @var Drupal\user\User + * @var \Drupal\user\Plugin\Core\Entity\User */ protected $web_user; @@ -61,7 +62,7 @@ function setUp() { 'access content', 'administer users', 'access user profiles', - )); + )); $this->web_user = $this->drupalCreateUser(array( 'access comments', 'post comments', @@ -91,8 +92,8 @@ function setUp() { /** * Posts a comment. * - * @param Drupal\user\User|null $account - * User to post comment on or NULL to post to the previusly loaded page. + * @param \Drupal\user\Plugin\Core\Entity\User|null $account + * User to post comment on or NULL to post to the previously loaded page. * @param $comment * Comment body. * @param $subject @@ -165,7 +166,7 @@ function postComment($account, $comment, $subject = '', $contact = NULL) { /** * Checks current page for specified comment. * - * @param Drupal\comment\Plugin\Core\Entity\comment $comment + * @param \Drupal\comment\Plugin\Core\Entity\Comment $comment * The comment object. * @param boolean $reply * Boolean indicating whether the comment is a reply to another comment. @@ -191,7 +192,7 @@ function commentExists(Comment $comment = NULL, $reply = FALSE) { /** * Deletes a comment. * - * @param Drupal\comment\Comment $comment + * @param \Drupal\comment\Plugin\Core\Entity\Comment $comment * Comment to delete. */ function deleteComment(Comment $comment) { @@ -264,19 +265,19 @@ function testCommentUser() { $this->performCommentOperation($comment1, 'unpublish'); $this->drupalGet('admin/content/comment/approval'); - $this->assertRaw('comments[' . $comment1->id . ']', 'Comment was unpublished.'); + $this->assertRaw('comments[' . $comment1->id() . ']', 'Comment was unpublished.'); // Publish comment. $this->performCommentOperation($comment1, 'publish', TRUE); $this->drupalGet('admin/content/comment'); - $this->assertRaw('comments[' . $comment1->id . ']', 'Comment was published.'); + $this->assertRaw('comments[' . $comment1->id() . ']', 'Comment was published.'); // Delete comment. $this->performCommentOperation($comment1, 'delete'); $this->drupalGet('admin/content/comment'); - $this->assertNoRaw('comments[' . $comment1->id . ']', 'Comment was deleted.'); + $this->assertNoRaw('comments[' . $comment1->id() . ']', 'Comment was deleted.'); // Post another comment. $comment1 = $this->postComment($this->web_user, $this->randomName(), $this->randomName()); @@ -284,7 +285,7 @@ function testCommentUser() { // Check comment was found. $this->drupalGet('admin/content/comment'); - $this->assertRaw('comments[' . $comment1->id . ']', 'Comment was published.'); + $this->assertRaw('comments[' . $comment1->id() . ']', 'Comment was published.'); $this->drupalLogout(); @@ -334,7 +335,7 @@ function testCommentUser() { $this->assertFieldByName('subject', '', 'Subject field found.'); $this->assertFieldByName("comment_body[$langcode][0][value]", '', 'Comment field found.'); - $this->drupalGet('comment/reply/user/' . $this->web_user->uid . '/comment/' . $comment1->id); + $this->drupalGet('comment/reply/user/' . $this->web_user->uid . '/comment/' . $comment1->id()); $this->assertText('You are not authorized to view comments', 'Error attempting to post reply.'); $this->assertNoText($comment1->subject->value, 'Comment not displayed.'); } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php index f5a2f02..73c1c84 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php @@ -43,6 +43,7 @@ function setUp() { 'post comments' => TRUE, 'skip comment approval' => TRUE, )); + // Create comment field on article. comment_add_default_comment_field('node', 'article'); @@ -57,9 +58,9 @@ function setUp() { * markup on the tracker page for those nodes and their comments. */ function testAttributesInTracker() { - // Create node as anonymous user. + // Creates node as anonymous user. $node_anon = $this->drupalCreateNode(array('type' => 'article', 'uid' => 0, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN))))); - // Create node as admin user. + // Creates node as admin user. $node_admin = $this->drupalCreateNode(array('type' => 'article', 'uid' => 1, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN))))); // Passes both the anonymously posted node and the administrator posted node