X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FUserArray.php;h=31bd601c06c466d3e8d98701253cb129f90e42a6;hp=7da658272aa3d2565789cd260a559da77665dae5;hb=35d9ad550f2f443455b3b76495d9cebfafdfaf37;hpb=b2645d82849ca74b0e6b8df6a3e28e81d0561a58 diff --git a/includes/UserArray.php b/includes/UserArray.php index 7da658272a..31bd601c06 100644 --- a/includes/UserArray.php +++ b/includes/UserArray.php @@ -27,7 +27,7 @@ abstract class UserArray implements Iterator { */ static function newFromResult( $res ) { $userArray = null; - if ( !wfRunHooks( 'UserArrayFromResult', array( &$userArray, $res ) ) ) { + if ( !Hooks::run( 'UserArrayFromResult', array( &$userArray, $res ) ) ) { return null; } if ( $userArray === null ) { @@ -56,6 +56,27 @@ abstract class UserArray implements Iterator { return self::newFromResult( $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