diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 503e32a..1342d9a 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -219,7 +219,7 @@ function comment_count_unpublished() { } /** - * Implements hook_ENTITY_TYPE_insert() for 'field_instance'. + * Implements hook_ENTITY_TYPE_insert() for field_instance(). */ function comment_field_instance_insert(FieldInstanceInterface $instance) { if ($instance->getType() == 'comment' && !$instance->isSyncing()) { @@ -229,7 +229,7 @@ function comment_field_instance_insert(FieldInstanceInterface $instance) { } /** - * Implements hook_ENTITY_TYPE_create() for 'field_instance'. + * Implements hook_ENTITY_TYPE_create() for field_instance(). */ function comment_field_instance_create(FieldInstanceInterface $instance) { if ($instance->getType() == 'comment' && !$instance->isSyncing()) { @@ -250,7 +250,7 @@ function comment_field_instance_create(FieldInstanceInterface $instance) { } /** - * Implements hook_ENTITY_TYPE_update() for 'field_instance'. + * Implements hook_ENTITY_TYPE_update() for field_instance(). */ function comment_field_instance_update(FieldInstanceInterface $instance) { if ($instance->getType() == 'comment') { @@ -262,7 +262,7 @@ function comment_field_instance_update(FieldInstanceInterface $instance) { } /** - * Implements hook_ENTITY_TYPE_delete() for 'field_entity'. + * Implements hook_ENTITY_TYPE_delete() for field_entity(). */ function comment_field_entity_delete(FieldInterface $field) { if ($field->getType() == 'comment') { @@ -273,7 +273,7 @@ function comment_field_entity_delete(FieldInterface $field) { } /** - * Implements hook_ENTITY_TYPE_delete() for 'field_instance'. + * Implements hook_ENTITY_TYPE_delete() for field_instance(). */ function comment_field_instance_delete(FieldInstanceInterface $instance) { if ($instance->getType() == 'comment') { @@ -343,7 +343,6 @@ function comment_new_page_count($num_comments, $new_replies, EntityInterface $en else { // Threaded comments: we build a query with a subquery to find the first // thread with a new comment. - // 1. Find all the threads with a new comment. $unread_threads_query = db_select('comment') ->fields('comment', array('thread')) @@ -371,12 +370,12 @@ function comment_new_page_count($num_comments, $new_replies, EntityInterface $en AND entity_type = :entity_type AND field_id = :field_id AND status = :status AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < :thread', array( - ':status' => CommentInterface::PUBLISHED, - ':entity_id' => $entity->id(), - ':field_id' => $entity->entityType() . '__' . $field_name, - ':entity_type' => $entity->entityType(), - ':thread' => $first_thread, - ))->fetchField(); + ':status' => CommentInterface::PUBLISHED, + ':entity_id' => $entity->id(), + ':field_id' => $entity->entityType() . '__' . $field_name, + ':entity_type' => $entity->entityType(), + ':thread' => $first_thread, + ))->fetchField(); $pageno = $count / $comments_per_page; } @@ -430,14 +429,15 @@ function comment_entity_view(EntityInterface $entity, EntityViewDisplayInterface // Entity have commenting open or close. $uri = $entity->uri(); if ($view_mode == 'rss') { - // Add a comments RSS element which is a URL to the comments of this node. + // Add a comments RSS element which is a URL to the comments + // of this node. if (!empty($uri['options'])) { $uri['options']['fragment'] = 'comments'; $uri['options']['absolute'] = TRUE; } $entity->rss_elements[] = array( 'key' => 'comments', - 'value' => url($uri['path'], $uri['options']) + 'value' => url($uri['path'], $uri['options']), ); } elseif ($view_mode == 'teaser') { @@ -479,7 +479,7 @@ function comment_entity_view(EntityInterface $entity, EntityViewDisplayInterface 'fragment' => 'comment-form', ); if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE) { - $links['comment-add']['href'] = 'comment/reply/'. $entity->entityType() . '/' . $entity->id() .'/' . $field_name; + $links['comment-add']['href'] = 'comment/reply/' . $entity->entityType() . '/' . $entity->id() . '/' . $field_name; } } else { @@ -508,7 +508,7 @@ function comment_entity_view(EntityInterface $entity, EntityViewDisplayInterface 'fragment' => 'comment-form', ); if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE) { - $links['comment-add']['href'] = 'comment/reply/'. $entity->entityType() . '/' . $entity->id() .'/' . $field_name; + $links['comment-add']['href'] = 'comment/reply/' . $entity->entityType() . '/' . $entity->id() . '/' . $field_name; } } } @@ -535,7 +535,11 @@ function comment_entity_view(EntityInterface $entity, EntityViewDisplayInterface array('node_id' => $entity->id()), ); $entity->content['links']['#post_render_cache']['Drupal\comment\CommentViewBuilder::attachNewCommentsLinkMetadata'] = array( - array('entity_type' => $entity->entityType(), 'entity_id' => $entity->id(), 'field_name' => $field_name), + array( + 'entity_type' => $entity->entityType(), + 'entity_id' => $entity->id(), + 'field_name' => $field_name, + ), ); } } @@ -726,7 +730,7 @@ function comment_prepare_thread(&$comments) { } } - // The final comment must close up some hanging divs + // The final comment must close up some hanging divs. $comments[$key]->divs_final = $divs; } @@ -735,9 +739,9 @@ function comment_prepare_thread(&$comments) { * * @param \Drupal\comment\CommentInterface $comment * The comment object. - * @param $view_mode + * @param string $view_mode * (optional) View mode, e.g. 'full', 'teaser'... Defaults to 'full'. - * @param $langcode + * @param string $langcode * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. * @@ -751,11 +755,11 @@ function comment_view(CommentInterface $comment, $view_mode = 'full', $langcode /** * Constructs render array from an array of loaded comments. * - * @param $comments + * @param object $comments * An array of comments as returned by entity_load_multiple(). - * @param $view_mode + * @param string $view_mode * View mode, e.g. 'full', 'teaser'... - * @param $langcode + * @param string $langcode * (optional) A string indicating the language field values are to be shown * in. If no language is provided the current content language is used. * Defaults to NULL. @@ -899,7 +903,7 @@ function comment_entity_insert(EntityInterface $entity) { 'last_comment_timestamp', 'last_comment_name', 'last_comment_uid', - 'comment_count' + 'comment_count', )); foreach ($fields as $field_name => $detail) { // Skip fields that entity does not have. @@ -1007,7 +1011,8 @@ function comment_node_update_index(EntityInterface $node, $langcode) { * Implements hook_update_index(). */ function comment_update_index() { - // Store the maximum possible comments per thread (used for ranking by reply count) + // Store the maximum possible comments + // per thread (used for ranking by reply count)! \Drupal::state()->set('comment.node_comment_statistics_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {comment_entity_statistics}')->fetchField())); } @@ -1039,7 +1044,9 @@ function comment_node_search_result(EntityInterface $node) { // Do not make a string if there are no comment fields, or no comments exist // or all comment fields are hidden. if ($comments > 0 || $open) { - return array('comment' => format_plural($comments, '1 comment', '@count comments')); + return array( + 'comment' => format_plural($comments, '1 comment', '@count comments'), + ); } } @@ -1118,7 +1125,7 @@ function comment_load($cid, $reset = FALSE) { * Entity type of the entity to which the comments are attached. * @param string $field_name * (optional) The field_name to count comments for. Defaults to NULL. - * @param $timestamp + * @param int $timestamp * Time to count from (defaults to time of last user access to node). * * @return int|false @@ -1180,8 +1187,8 @@ function comment_num_new($entity_id, $entity_type, $field_name = NULL, $timestam * @return int * The display ordinal for the comment. * - * @see comment_get_display_page() - * @see field_info_instance(). + * see comment_get_display_page() + * see field_info_instance(). */ function comment_get_display_ordinal($cid, $instance) { // Count how many comments (c1) are before $cid (c2) in display order. This is @@ -1302,7 +1309,7 @@ function comment_preview(CommentInterface $comment, array &$form_state) { } /** - * Implements hook_preprocess_HOOK() for block templates. + * Implements hook_preprocess_HOOK() for block.tpl.php. */ function comment_preprocess_block(&$variables) { if ($variables['configuration']['module'] == 'comment') { @@ -1326,7 +1333,11 @@ function comment_prepare_author(CommentInterface $comment) { // The account has been pre-loaded by CommentViewBuilder::buildContent(). $account = $comment->uid->entity; if (empty($account->uid->value)) { - $account = entity_create('user', array('uid' => 0, 'name' => $comment->name->value, 'homepage' => $comment->homepage->value)); + $account = entity_create('user', array( + 'uid' => 0, + 'name' => $comment->name->value, + 'homepage' => $comment->homepage->value, + )); } return $account; } @@ -1374,7 +1385,7 @@ function template_preprocess_comment(&$variables) { } if (\Drupal::config('user.settings')->get('signatures') && $account->getSignature()) { - $variables['signature'] = check_markup($account->getSignature(), $account->getSignatureFormat(), '', TRUE) ; + $variables['signature'] = check_markup($account->getSignature(), $account->getSignatureFormat(), '', TRUE); } else { $variables['signature'] = ''; @@ -1509,7 +1520,7 @@ function _comment_per_page() { * 2100, 2101, ..., 2zzy, 2zzz, * 31000, 31001, ... * - * @deprecated Use \Drupal\Component\Utility\Number::intToAlphadecimal() instead. + * @deprecated Use\Drupal\Component\Utility\Number::intToAlphadecimal() instead. */ function comment_int_to_alphadecimal($i = 0) { return Number::alphadecimalToInt($i); @@ -1518,7 +1529,7 @@ function comment_int_to_alphadecimal($i = 0) { /** * Decodes a sorting code back to an integer. * - * @deprecated Use \Drupal\Component\Utility\Number::alphadecimalToInt() instead. + * @deprecated Use\Drupal\Component\Utility\Number::alphadecimalToInt() instead. */ function comment_alphadecimal_to_int($c = '00') { return Number::alphadecimalToInt($c); @@ -1539,7 +1550,8 @@ function comment_ranking() { // nodes. 'on' => "ces.entity_id = i.sid AND ces.entity_type = 'node' AND ces.field_id = 'node__comment'", ), - // Inverse law that maps the highest reply count on the site to 1 and 0 to 0. + // Inverse law that maps the highest reply count + // on the site to 1 and 0 to 0. 'score' => '2.0 - 2.0 / (1.0 + ces.comment_count * CAST(:scale AS DECIMAL))', 'arguments' => array(':scale' => \Drupal::state()->get('comment.node_comment_statistics_scale') ?: 0), ),