From 5bd2dd5dd32c1b7a1f878baf1e1d7709f243fd6b Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Wed, 11 Apr 2018 21:50:57 +0100 Subject: [PATCH] Issue #2605714 by andypost, Utkarsh_Mishra, Chi, idebr: Cleanup HistoryUserTimestamp views filter handler --- .../views/field/HistoryUserTimestamp.php | 9 ++++++++ .../views/filter/HistoryUserTimestamp.php | 23 +++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php index 3a8b22d00ecb..617cd23e12d5 100644 --- a/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php +++ b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php @@ -42,6 +42,9 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o } } + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -50,6 +53,9 @@ protected function defineOptions() { return $options; } + /** + * {@inheritdoc} + */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); if (\Drupal::moduleHandler()->moduleExists('comment')) { @@ -61,6 +67,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { } } + /** + * {@inheritdoc} + */ public function query() { // Only add ourselves to the query if logged in. if (\Drupal::currentUser()->isAnonymous()) { diff --git a/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php index 92a57991ca7b..02288da1c4f2 100644 --- a/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php +++ b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php @@ -20,7 +20,9 @@ class HistoryUserTimestamp extends FilterPluginBase { use UncacheableDependencyTrait; - // Don't display empty space where the operator would be. + /** + * {@inheritdoc} + */ public $no_operator = TRUE; /** @@ -30,6 +32,9 @@ public function usesGroupBy() { return FALSE; } + /** + * {@inheritdoc} + */ public function buildExposeForm(&$form, FormStateInterface $form_state) { parent::buildExposeForm($form, $form_state); // @todo There are better ways of excluding required and multiple (object flags) @@ -38,6 +43,9 @@ public function buildExposeForm(&$form, FormStateInterface $form_state) { unset($form['expose']['remember']); } + /** + * {@inheritdoc} + */ protected function valueForm(&$form, FormStateInterface $form_state) { // Only present a checkbox for the exposed filter itself. There's no way // to tell the difference between not checked and the default value, so @@ -57,6 +65,9 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } } + /** + * {@inheritdoc} + */ public function query() { // This can only work if we're authenticated in. if (!\Drupal::currentUser()->isAuthenticated()) { @@ -70,7 +81,6 @@ public function query() { // Hey, Drupal kills old history, so nodes that haven't been updated // since HISTORY_READ_LIMIT are bzzzzzzzt outta here! - $limit = REQUEST_TIME - HISTORY_READ_LIMIT; $this->ensureMyTable(); @@ -79,9 +89,9 @@ public function query() { $clause = ''; $clause2 = ''; - 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"; + if ($alias = $this->query->ensureTable('comment_entity_statistics', $this->relationship)) { + $clause = "OR $alias.last_comment_timestamp > (***CURRENT_TIME*** - $limit)"; + $clause2 = "OR $field < $alias.last_comment_timestamp"; } // NULL means a history record doesn't exist. That's clearly new content. @@ -90,6 +100,9 @@ public function query() { $this->query->addWhereExpression($this->options['group'], "($field IS NULL AND ($node.changed > (***CURRENT_TIME*** - $limit) $clause)) OR $field < $node.changed $clause2"); } + /** + * {@inheritdoc} + */ public function adminSummary() { if (!empty($this->options['exposed'])) { return $this->t('exposed'); -- GitLab