From: Stephane Bisson Date: Fri, 3 Jun 2016 13:05:10 +0000 (-0400) Subject: Add column alias support in BatchRowIterator X-Git-Tag: 1.31.0-rc.0~6712^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=6c1211ed43fab7b71acc3db354ef62721e7d1a51;p=lhc%2Fweb%2Fwiklou.git Add column alias support in BatchRowIterator Used by Echo/maintenance/backfillReadBundles Bug: T136368 Change-Id: Ia8f8aa718713798a81392b5e9751c5c18ab81720 --- diff --git a/includes/utils/BatchRowIterator.php b/includes/utils/BatchRowIterator.php index 3bd3a4c3ec..419ee4730d 100644 --- a/includes/utils/BatchRowIterator.php +++ b/includes/utils/BatchRowIterator.php @@ -136,8 +136,9 @@ class BatchRowIterator implements RecursiveIterator { */ public function extractPrimaryKeys( $row ) { $pk = []; - foreach ( $this->primaryKey as $column ) { - $pk[$column] = $row->$column; + foreach ( $this->primaryKey as $alias => $column ) { + $name = is_numeric( $alias ) ? $column : $alias; + $pk[$name] = $row->{$name}; } return $pk; } @@ -228,8 +229,9 @@ class BatchRowIterator implements RecursiveIterator { $maxRow = end( $this->current ); $maximumValues = []; - foreach ( $this->primaryKey as $column ) { - $maximumValues[$column] = $this->db->addQuotes( $maxRow->$column ); + foreach ( $this->primaryKey as $alias => $column ) { + $name = is_numeric( $alias ) ? $column : $alias; + $maximumValues[$column] = $this->db->addQuotes( $maxRow->{$name} ); } $pkConditions = [];