From 6c1211ed43fab7b71acc3db354ef62721e7d1a51 Mon Sep 17 00:00:00 2001 From: Stephane Bisson Date: Fri, 3 Jun 2016 09:05:10 -0400 Subject: [PATCH] Add column alias support in BatchRowIterator Used by Echo/maintenance/backfillReadBundles Bug: T136368 Change-Id: Ia8f8aa718713798a81392b5e9751c5c18ab81720 --- includes/utils/BatchRowIterator.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 = []; -- 2.20.1