Commit 5bd2dd5d authored by alexpott's avatar alexpott

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

Issue #2605714 by andypost, Utkarsh_Mishra, Chi, idebr: Cleanup HistoryUserTimestamp views filter handler
parent 25d96908
......@@ -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()) {
......
......@@ -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');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment