function HistoryUserTimestamp::query
Same name in this branch
- 10 core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php \Drupal\history\Plugin\views\field\HistoryUserTimestamp::query()
Same name in other branches
- 9 core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php \Drupal\history\Plugin\views\field\HistoryUserTimestamp::query()
- 9 core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php \Drupal\history\Plugin\views\filter\HistoryUserTimestamp::query()
- 8.9.x core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php \Drupal\history\Plugin\views\field\HistoryUserTimestamp::query()
- 8.9.x core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php \Drupal\history\Plugin\views\filter\HistoryUserTimestamp::query()
- 11.x core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php \Drupal\history\Plugin\views\field\HistoryUserTimestamp::query()
- 11.x core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php \Drupal\history\Plugin\views\filter\HistoryUserTimestamp::query()
Overrides FilterPluginBase::query
File
-
core/
modules/ history/ src/ Plugin/ views/ filter/ HistoryUserTimestamp.php, line 106
Class
- HistoryUserTimestamp
- Filter for new content.
Namespace
Drupal\history\Plugin\views\filterCode
public function query() {
// This can only work if we're authenticated in.
if (!\Drupal::currentUser()->isAuthenticated()) {
return;
}
// Don't filter if we're exposed and the checkbox isn't selected.
if (!empty($this->options['exposed']) && empty($this->value)) {
return;
}
// Hey, Drupal kills old history, so nodes that haven't been updated
// since HISTORY_READ_LIMIT are outta here!
$limit = $this->time
->getRequestTime() - HISTORY_READ_LIMIT;
$this->ensureMyTable();
$field = "{$this->tableAlias}.{$this->realField}";
$node = $this->query
->ensureTable('node_field_data', $this->relationship);
$clause = '';
$clause2 = '';
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.
// Unless it's very very old content. Everything in the query is already
// type safe cause none of it is coming from outside here.
$this->query
->addWhereExpression($this->options['group'], "({$field} IS NULL AND ({$node}.changed > (***CURRENT_TIME*** - {$limit}) {$clause})) OR {$field} < {$node}.changed {$clause2}");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.