X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FUserArray.php;h=31bd601c06c466d3e8d98701253cb129f90e42a6;hb=e7c9096ecc084bb81a99d3acc949c32b0ef49d56;hp=38f0d9d5187e6edc2fc1e0a5d9ea8fd50c0acc86;hpb=9e0b52b14537a4238239a6e8a2319fe3838fa409;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/UserArray.php b/includes/UserArray.php index 38f0d9d518..31bd601c06 100644 --- a/includes/UserArray.php +++ b/includes/UserArray.php @@ -22,12 +22,12 @@ abstract class UserArray implements Iterator { /** - * @param $res ResultWrapper + * @param ResultWrapper $res * @return UserArrayFromResult */ static function newFromResult( $res ) { $userArray = null; - if ( !wfRunHooks( 'UserArrayFromResult', array( &$userArray, $res ) ) ) { + if ( !Hooks::run( 'UserArrayFromResult', array( &$userArray, $res ) ) ) { return null; } if ( $userArray === null ) { @@ -37,7 +37,7 @@ abstract class UserArray implements Iterator { } /** - * @param $ids array + * @param array $ids * @return UserArrayFromResult */ static function newFromIDs( $ids ) { @@ -57,10 +57,31 @@ abstract class UserArray implements Iterator { } /** - * @param $res + * @since 1.25 + * @param array $names + * @return UserArrayFromResult + */ + static function newFromNames( $names ) { + $names = array_map( 'strval', (array)$names ); // paranoia + if ( !$names ) { + // Database::select() doesn't like empty arrays + return new ArrayIterator( array() ); + } + $dbr = wfGetDB( DB_SLAVE ); + $res = $dbr->select( + 'user', + User::selectFields(), + array( 'user_name' => array_unique( $names ) ), + __METHOD__ + ); + return self::newFromResult( $res ); + } + + /** + * @param ResultWrapper $res * @return UserArrayFromResult */ protected static function newFromResult_internal( $res ) { return new UserArrayFromResult( $res ); } -} \ No newline at end of file +}