Tweaked User::READ_LOCKING to use LOCK IN SHARE MODE
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 14 Jul 2015 18:13:01 +0000 (11:13 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 14 Jul 2015 18:13:05 +0000 (11:13 -0700)
* This better alignes with IDBAccessObject docs and
  still locks out INSERTs

Change-Id: Ib8713938e0afa14bee6f90bc51d6331eaf356447

includes/User.php

index 95ac0f1..339487d 100644 (file)
@@ -3721,15 +3721,13 @@ class User implements IDBAccessObject {
                        : wfGetDB( DB_SLAVE );
 
                $options = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING )
-                       ? array( 'FOR UPDATE' )
+                       ? array( 'LOCK IN SHARE MODE' )
                        : array();
 
-               $id = $db->selectField( 'user', 'user_id', array( 'user_name' => $s ), __METHOD__, $options );
-               if ( $id === false ) {
-                       $id = 0;
-               }
+               $id = $db->selectField( 'user',
+                       'user_id', array( 'user_name' => $s ), __METHOD__, $options );
 
-               return $id;
+               return (int)$id;
        }
 
        /**