Skip to content
Snippets Groups Projects
Unverified Commit 5bd2dd5d authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2605714 by andypost, Utkarsh_Mishra, Chi, idebr: Cleanup...

Issue #2605714 by andypost, Utkarsh_Mishra, Chi, idebr: Cleanup HistoryUserTimestamp views filter handler
parent 25d96908
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -42,6 +42,9 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o ...@@ -42,6 +42,9 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
} }
} }
/**
* {@inheritdoc}
*/
protected function defineOptions() { protected function defineOptions() {
$options = parent::defineOptions(); $options = parent::defineOptions();
...@@ -50,6 +53,9 @@ protected function defineOptions() { ...@@ -50,6 +53,9 @@ protected function defineOptions() {
return $options; return $options;
} }
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) { public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state); parent::buildOptionsForm($form, $form_state);
if (\Drupal::moduleHandler()->moduleExists('comment')) { if (\Drupal::moduleHandler()->moduleExists('comment')) {
...@@ -61,6 +67,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ...@@ -61,6 +67,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
} }
} }
/**
* {@inheritdoc}
*/
public function query() { public function query() {
// Only add ourselves to the query if logged in. // Only add ourselves to the query if logged in.
if (\Drupal::currentUser()->isAnonymous()) { if (\Drupal::currentUser()->isAnonymous()) {
......
...@@ -20,7 +20,9 @@ class HistoryUserTimestamp extends FilterPluginBase { ...@@ -20,7 +20,9 @@ class HistoryUserTimestamp extends FilterPluginBase {
use UncacheableDependencyTrait; use UncacheableDependencyTrait;
// Don't display empty space where the operator would be. /**
* {@inheritdoc}
*/
public $no_operator = TRUE; public $no_operator = TRUE;
/** /**
...@@ -30,6 +32,9 @@ public function usesGroupBy() { ...@@ -30,6 +32,9 @@ public function usesGroupBy() {
return FALSE; return FALSE;
} }
/**
* {@inheritdoc}
*/
public function buildExposeForm(&$form, FormStateInterface $form_state) { public function buildExposeForm(&$form, FormStateInterface $form_state) {
parent::buildExposeForm($form, $form_state); parent::buildExposeForm($form, $form_state);
// @todo There are better ways of excluding required and multiple (object flags) // @todo There are better ways of excluding required and multiple (object flags)
...@@ -38,6 +43,9 @@ public function buildExposeForm(&$form, FormStateInterface $form_state) { ...@@ -38,6 +43,9 @@ public function buildExposeForm(&$form, FormStateInterface $form_state) {
unset($form['expose']['remember']); unset($form['expose']['remember']);
} }
/**
* {@inheritdoc}
*/
protected function valueForm(&$form, FormStateInterface $form_state) { protected function valueForm(&$form, FormStateInterface $form_state) {
// Only present a checkbox for the exposed filter itself. There's no way // 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 // to tell the difference between not checked and the default value, so
...@@ -57,6 +65,9 @@ protected function valueForm(&$form, FormStateInterface $form_state) { ...@@ -57,6 +65,9 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
} }
} }
/**
* {@inheritdoc}
*/
public function query() { public function query() {
// This can only work if we're authenticated in. // This can only work if we're authenticated in.
if (!\Drupal::currentUser()->isAuthenticated()) { if (!\Drupal::currentUser()->isAuthenticated()) {
...@@ -70,7 +81,6 @@ public function query() { ...@@ -70,7 +81,6 @@ public function query() {
// Hey, Drupal kills old history, so nodes that haven't been updated // Hey, Drupal kills old history, so nodes that haven't been updated
// since HISTORY_READ_LIMIT are bzzzzzzzt outta here! // since HISTORY_READ_LIMIT are bzzzzzzzt outta here!
$limit = REQUEST_TIME - HISTORY_READ_LIMIT; $limit = REQUEST_TIME - HISTORY_READ_LIMIT;
$this->ensureMyTable(); $this->ensureMyTable();
...@@ -79,9 +89,9 @@ public function query() { ...@@ -79,9 +89,9 @@ public function query() {
$clause = ''; $clause = '';
$clause2 = ''; $clause2 = '';
if ($ces = $this->query->ensureTable('comment_entity_statistics', $this->relationship)) { if ($alias = $this->query->ensureTable('comment_entity_statistics', $this->relationship)) {
$clause = ("OR $ces.last_comment_timestamp > (***CURRENT_TIME*** - $limit)"); $clause = "OR $alias.last_comment_timestamp > (***CURRENT_TIME*** - $limit)";
$clause2 = "OR $field < $ces.last_comment_timestamp"; $clause2 = "OR $field < $alias.last_comment_timestamp";
} }
// NULL means a history record doesn't exist. That's clearly new content. // NULL means a history record doesn't exist. That's clearly new content.
...@@ -90,6 +100,9 @@ public function query() { ...@@ -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"); $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() { public function adminSummary() {
if (!empty($this->options['exposed'])) { if (!empty($this->options['exposed'])) {
return $this->t('exposed'); return $this->t('exposed');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment