Skip to content

Commit

Permalink
Fix minoredits=exclude
Browse files Browse the repository at this point in the history
fixes issue Universal-Omega#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.
  • Loading branch information
HamishSlater committed Jun 16, 2023
1 parent 1ac2411 commit 2c72d81
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions includes/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2c72d81

Please sign in to comment.