diff -u b/core/modules/forum/forum.services.yml b/core/modules/forum/forum.services.yml --- b/core/modules/forum/forum.services.yml +++ b/core/modules/forum/forum.services.yml @@ -1,7 +1,7 @@ services: forum_manager: class: Drupal\forum\ForumManager - arguments: ['@config.factory', '@entity_type.manager', '@database', '@string_translation', '@comment.manager', '@history.repository', '@entity_field.manager'] + arguments: ['@config.factory', '@entity_type.manager', '@database', '@string_translation', '@comment.manager', '@entity_field.manager', '@history.repository'] tags: - { name: backend_overridable } forum.breadcrumb.node: diff -u b/core/modules/forum/src/ForumManager.php b/core/modules/forum/src/ForumManager.php --- b/core/modules/forum/src/ForumManager.php +++ b/core/modules/forum/src/ForumManager.php @@ -12,8 +12,8 @@ use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\comment\CommentManagerInterface; -use Drupal\history\HistoryRepositoryInterface; use Drupal\node\NodeInterface; +use Drupal\history\HistoryRepositoryInterface; /** * Provides forum manager service. @@ -141,23 +141,27 @@ * The translation manager service. * @param \Drupal\comment\CommentManagerInterface $comment_manager * The comment manager service. - * @param \Drupal\history\HistoryRepositoryInterface $history_repository - * The history repository service. * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager * The entity field manager. + * @param \Drupal\history\HistoryRepositoryInterface $history_repository + * The history repository service. */ - public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, Connection $connection, TranslationInterface $string_translation, CommentManagerInterface $comment_manager, HistoryRepositoryInterface $history_repository, EntityFieldManagerInterface $entity_field_manager = NULL) { + public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, Connection $connection, TranslationInterface $string_translation, CommentManagerInterface $comment_manager, EntityFieldManagerInterface $entity_field_manager = NULL, HistoryRepositoryInterface $history_repository = NULL) { $this->configFactory = $config_factory; $this->entityTypeManager = $entity_type_manager; $this->connection = $connection; $this->stringTranslation = $string_translation; $this->commentManager = $comment_manager; - $this->historyRepository = $history_repository; if (!$entity_field_manager) { @trigger_error('The entity_field.manager service must be passed to ForumManager::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED); $entity_field_manager = \Drupal::service('entity_field.manager'); } $this->entityFieldManager = $entity_field_manager; + if (!$history_repository) { + @trigger_error('The history.repository service must be passed to ForumManager::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/2081585.', E_USER_DEPRECATED); + $history_repository = \Drupal::service('history.repository'); + } + $this->historyRepository = $history_repository; } /** @@ -343,11 +347,10 @@ if (isset($this->history[$nid])) { return $this->history[$nid]; } - $this->history += $this->historyRepository->getLastViewed('node', array($nid), $account); + $this->history += $this->historyRepository->getLastViewed('node', [$nid], $account); if (empty($this->history[$nid])) { $this->history[$nid] = HISTORY_READ_LIMIT; } - return $this->history[$nid]; } diff -u b/core/modules/forum/tests/src/Unit/ForumManagerTest.php b/core/modules/forum/tests/src/Unit/ForumManagerTest.php --- b/core/modules/forum/tests/src/Unit/ForumManagerTest.php +++ b/core/modules/forum/tests/src/Unit/ForumManagerTest.php @@ -72,8 +72,8 @@ $connection, $translation_manager, $comment_manager, - $history_repository, $entity_field_manager, + $history_repository, ]) ->getMock(); only in patch2: unchanged: --- a/core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php +++ b/core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php @@ -25,6 +25,7 @@ class BlockConfigSchemaTest extends KernelTestBase { 'block_content', 'comment', 'forum', + 'history', 'node', 'statistics', // BlockManager->getModuleName() calls system_get_info(). only in patch2: unchanged: --- a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php @@ -20,6 +20,7 @@ class MigrateBlockContentTranslationTest extends MigrateDrupal6TestBase { 'block', 'comment', 'forum', + 'history', 'views', 'block_content', 'content_translation', only in patch2: unchanged: --- a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php +++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php @@ -164,7 +164,7 @@ public function preRender(&$values) { 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 - LEFT JOIN {history} h ON h.nid = n.nid AND h.uid = :h_uid WHERE n.nid IN ( :nids[] ) + LEFT JOIN {history} h ON h.entity_id = 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, ':h_uid' => $user->id(), only in patch2: unchanged: --- a/core/modules/forum/tests/src/Kernel/ForumValidationTest.php +++ b/core/modules/forum/tests/src/Kernel/ForumValidationTest.php @@ -18,7 +18,7 @@ class ForumValidationTest extends EntityKernelTestBase { * * @var array */ - public static $modules = ['node', 'options', 'comment', 'taxonomy', 'forum']; + public static $modules = ['node', 'options', 'comment', 'taxonomy', 'history', 'forum']; /** * Tests the forum validation constraints. only in patch2: unchanged: --- a/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumConfigsTest.php +++ b/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumConfigsTest.php @@ -17,7 +17,7 @@ class MigrateForumConfigsTest extends MigrateDrupal6TestBase { /** * {@inheritdoc} */ - public static $modules = ['comment', 'forum', 'taxonomy']; + public static $modules = ['comment', 'forum', 'history', 'taxonomy']; /** * {@inheritdoc} only in patch2: unchanged: --- a/core/modules/forum/tests/src/Kernel/Migrate/d7/MigrateForumSettingsTest.php +++ b/core/modules/forum/tests/src/Kernel/Migrate/d7/MigrateForumSettingsTest.php @@ -19,6 +19,7 @@ class MigrateForumSettingsTest extends MigrateDrupal7TestBase { 'text', 'node', 'taxonomy', + 'history', 'forum', ]; only in patch2: unchanged: --- a/core/modules/migrate/tests/src/Kernel/Plugin/MigrationPluginListTest.php +++ b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationPluginListTest.php @@ -39,6 +39,7 @@ class MigrationPluginListTest extends KernelTestBase { 'file', 'filter', 'forum', + 'history', 'image', 'language', 'locale',