Drop support for XHTML 1.0
[lhc/web/wiklou.git] / includes / User.php
index 37a384c..1d87d40 100644 (file)
@@ -1807,8 +1807,11 @@ class User {
        }
 
        /**
-        * Return the talk page(s) this user has new messages on.
-        * @return Array of String page URLs
+        * Return the revision and link for the oldest new talk page message for
+        * this user.
+        * Note: This function was designed to accomodate multiple talk pages, but
+        * currently only returns a single link and revision.
+        * @return Array
         */
        public function getNewMessageLinks() {
                $talks = array();
@@ -1828,6 +1831,28 @@ class User {
                return array( array( 'wiki' => wfWikiID(), 'link' => $utp->getLocalURL(), 'rev' => $rev ) );
        }
 
+       /**
+        * Get the revision ID for the oldest new talk page message for this user
+        * @return Integer or null if there are no new messages
+        */
+       public function getNewMessageRevisionId() {
+               $newMessageRevisionId = null;
+               $newMessageLinks = $this->getNewMessageLinks();
+               if ( $newMessageLinks ) {
+                       // Note: getNewMessageLinks() never returns more than a single link
+                       // and it is always for the same wiki, but we double-check here in
+                       // case that changes some time in the future.
+                       if ( count( $newMessageLinks ) === 1
+                               && $newMessageLinks[0]['wiki'] === wfWikiID()
+                               && $newMessageLinks[0]['rev']
+                       ) {
+                               $newMessageRevision = $newMessageLinks[0]['rev'];
+                               $newMessageRevisionId = $newMessageRevision->getId();
+                       }
+               }
+               return $newMessageRevisionId;
+       }
+
        /**
         * Internal uncached check for new messages
         *
@@ -3263,7 +3288,7 @@ class User {
                        }
                        if ( !$loaded ) {
                                throw new MWException( __METHOD__ . ": hit a key conflict attempting " .
-                                       "to insert a user row, but then it doesn't exist when we select it!" );
+                                       "to insert user '{$this->mName}' row, but it was not present in select!" );
                        }
                        return Status::newFatal( 'userexists' );
                }
@@ -4482,8 +4507,7 @@ class User {
         *
         * @return array Array of HTML attributes suitable for feeding to
         *   Html::element(), directly or indirectly.  (Don't feed to Xml::*()!
-        *   That will potentially output invalid XHTML 1.0 Transitional, and will
-        *   get confused by the boolean attribute syntax used.)
+        *   That will get confused by the boolean attribute syntax used.)
         */
        public static function passwordChangeInputAttribs() {
                global $wgMinimalPasswordLength;