Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
d084d2d2
Commit
d084d2d2
authored
Jun 6, 2014
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2224917
by m1r1k, drumm, Steven Jones: Fixed Tracker page doesn't order results properly.
parent
c42dc376
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/tracker/src/Tests/TrackerTest.php
+66
-0
66 additions, 0 deletions
core/modules/tracker/src/Tests/TrackerTest.php
core/modules/tracker/tracker.module
+9
-1
9 additions, 1 deletion
core/modules/tracker/tracker.module
with
75 additions
and
1 deletion
core/modules/tracker/src/Tests/TrackerTest.php
+
66
−
0
View file @
d084d2d2
...
...
@@ -220,6 +220,72 @@ function testTrackerNewComments() {
$this
->
assertText
(
'1 new'
,
'New comments are counted on the tracker listing pages.'
);
}
/**
* Tests for ordering on a users tracker listing when comments are posted.
*/
function
testTrackerOrderingNewComments
()
{
$this
->
drupalLogin
(
$this
->
user
);
$node_one
=
$this
->
drupalCreateNode
(
array
(
'title'
=>
$this
->
randomName
(
8
),
));
$node_two
=
$this
->
drupalCreateNode
(
array
(
'title'
=>
$this
->
randomName
(
8
),
));
// Now get other_user to track these pieces of content.
$this
->
drupalLogin
(
$this
->
other_user
);
// Add a comment to the first page.
$comment
=
array
(
'subject'
=>
$this
->
randomName
(),
'comment_body[0][value]'
=>
$this
->
randomName
(
20
),
);
$this
->
drupalPostForm
(
'comment/reply/node/'
.
$node_one
->
id
()
.
'/comment'
,
$comment
,
t
(
'Save'
));
// If the comment is posted in the same second as the last one then Drupal
// can't tell the difference, so we wait one second here.
sleep
(
1
);
// Add a comment to the second page.
$comment
=
array
(
'subject'
=>
$this
->
randomName
(),
'comment_body[0][value]'
=>
$this
->
randomName
(
20
),
);
$this
->
drupalPostForm
(
'comment/reply/node/'
.
$node_two
->
id
()
.
'/comment'
,
$comment
,
t
(
'Save'
));
// We should at this point have in our tracker for other_user:
// 1. node_two
// 2. node_one
// Because that's the reverse order of the posted comments.
// Now we're going to post a comment to node_one which should jump it to the
// top of the list.
$this
->
drupalLogin
(
$this
->
user
);
// If the comment is posted in the same second as the last one then Drupal
// can't tell the difference, so we wait one second here.
sleep
(
1
);
// Add a comment to the second page.
$comment
=
array
(
'subject'
=>
$this
->
randomName
(),
'comment_body[0][value]'
=>
$this
->
randomName
(
20
),
);
$this
->
drupalPostForm
(
'comment/reply/node/'
.
$node_one
->
id
()
.
'/comment'
,
$comment
,
t
(
'Save'
));
// Switch back to the other_user and assert that the order has swapped.
$this
->
drupalLogin
(
$this
->
other_user
);
$this
->
drupalGet
(
'user/'
.
$this
->
other_user
->
id
()
.
'/track'
);
// This is a cheeky way of asserting that the nodes are in the right order
// on the tracker page.
// It's almost certainly too brittle.
$pattern
=
'/'
.
preg_quote
(
$node_one
->
getTitle
())
.
'.+'
.
preg_quote
(
$node_two
->
getTitle
())
.
'/s'
;
$this
->
verbose
(
$pattern
);
$this
->
assertPattern
(
$pattern
,
'Most recently commented on node appears at the top of tracker'
);
}
/**
* Tests that existing nodes are indexed by cron.
*/
...
...
This diff is collapsed.
Click to expand it.
core/modules/tracker/tracker.module
+
9
−
1
View file @
d084d2d2
...
...
@@ -256,7 +256,7 @@ function _tracker_add($nid, $uid, $changed) {
))
->
execute
();
// Create or update the user-level data.
// Create or update the user-level data
, first for the user posting
.
db_merge
(
'tracker_user'
)
->
keys
(
array
(
'nid'
=>
$nid
,
...
...
@@ -267,6 +267,14 @@ function _tracker_add($nid, $uid, $changed) {
'published'
=>
$node
->
status
,
))
->
execute
();
// Update the times for all the other users tracking the post.
db_update
(
'tracker_user'
)
->
condition
(
'nid'
,
$nid
)
->
fields
(
array
(
'changed'
=>
$changed
,
'published'
=>
$node
->
status
,
))
->
execute
();
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment