update drupal
This commit is contained in:
@@ -144,9 +144,9 @@ class CommentLazyBuilders implements TrustedCallbackInterface {
|
||||
if (!$is_in_preview) {
|
||||
/** @var \Drupal\comment\CommentInterface $entity */
|
||||
$entity = $this->entityTypeManager->getStorage('comment')->load($comment_entity_id);
|
||||
$commented_entity = $entity->getCommentedEntity();
|
||||
|
||||
$links['comment'] = $this->buildLinks($entity, $commented_entity);
|
||||
if ($commented_entity = $entity->getCommentedEntity()) {
|
||||
$links['comment'] = $this->buildLinks($entity, $commented_entity);
|
||||
}
|
||||
|
||||
// Allow other modules to alter the comment links.
|
||||
$hook_context = [
|
||||
|
||||
@@ -80,9 +80,11 @@ class CommentViewBuilder extends EntityViewBuilder {
|
||||
|
||||
/** @var \Drupal\comment\CommentInterface $entity */
|
||||
// Store a threading field setting to use later in self::buildComponents().
|
||||
$build['#comment_threaded'] = $entity->getCommentedEntity()
|
||||
->getFieldDefinition($entity->getFieldName())
|
||||
->getSetting('default_mode') === CommentManagerInterface::COMMENT_MODE_THREADED;
|
||||
$commented_entity = $entity->getCommentedEntity();
|
||||
$build['#comment_threaded'] =
|
||||
is_null($commented_entity)
|
||||
|| $commented_entity->getFieldDefinition($entity->getFieldName())
|
||||
->getSetting('default_mode') === CommentManagerInterface::COMMENT_MODE_THREADED;
|
||||
// If threading is enabled, don't render cache individual comments, but do
|
||||
// keep the cacheability metadata, so it can bubble up.
|
||||
if ($build['#comment_threaded']) {
|
||||
@@ -140,10 +142,12 @@ class CommentViewBuilder extends EntityViewBuilder {
|
||||
|
||||
// Commented entities already loaded after self::getBuildDefaults().
|
||||
$commented_entity = $entity->getCommentedEntity();
|
||||
// Set defaults if the commented_entity does not exist.
|
||||
$bundle = $commented_entity ? $commented_entity->bundle() : '';
|
||||
$is_node = $commented_entity ? $commented_entity->getEntityTypeId() === 'node' : NULL;
|
||||
|
||||
$build[$id]['#entity'] = $entity;
|
||||
$build[$id]['#theme'] = 'comment__' . $entity->getFieldName() . '__' . $commented_entity->bundle();
|
||||
|
||||
$build[$id]['#theme'] = 'comment__' . $entity->getFieldName() . '__' . $bundle;
|
||||
$display = $displays[$entity->bundle()];
|
||||
if ($display->getComponent('links')) {
|
||||
$build[$id]['links'] = [
|
||||
@@ -164,7 +168,7 @@ class CommentViewBuilder extends EntityViewBuilder {
|
||||
$build[$id]['#attached'] = [];
|
||||
}
|
||||
$build[$id]['#attached']['library'][] = 'comment/drupal.comment-by-viewer';
|
||||
if ($attach_history && $commented_entity->getEntityTypeId() === 'node') {
|
||||
if ($attach_history && $is_node) {
|
||||
$build[$id]['#attached']['library'][] = 'comment/drupal.comment-new-indicator';
|
||||
|
||||
// Embed the metadata for the comment "new" indicators on this node.
|
||||
|
||||
@@ -250,7 +250,7 @@ class CommentViewsData extends EntityViewsData {
|
||||
// the same two tables is not supported.
|
||||
if (\Drupal::service('comment.manager')->getFields($type)) {
|
||||
$data['comment_entity_statistics']['table']['join'][$entity_type->getDataTable() ?: $entity_type->getBaseTable()] = [
|
||||
'type' => 'INNER',
|
||||
'type' => 'LEFT',
|
||||
'left_field' => $entity_type->getKey('id'),
|
||||
'field' => 'entity_id',
|
||||
'extra' => [
|
||||
|
||||
@@ -404,7 +404,8 @@ class Comment extends ContentEntityBase implements CommentInterface {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorName() {
|
||||
if ($this->get('uid')->target_id) {
|
||||
// If their is a valid user id and the user entity exists return the label.
|
||||
if ($this->get('uid')->target_id && $this->get('uid')->entity) {
|
||||
return $this->get('uid')->entity->label();
|
||||
}
|
||||
return $this->get('name')->value ?: \Drupal::config('user.settings')->get('anonymous');
|
||||
@@ -510,8 +511,8 @@ class Comment extends ContentEntityBase implements CommentInterface {
|
||||
*/
|
||||
public static function preCreate(EntityStorageInterface $storage, array &$values) {
|
||||
if (empty($values['comment_type']) && !empty($values['field_name']) && !empty($values['entity_type'])) {
|
||||
$field_storage = FieldStorageConfig::loadByName($values['entity_type'], $values['field_name']);
|
||||
$values['comment_type'] = $field_storage->getSetting('comment_type');
|
||||
$fields = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions($values['entity_type']);
|
||||
$values['comment_type'] = $fields[$values['field_name']]->getSetting('comment_type');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ class NodeNewComments extends NumericField {
|
||||
}
|
||||
|
||||
if ($nids) {
|
||||
$result = $this->database->query("SELECT n.nid, COUNT(c.cid) as num_comments FROM {node} n INNER JOIN {comment_field_data} c ON n.nid = c.entity_id AND c.entity_type = 'node' AND c.default_langcode = 1
|
||||
$result = $this->database->query("SELECT n.nid, COUNT(c.cid) AS num_comments FROM {node} n INNER JOIN {comment_field_data} c ON n.nid = c.entity_id AND c.entity_type = 'node' AND c.default_langcode = 1
|
||||
LEFT JOIN {history} h ON h.nid = n.nid AND h.uid = :h_uid WHERE n.nid IN ( :nids[] )
|
||||
AND c.changed > GREATEST(COALESCE(h.timestamp, :timestamp1), :timestamp2) AND c.status = :status GROUP BY n.nid", [
|
||||
':status' => CommentInterface::PUBLISHED,
|
||||
|
||||
Reference in New Issue
Block a user