Kaldari has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/74547


Change subject: Making sure wgUserNewMsgRevisionId works even for the first post
......................................................................

Making sure wgUserNewMsgRevisionId works even for the first post

Bug: 51640
Change-Id: Ie8215f2240ecb683279be3ab9de78b4b33067794
---
M includes/User.php
1 file changed, 15 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/47/74547/1

diff --git a/includes/User.php b/includes/User.php
index 685bce7..21b0f82 100644
--- a/includes/User.php
+++ b/includes/User.php
@@ -1844,10 +1844,23 @@
                $utp = $this->getTalkPage();
                $dbr = wfGetDB( DB_SLAVE );
                // Get the "last viewed rev" timestamp from the oldest message 
notification
-               $timestamp = $dbr->selectField( 'user_newtalk',
+               $timestamp = $dbr->selectField(
+                       'user_newtalk',
                        'MIN(user_last_timestamp)',
                        $this->isAnon() ? array( 'user_ip' => $this->getName() 
) : array( 'user_id' => $this->getID() ),
-                       __METHOD__ );
+                       __METHOD__
+               );
+               // If the user has never visited their talk page, 
user_last_timestamp
+               // will be null for all of their talk page revisions.
+               if ( !$timestamp ) {
+                       // Retrieve the timestamp of the first revision for the 
talk page
+                       $timestamp = $dbr->selectField(
+                               'revision',
+                               'MIN(rev_timestamp)',
+                               array( 'rev_page' => $utp->getArticleID() ),
+                               __METHOD__
+                       );
+               }
                $rev = $timestamp ? Revision::loadFromTimestamp( $dbr, $utp, 
$timestamp ) : null;
                return array( array( 'wiki' => wfWikiID(), 'link' => 
$utp->getLocalURL(), 'rev' => $rev ) );
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/74547
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie8215f2240ecb683279be3ab9de78b4b33067794
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to