Add setCaller to BatchRowIterator

Bug: T260354
Change-Id: Ia1e2dcc75c1350a9a2c6bffccdc8398ce695e3f3
This commit is contained in:
Reedy 2020-08-15 13:09:44 +01:00 committed by Umherirrender
parent 2c6c17223a
commit 62d8fe2eac

View file

@ -88,6 +88,11 @@ class BatchRowIterator implements RecursiveIterator {
*/
protected $options = [];
/**
* For debugging which method is using this class.
*/
protected $caller;
/**
* @stable to call
*
@ -149,6 +154,20 @@ class BatchRowIterator implements RecursiveIterator {
}
}
/**
* Use ->setCaller( __METHOD__ ) to indicate which code is using this
* class. Only used in debugging output.
* @since 1.36
*
* @param string $caller
* @return self
*/
public function setCaller( $caller ) {
$this->caller = $caller;
return $this;
}
/**
* Extracts the primary key(s) from a database row.
*
@ -212,11 +231,16 @@ class BatchRowIterator implements RecursiveIterator {
* Fetch the next set of rows from the database.
*/
public function next() {
$caller = __METHOD__;
if ( (string)$this->caller !== '' ) {
$caller .= " (for {$this->caller})";
}
$res = $this->db->select(
$this->table,
$this->fetchColumns,
$this->buildConditions(),
__METHOD__,
$caller,
[
'LIMIT' => $this->batchSize,
'ORDER BY' => $this->orderBy,