From 2c72d8185d34038a5e2492dc196bc877efbd1c07 Mon Sep 17 00:00:00 2001 From: Hamish Slater Date: Fri, 16 Jun 2023 12:00:12 +0200 Subject: [PATCH] Fix minoredits=exclude fixes issue #226 Previously, the query selected the latest revision for each page based on the rev_timestamp, but did not consider the rev_minor_edit value until afterwards. Now it will retrieve the latest revision that satisfies the condition rev.rev_minor_edit = 0. --- includes/Query.php | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/includes/Query.php b/includes/Query.php index ec4ade04..eaa90d6b 100644 --- a/includes/Query.php +++ b/includes/Query.php @@ -1575,18 +1575,6 @@ private function _maxrevisions( $option ) { $this->addWhere( "((SELECT count(rev_aux3.rev_page) FROM {$this->tableNames['revision']} AS rev_aux3 WHERE rev_aux3.rev_page = {$this->tableNames['page']}.page_id) <= {$option})" ); } - /** - * Set SQL for 'minoredits' parameter. - * - * @param mixed $option - */ - private function _minoredits( $option ) { - if ( isset( $option ) && $option == 'exclude' ) { - $this->addTable( 'revision', 'revision' ); - $this->addWhere( 'revision.rev_minor_edit = 0' ); - } - } - /** * Set SQL for 'minrevisions' parameter. * @@ -1867,12 +1855,13 @@ private function _ordermethod( $option ) { $this->addSelect( [ 'rev.rev_timestamp' ] ); if ( !$this->revisionAuxWhereAdded ) { - $this->addWhere( - [ - "{$this->tableNames['page']}.page_id = rev.rev_page", - "rev.rev_timestamp = (SELECT MAX(rev_aux.rev_timestamp) FROM {$this->tableNames['revision']} AS rev_aux WHERE rev_aux.rev_page = rev.rev_page)" - ] - ); + $this->addWhere( "{$this->tableNames['page']}.page_id = rev.rev_page" ); + + if ( $this->parameters->getParameter( 'minoredits' ) == 'exclude' ) { + $this->addWhere( "rev.rev_timestamp = (SELECT MAX(rev_aux.rev_timestamp) FROM {$this->tableNames['revision']} AS rev_aux WHERE rev_aux.rev_page = rev.rev_page AND rev_aux.rev_minor_edit = 0)" ); + } else { + $this->addWhere( "rev.rev_timestamp = (SELECT MAX(rev_aux.rev_timestamp) FROM {$this->tableNames['revision']} AS rev_aux WHERE rev_aux.rev_page = rev.rev_page)" ); + } } $this->revisionAuxWhereAdded = true;