LocalIdLookup: Use DBAccessObjectUtils
authorKunal Mehta <legoktm@member.fsf.org>
Tue, 13 Sep 2016 04:29:41 +0000 (21:29 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Tue, 13 Sep 2016 04:47:13 +0000 (21:47 -0700)
This simplies some code that was re-implementing
DBAccessObjectUtils::getDBOptions().

Change-Id: Ib446f43149abdf23f07f209ccd9698923f0a2c22

includes/user/LocalIdLookup.php

index 0d8b1a8..0a34554 100644 (file)
@@ -60,10 +60,8 @@ class LocalIdLookup extends CentralIdLookup {
                }
 
                $audience = $this->checkAudience( $audience );
-               $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_REPLICA );
-               $options = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING )
-                       ? [ 'LOCK IN SHARE MODE' ]
-                       : [];
+               list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
+               $db = wfGetDB( $index );
 
                $tables = [ 'user' ];
                $fields = [ 'user_id', 'user_name' ];
@@ -93,10 +91,8 @@ class LocalIdLookup extends CentralIdLookup {
                }
 
                $audience = $this->checkAudience( $audience );
-               $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_REPLICA );
-               $options = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING )
-                       ? [ 'LOCK IN SHARE MODE' ]
-                       : [];
+               list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
+               $db = wfGetDB( $index );
 
                $tables = [ 'user' ];
                $fields = [ 'user_id', 'user_name' ];