X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Futils%2FBatchRowIterator.php;h=ef2c14a9b793342a8d6dc2e1e3ec56030404915d;hb=9964ca1a390c446397dcd466916ffed356cdc3c9;hp=9fc243120a644a42b05f5c422166caa5ae29f660;hpb=a303296f2730d6279a249bde77f3e0b9b42e494f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/utils/BatchRowIterator.php b/includes/utils/BatchRowIterator.php index 9fc243120a..ef2c14a9b7 100644 --- a/includes/utils/BatchRowIterator.php +++ b/includes/utils/BatchRowIterator.php @@ -77,16 +77,21 @@ class BatchRowIterator implements RecursiveIterator { */ private $key; + /** + * @var array Additional query options + */ + protected $options = []; + /** * @param IDatabase $db The database to read from * @param string|array $table The name or names of the table to read from * @param string|array $primaryKey The name or names of the primary key columns * @param integer $batchSize The number of rows to fetch per iteration - * @throws MWException + * @throws InvalidArgumentException */ public function __construct( IDatabase $db, $table, $primaryKey, $batchSize ) { if ( $batchSize < 1 ) { - throw new MWException( 'Batch size must be at least 1 row.' ); + throw new InvalidArgumentException( 'Batch size must be at least 1 row.' ); } $this->db = $db; $this->table = $table; @@ -97,7 +102,7 @@ class BatchRowIterator implements RecursiveIterator { } /** - * @param array $condition Query conditions suitable for use with + * @param array $conditions Query conditions suitable for use with * IDatabase::select */ public function addConditions( array $conditions ) { @@ -105,7 +110,15 @@ class BatchRowIterator implements RecursiveIterator { } /** - * @param array $condition Query join conditions suitable for use + * @param array $options Query options suitable for use with + * IDatabase::select + */ + public function addOptions( array $options ) { + $this->options = array_merge( $this->options, $options ); + } + + /** + * @param array $conditions Query join conditions suitable for use * with IDatabase::select */ public function addJoinConditions( array $conditions ) { @@ -199,7 +212,7 @@ class BatchRowIterator implements RecursiveIterator { [ 'LIMIT' => $this->batchSize, 'ORDER BY' => $this->orderBy, - ], + ] + $this->options, $this->joinConditions );