Make edit stash keys less preference sensitive
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 6 Jun 2016 21:34:14 +0000 (14:34 -0700)
committerOri.livneh <ori@wikimedia.org>
Mon, 6 Jun 2016 22:03:11 +0000 (22:03 +0000)
Only factor in the user ID/name/sig instead of anything that
might happen to touch the user row.

Bug: T136678
Change-Id: I004790a017c68cfcff6729f6fbfd0f79b6904c20

includes/api/ApiStashEdit.php

index e739e51..01153a5 100644 (file)
@@ -406,11 +406,15 @@ class ApiStashEdit extends ApiBase {
         */
        private static function getStashKey( Title $title, Content $content, User $user ) {
                $hash = sha1( implode( ':', [
         */
        private static function getStashKey( Title $title, Content $content, User $user ) {
                $hash = sha1( implode( ':', [
+                       // Account for the edit model/text
                        $content->getModel(),
                        $content->getDefaultFormat(),
                        sha1( $content->serialize( $content->getDefaultFormat() ) ),
                        $content->getModel(),
                        $content->getDefaultFormat(),
                        sha1( $content->serialize( $content->getDefaultFormat() ) ),
-                       $user->getId() ?: md5( $user->getName() ), // account for user parser options
-                       $user->getId() ? $user->getDBTouched() : '-' // handle preference change races
+                       // Account for user name related variables like signatures
+                       $user->getId(),
+                       md5( $user->getName() ),
+                       (string)$user->getOption( 'nickname' ),
+                       (int)$user->getBoolOption( 'fancysig' )
                ] ) );
 
                return wfMemcKey( 'prepared-edit', md5( $title->getPrefixedDBkey() ), $hash );
                ] ) );
 
                return wfMemcKey( 'prepared-edit', md5( $title->getPrefixedDBkey() ), $hash );