From: Aaron Schulz Date: Thu, 28 Mar 2019 17:58:42 +0000 (-0700) Subject: rdbms: add IDatabase::UNION_* constants for readability X-Git-Tag: 1.34.0-rc.0~2274^2 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=d630dfb439b1f71fe077897322ec29daeed9a605;p=lhc%2Fweb%2Fwiklou.git rdbms: add IDatabase::UNION_* constants for readability Change-Id: I0d39242d1c4bd8c2236f0b0cd21eb3f604b7d2bd --- diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index 3781ab0f35..7e46c1a036 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -268,7 +268,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase { [ 'ar_rev_id' => $revids ], __METHOD__ ), - ], false ); + ], $db::UNION_DISTINCT ); $res = $db->query( $sql, __METHOD__ ); foreach ( $res as $row ) { if ( (int)$row->id === (int)$params['startid'] ) { diff --git a/includes/libs/rdbms/database/IDatabase.php b/includes/libs/rdbms/database/IDatabase.php index eac9baed0e..b4440d6dfa 100644 --- a/includes/libs/rdbms/database/IDatabase.php +++ b/includes/libs/rdbms/database/IDatabase.php @@ -114,6 +114,11 @@ interface IDatabase { */ const QUERY_PSEUDO_PERMANENT = 2; + /** @var bool Parameter to unionQueries() for UNION ALL */ + const UNION_ALL = true; + /** @var bool Parameter to unionQueries() for UNION DISTINCT */ + const UNION_DISTINCT = false; + /** * A string describing the current software version, and possibly * other details in a user-friendly way. Will be listed on Special:Version, etc. @@ -1384,7 +1389,7 @@ interface IDatabase { * This is used for providing overload point for other DB abstractions * not compatible with the MySQL syntax. * @param array $sqls SQL statements to combine - * @param bool $all Use UNION ALL + * @param bool $all Either IDatabase::UNION_ALL or IDatabase::UNION_DISTINCT * @return string SQL fragment */ public function unionQueries( $sqls, $all ); diff --git a/includes/specials/SpecialRecentchangeslinked.php b/includes/specials/SpecialRecentchangeslinked.php index 62c867b44c..88656546e3 100644 --- a/includes/specials/SpecialRecentchangeslinked.php +++ b/includes/specials/SpecialRecentchangeslinked.php @@ -224,7 +224,8 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { $sql = $subsql[0]; } else { // need to resort and relimit after union - $sql = $dbr->unionQueries( $subsql, false ) . ' ORDER BY rc_timestamp DESC'; + $sql = $dbr->unionQueries( $subsql, $dbr::UNION_DISTINCT ) . + ' ORDER BY rc_timestamp DESC'; $sql = $dbr->limitResult( $sql, $limit, false ); } diff --git a/maintenance/findOrphanedFiles.php b/maintenance/findOrphanedFiles.php index 57e04e0ea1..e81e1971ec 100644 --- a/maintenance/findOrphanedFiles.php +++ b/maintenance/findOrphanedFiles.php @@ -117,7 +117,7 @@ class FindOrphanedFiles extends Maintenance { $oiWheres ? $dbr->makeList( $oiWheres, LIST_OR ) : '1=0' ) ], - true // UNION ALL (performance) + $dbr::UNION_ALL ), __METHOD__ );