Issue #1861874 by dawehner, damiankloip, tim.plunkett: Change all uses of NODE_NEW_LIMIT to HISTORY_READ_LIMIT.
parent
33e284e8e9
commit
8f03af994a
|
@ -85,7 +85,7 @@ class NodeNewComments extends Numeric {
|
|||
$query->addExpression('COUNT(c.cid)', 'num_comments');
|
||||
$query->leftJoin('history', 'h', 'h.nid = n.nid');
|
||||
$query->condition('n.nid', $nids);
|
||||
$query->where('c.changed > GREATEST(COALESCE(h.timestamp, :timestamp), :timestamp)', array(':timestamp' => NODE_NEW_LIMIT));
|
||||
$query->where('c.changed > GREATEST(COALESCE(h.timestamp, :timestamp), :timestamp)', array(':timestamp' => HISTORY_READ_LIMIT));
|
||||
$query->condition('c.status', COMMENT_PUBLISHED);
|
||||
$query->groupBy('n.nid');
|
||||
$result = $query->execute();
|
||||
|
|
|
@ -34,12 +34,12 @@ function history_views_data() {
|
|||
$data['history']['timestamp'] = array(
|
||||
'title' => t('Has new content'),
|
||||
'field' => array(
|
||||
'id' => 'node_history_user_timestamp',
|
||||
'id' => 'history_user_timestamp',
|
||||
'help' => t('Show a marker if the content is new or updated.'),
|
||||
),
|
||||
'filter' => array(
|
||||
'help' => t('Show only content that is new or updated.'),
|
||||
'id' => 'node_history_user_timestamp',
|
||||
'id' => 'history_user_timestamp',
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Definition of Drupal\node\Plugin\views\field\HistoryUserTimestamp.
|
||||
* Contains \Drupal\history\Plugin\views\field\HistoryUserTimestamp.
|
||||
*/
|
||||
|
||||
namespace Drupal\node\Plugin\views\field;
|
||||
namespace Drupal\history\Plugin\views\field;
|
||||
|
||||
use Drupal\views\ViewExecutable;
|
||||
use Drupal\views\Plugin\views\display\DisplayPluginBase;
|
||||
|
@ -15,14 +15,14 @@ use Drupal\Core\Annotation\Plugin;
|
|||
/**
|
||||
* Field handler to display the marker for new content.
|
||||
*
|
||||
* The handler is named history_user, because of compability reasons, the table
|
||||
* is history.
|
||||
* The handler is named history_user, because of compatibility reasons, the
|
||||
* table is history.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*
|
||||
* @Plugin(
|
||||
* id = "node_history_user_timestamp",
|
||||
* module = "node"
|
||||
* id = "history_user_timestamp",
|
||||
* module = "history"
|
||||
* )
|
||||
*/
|
||||
class HistoryUserTimestamp extends Node {
|
||||
|
@ -84,13 +84,13 @@ class HistoryUserTimestamp extends Node {
|
|||
|
||||
$last_comment = module_exists('comment') && !empty($this->options['comments']) ? $this->get_value($values, 'last_comment') : 0;
|
||||
|
||||
if (!$last_read && $changed > NODE_NEW_LIMIT) {
|
||||
if (!$last_read && $changed > HISTORY_READ_LIMIT) {
|
||||
$mark = MARK_NEW;
|
||||
}
|
||||
elseif ($changed > $last_read && $changed > NODE_NEW_LIMIT) {
|
||||
elseif ($changed > $last_read && $changed > HISTORY_READ_LIMIT) {
|
||||
$mark = MARK_UPDATED;
|
||||
}
|
||||
elseif ($last_comment > $last_read && $last_comment > NODE_NEW_LIMIT) {
|
||||
elseif ($last_comment > $last_read && $last_comment > HISTORY_READ_LIMIT) {
|
||||
$mark = MARK_UPDATED;
|
||||
}
|
||||
return $this->render_link(theme('mark', array('type' => $mark)), $values);
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Definition of Drupal\node\Plugin\views\filter\HistoryUserTimestamp.
|
||||
* Contains \Drupal\history\Plugin\views\filter\HistoryUserTimestamp.
|
||||
*/
|
||||
|
||||
namespace Drupal\node\Plugin\views\filter;
|
||||
namespace Drupal\history\Plugin\views\filter;
|
||||
|
||||
use Drupal\views\Plugin\views\filter\FilterPluginBase;
|
||||
use Drupal\Core\Annotation\Plugin;
|
||||
|
@ -13,14 +13,14 @@ use Drupal\Core\Annotation\Plugin;
|
|||
/**
|
||||
* Filter for new content.
|
||||
*
|
||||
* The handler is named history_user, because of compability reasons, the table
|
||||
* is history.
|
||||
* The handler is named history_user, because of compatibility reasons, the
|
||||
* table is history.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*
|
||||
* @Plugin(
|
||||
* id = "node_history_user_timestamp",
|
||||
* module = "node"
|
||||
* id = "history_user_timestamp",
|
||||
* module = "history"
|
||||
* )
|
||||
*/
|
||||
class HistoryUserTimestamp extends FilterPluginBase {
|
||||
|
@ -68,9 +68,9 @@ class HistoryUserTimestamp extends FilterPluginBase {
|
|||
}
|
||||
|
||||
// Hey, Drupal kills old history, so nodes that haven't been updated
|
||||
// since NODE_NEW_LIMIT are bzzzzzzzt outta here!
|
||||
// since HISTORY_READ_LIMIT are bzzzzzzzt outta here!
|
||||
|
||||
$limit = REQUEST_TIME - NODE_NEW_LIMIT;
|
||||
$limit = REQUEST_TIME - HISTORY_READ_LIMIT;
|
||||
|
||||
$this->ensureMyTable();
|
||||
$field = "$this->tableAlias.$this->realField";
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\history\Tests\Views\HistoryTimestampTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\history\Tests\Views;
|
||||
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
|
||||
/**
|
||||
* Tests the history timestamp handlers.
|
||||
*
|
||||
* @see \Drupal\history\Plugin\views\field\HistoryTimestamp.
|
||||
* @see \Drupal\history\Plugin\views\filter\HistoryTimestamp.
|
||||
*/
|
||||
class HistoryTimestampTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('history', 'node');
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_history');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'History Integration',
|
||||
'description' => 'Tests the history timestamp handlers.',
|
||||
'group' => 'Views Modules',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the handlers.
|
||||
*/
|
||||
public function testHandlers() {
|
||||
$nodes = array();
|
||||
$nodes[] = $this->drupalCreateNode();
|
||||
$nodes[] = $this->drupalCreateNode();
|
||||
|
||||
$account = $this->drupalCreateUser();
|
||||
$this->drupalLogin($account);
|
||||
$GLOBALS['user'] = $account;
|
||||
|
||||
db_insert('history')
|
||||
->fields(array(
|
||||
'uid' => $account->id(),
|
||||
'nid' => $nodes[0]->id(),
|
||||
'timestamp' => REQUEST_TIME - 100,
|
||||
))->execute();
|
||||
|
||||
db_insert('history')
|
||||
->fields(array(
|
||||
'uid' => $account->id(),
|
||||
'nid' => $nodes[1]->id(),
|
||||
'timestamp' => REQUEST_TIME + 100,
|
||||
))->execute();
|
||||
|
||||
|
||||
$column_map = array(
|
||||
'nid' => 'nid',
|
||||
);
|
||||
|
||||
// Test the history field.
|
||||
$view = views_get_view('test_history');
|
||||
$view->setDisplay('page_1');
|
||||
$this->executeView($view);
|
||||
$this->assertEqual(count($view->result), 2);
|
||||
$output = $view->preview();
|
||||
$this->drupalSetContent($output);
|
||||
$result = $this->xpath('//span[@class=:class]', array(':class' => 'marker'));
|
||||
$this->assertEqual(count($result), 1, 'Just one node is marked as new');
|
||||
|
||||
// Test the history filter.
|
||||
$view = views_get_view('test_history');
|
||||
$view->setDisplay('page_2');
|
||||
$this->executeView($view);
|
||||
$this->assertEqual(count($view->result), 1);
|
||||
$this->assertIdenticalResultset($view, array(array('nid' => $nodes[0]->id())), $column_map);
|
||||
}
|
||||
}
|
|
@ -30,6 +30,7 @@ class HandlerAllTest extends HandlerTestBase {
|
|||
'field',
|
||||
'filter',
|
||||
'file',
|
||||
'history',
|
||||
'language',
|
||||
'locale',
|
||||
'node',
|
||||
|
|
|
@ -0,0 +1,208 @@
|
|||
api_version: '3.0'
|
||||
base_field: nid
|
||||
base_table: node
|
||||
core: 8.x
|
||||
description: ''
|
||||
disabled: '0'
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: ''
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
cache:
|
||||
type: none
|
||||
query:
|
||||
type: views_query
|
||||
exposed_form:
|
||||
type: basic
|
||||
pager:
|
||||
type: full
|
||||
style:
|
||||
type: default
|
||||
row:
|
||||
type: fields
|
||||
fields:
|
||||
title:
|
||||
id: title
|
||||
table: node
|
||||
field: title
|
||||
label: ''
|
||||
alter:
|
||||
alter_text: '0'
|
||||
make_link: '0'
|
||||
absolute: '0'
|
||||
trim: '0'
|
||||
word_boundary: '0'
|
||||
ellipsis: '0'
|
||||
strip_tags: '0'
|
||||
html: '0'
|
||||
hide_empty: '0'
|
||||
empty_zero: '0'
|
||||
link_to_node: '1'
|
||||
timestamp:
|
||||
id: timestamp
|
||||
table: history
|
||||
field: timestamp
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: 'Has new content'
|
||||
exclude: '0'
|
||||
alter:
|
||||
alter_text: '0'
|
||||
text: ''
|
||||
make_link: '0'
|
||||
path: ''
|
||||
absolute: '0'
|
||||
external: '0'
|
||||
replace_spaces: '0'
|
||||
path_case: none
|
||||
trim_whitespace: '0'
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: '0'
|
||||
max_length: ''
|
||||
word_boundary: '1'
|
||||
ellipsis: '1'
|
||||
more_link: '0'
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: '0'
|
||||
trim: '0'
|
||||
preserve_tags: ''
|
||||
html: '0'
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: '1'
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: '1'
|
||||
empty: ''
|
||||
hide_empty: '0'
|
||||
empty_zero: '0'
|
||||
hide_alter_empty: '1'
|
||||
link_to_node: '0'
|
||||
comments: '0'
|
||||
filters:
|
||||
status:
|
||||
value: '1'
|
||||
table: node
|
||||
field: status
|
||||
id: status
|
||||
expose:
|
||||
operator: '0'
|
||||
group: '1'
|
||||
sorts:
|
||||
created:
|
||||
id: created
|
||||
table: node
|
||||
field: created
|
||||
order: DESC
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: 'Page without new filter'
|
||||
position: ''
|
||||
display_options:
|
||||
display_description: ''
|
||||
path: test-without-history
|
||||
page_2:
|
||||
display_plugin: page
|
||||
id: page_2
|
||||
display_title: 'Page with new filter'
|
||||
position: ''
|
||||
display_options:
|
||||
display_description: ''
|
||||
path: test-with-history
|
||||
filters:
|
||||
status:
|
||||
id: status
|
||||
table: node
|
||||
field: status
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: '1'
|
||||
group: '1'
|
||||
exposed: '0'
|
||||
expose:
|
||||
operator_id: '0'
|
||||
label: ''
|
||||
description: ''
|
||||
use_operator: '0'
|
||||
operator: '0'
|
||||
identifier: ''
|
||||
required: '0'
|
||||
remember: '0'
|
||||
multiple: '0'
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
is_grouped: '0'
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: '1'
|
||||
widget: select
|
||||
multiple: '0'
|
||||
remember: '0'
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
timestamp:
|
||||
id: timestamp
|
||||
table: history
|
||||
field: timestamp
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: ''
|
||||
group: '1'
|
||||
exposed: '0'
|
||||
expose:
|
||||
operator_id: '0'
|
||||
label: ''
|
||||
description: ''
|
||||
use_operator: '0'
|
||||
operator: ''
|
||||
identifier: ''
|
||||
required: '0'
|
||||
remember: '0'
|
||||
multiple: '0'
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
is_grouped: '0'
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: '1'
|
||||
widget: select
|
||||
multiple: '0'
|
||||
remember: '0'
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
defaults:
|
||||
filters: '0'
|
||||
filter_groups: '0'
|
||||
filter_groups:
|
||||
operator: AND
|
||||
groups:
|
||||
1: AND
|
||||
human_name: test_history
|
||||
module: views
|
||||
name: test_history
|
||||
tag: ''
|
Loading…
Reference in New Issue