From 9c8e3214f3c31ddc7b5f7376ba95e2b4d0ec42aa Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 11 May 2017 18:18:44 -0400 Subject: [PATCH] ApiQueryRevisions: Don't be so tricky handling rvstartid/rvendid If someone strangely supplies 0 as an id, the tricky version confuses that with null and winds up making the DB layer throw an exception. Just do it more straightforwardly. Bug: T165100 Change-Id: Id8376d419e7758c0bf92ad50dd7b7ac283a73101 --- includes/api/ApiQueryRevisions.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index b0a8468428..a4f0315e9f 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -219,26 +219,26 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase { } // Convert startid/endid to timestamps (T163532) - if ( $params['startid'] !== null || $params['endid'] !== null ) { - $ids = [ - (int)$params['startid'] => true, - (int)$params['endid'] => true, - ]; - unset( $ids[0] ); // null - $ids = array_keys( $ids ); - + $revids = []; + if ( $params['startid'] !== null ) { + $revids[] = (int)$params['startid']; + } + if ( $params['endid'] !== null ) { + $revids[] = (int)$params['endid']; + } + if ( $revids ) { $db = $this->getDB(); $sql = $db->unionQueries( [ $db->selectSQLText( 'revision', [ 'id' => 'rev_id', 'ts' => 'rev_timestamp' ], - [ 'rev_id' => $ids ], + [ 'rev_id' => $revids ], __METHOD__ ), $db->selectSQLText( 'archive', [ 'id' => 'ar_rev_id', 'ts' => 'ar_timestamp' ], - [ 'ar_rev_id' => $ids ], + [ 'ar_rev_id' => $revids ], __METHOD__ ), ], false ); -- 2.20.1