Merge "Fix WatchedItemStore last-seen stashing logic"
[lhc/web/wiklou.git] / includes / user / User.php
index 1e3ecf2..277731a 100644 (file)
@@ -1191,6 +1191,8 @@ class User implements IDBAccessObject, UserIdentity {
         * - forceChange (bool): if set to true, the user should not be
         *   allowed to log with this password unless they change it during
         *   the login process (see ResetPasswordSecondaryAuthenticationProvider).
+        * - suggestChangeOnLogin (bool): if set to true, the user should be prompted for
+        *   a password change on login.
         *
         * @param string $password Desired password
         * @return Status
@@ -4266,7 +4268,7 @@ class User implements IDBAccessObject, UserIdentity {
 
                Hooks::run( 'UserSaveSettings', [ $this ] );
                $this->clearSharedCache();
-               $this->getUserPage()->invalidateCache();
+               $this->getUserPage()->purgeSquid();
        }
 
        /**
@@ -4974,6 +4976,28 @@ class User implements IDBAccessObject, UserIdentity {
         *  non-existent/anonymous user accounts.
         */
        public function getFirstEditTimestamp() {
+               return $this->getEditTimestamp( true );
+       }
+
+       /**
+        * Get the timestamp of the latest edit
+        *
+        * @since 1.33
+        * @return string|bool Timestamp of first edit, or false for
+        *  non-existent/anonymous user accounts.
+        */
+       public function getLatestEditTimestamp() {
+               return $this->getEditTimestamp( false );
+       }
+
+       /**
+        * Get the timestamp of the first or latest edit
+        *
+        * @param bool $first True for the first edit, false for the latest one
+        * @return string|bool Timestamp of first or latest edit, or false for
+        *  non-existent/anonymous user accounts.
+        */
+       private function getEditTimestamp( $first ) {
                if ( $this->getId() == 0 ) {
                        return false; // anons
                }
@@ -4981,12 +5005,13 @@ class User implements IDBAccessObject, UserIdentity {
                $actorWhere = ActorMigration::newMigration()->getWhere( $dbr, 'rev_user', $this );
                $tsField = isset( $actorWhere['tables']['temp_rev_user'] )
                        ? 'revactor_timestamp' : 'rev_timestamp';
+               $sortOrder = $first ? 'ASC' : 'DESC';
                $time = $dbr->selectField(
                        [ 'revision' ] + $actorWhere['tables'],
                        $tsField,
                        [ $actorWhere['conds'] ],
                        __METHOD__,
-                       [ 'ORDER BY' => "$tsField ASC" ],
+                       [ 'ORDER BY' => "$tsField $sortOrder" ],
                        $actorWhere['joins']
                );
                if ( !$time ) {