diff --git a/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php index 22169273257b818bd31e363d8eda6af665ff4f5d..9abfe563963af071c8f30699c861b06937cb74b7 100644 --- a/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php +++ b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php @@ -81,8 +81,7 @@ public function query() { $clause = ''; $clause2 = ''; - if (\Drupal::moduleHandler()->moduleExists('comment')) { - $ces = $this->query->ensureTable('comment_entity_statistics', $this->relationship); + if ($ces = $this->query->ensureTable('comment_entity_statistics', $this->relationship)) { $clause = ("OR $ces.last_comment_timestamp > (***CURRENT_TIME*** - $limit)"); $clause2 = "OR $field < $ces.last_comment_timestamp"; } diff --git a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php b/core/modules/history/src/Tests/Views/HistoryTimestampTest.php index 44f67f95867380eb6cc116a30286e81fd81a1703..a76a5e8049a50bfafa67ad5af67d242ba3119035 100644 --- a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php +++ b/core/modules/history/src/Tests/Views/HistoryTimestampTest.php @@ -80,5 +80,14 @@ public function testHandlers() { $this->executeView($view); $this->assertEqual(count($view->result), 1); $this->assertIdenticalResultset($view, array(array('nid' => $nodes[0]->id())), $column_map); + + // Install Comment module and make sure that content types without comment + // field will not break the view. + // See \Drupal\history\Plugin\views\filter\HistoryUserTimestamp::query() + \Drupal::service('module_installer')->install(['comment']); + $view = Views::getView('test_history'); + $view->setDisplay('page_2'); + $this->executeView($view); + } }