X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fuser%2FLocalIdLookup.php;h=0a345540ffc3445931424894334579e94c9b70fa;hb=8a95833baed3b8071fcbd8cd2bc8c3449409f665;hp=c0f9c05490010f464c626b0715eb48dcb892f7c8;hpb=3c18e32e58d53ab38d1dd52d00f248ddef435ebd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/user/LocalIdLookup.php b/includes/user/LocalIdLookup.php index c0f9c05490..0a345540ff 100644 --- a/includes/user/LocalIdLookup.php +++ b/includes/user/LocalIdLookup.php @@ -56,24 +56,22 @@ class LocalIdLookup extends CentralIdLookup { array $idToName, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL ) { if ( !$idToName ) { - return array(); + return []; } $audience = $this->checkAudience( $audience ); - $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_SLAVE ); - $options = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING ) - ? array( 'LOCK IN SHARE MODE' ) - : array(); + list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags ); + $db = wfGetDB( $index ); - $tables = array( 'user' ); - $fields = array( 'user_id', 'user_name' ); - $where = array( + $tables = [ 'user' ]; + $fields = [ 'user_id', 'user_name' ]; + $where = [ 'user_id' => array_map( 'intval', array_keys( $idToName ) ), - ); - $join = array(); + ]; + $join = []; if ( $audience && !$audience->isAllowed( 'hideuser' ) ) { $tables[] = 'ipblocks'; - $join['ipblocks'] = array( 'LEFT JOIN', 'ipb_user=user_id' ); + $join['ipblocks'] = [ 'LEFT JOIN', 'ipb_user=user_id' ]; $fields[] = 'ipb_deleted'; } @@ -89,24 +87,22 @@ class LocalIdLookup extends CentralIdLookup { array $nameToId, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL ) { if ( !$nameToId ) { - return array(); + return []; } $audience = $this->checkAudience( $audience ); - $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_SLAVE ); - $options = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING ) - ? array( 'LOCK IN SHARE MODE' ) - : array(); + list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags ); + $db = wfGetDB( $index ); - $tables = array( 'user' ); - $fields = array( 'user_id', 'user_name' ); - $where = array( + $tables = [ 'user' ]; + $fields = [ 'user_id', 'user_name' ]; + $where = [ 'user_name' => array_map( 'strval', array_keys( $nameToId ) ), - ); - $join = array(); + ]; + $join = []; if ( $audience && !$audience->isAllowed( 'hideuser' ) ) { $tables[] = 'ipblocks'; - $join['ipblocks'] = array( 'LEFT JOIN', 'ipb_user=user_id' ); + $join['ipblocks'] = [ 'LEFT JOIN', 'ipb_user=user_id' ]; $where[] = 'ipb_deleted = 0 OR ipb_deleted IS NULL'; }