[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Changed default sort to be on more than one field
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/402761 ) Change subject: Changed default sort to be on more than one field .. Changed default sort to be on more than one field Change-Id: Ieaedbcb5e375aae27eabe99e0ba931522e185f05 --- M includes/CargoSQLQuery.php 1 file changed, 19 insertions(+), 7 deletions(-) Approvals: Yaron Koren: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/CargoSQLQuery.php b/includes/CargoSQLQuery.php index 3a475bb..b41c058 100644 --- a/includes/CargoSQLQuery.php +++ b/includes/CargoSQLQuery.php @@ -392,13 +392,25 @@ if ( $orderByStr != '' ) { $this->mOrderByStr = $orderByStr; } else { - // By default, sort on the first field. - reset( $this->mAliasedFieldNames ); - $firstField = current( $this->mAliasedFieldNames ); - if ( strpos( $firstField, '(' ) === false && strpos( $firstField, '.' ) === false ) { - $this->mOrderByStr = $this->mCargoDB->addIdentifierQuotes( $firstField ); - } else { - $this->mOrderByStr = $firstField; + // By default, sort on up to the first five fields, in + // the order in which they're defined. Five seems like + // enough to make sure everything is in the right order, + // no? Or should it always be all the fields? + $this->mOrderByStr = ''; + $fieldNum = 1; + foreach ( $this->mAliasedFieldNames as $fieldName ) { + if ( $fieldNum > 1 ) { + $this->mOrderByStr .= ', '; + } + if ( strpos( $fieldName, '(' ) === false && strpos( $fieldName, '.' ) === false ) { + $this->mOrderByStr .= $this->mCargoDB->addIdentifierQuotes( $fieldName ); + } else { + $this->mOrderByStr .= $fieldName; + } + $fieldNum++; + if ( $fieldNum > 5 ) { + break; + } } } } -- To view, visit https://gerrit.wikimedia.org/r/402761 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ieaedbcb5e375aae27eabe99e0ba931522e185f05 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Cargo Gerrit-Branch: master Gerrit-Owner: Yaron KorenGerrit-Reviewer: Yaron Koren Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Changed default sort to be on more than one field
Yaron Koren has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/402761 ) Change subject: Changed default sort to be on more than one field .. Changed default sort to be on more than one field Change-Id: Ieaedbcb5e375aae27eabe99e0ba931522e185f05 --- M includes/CargoSQLQuery.php 1 file changed, 19 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo refs/changes/61/402761/2 diff --git a/includes/CargoSQLQuery.php b/includes/CargoSQLQuery.php index 3a475bb..b41c058 100644 --- a/includes/CargoSQLQuery.php +++ b/includes/CargoSQLQuery.php @@ -392,13 +392,25 @@ if ( $orderByStr != '' ) { $this->mOrderByStr = $orderByStr; } else { - // By default, sort on the first field. - reset( $this->mAliasedFieldNames ); - $firstField = current( $this->mAliasedFieldNames ); - if ( strpos( $firstField, '(' ) === false && strpos( $firstField, '.' ) === false ) { - $this->mOrderByStr = $this->mCargoDB->addIdentifierQuotes( $firstField ); - } else { - $this->mOrderByStr = $firstField; + // By default, sort on up to the first five fields, in + // the order in which they're defined. Five seems like + // enough to make sure everything is in the right order, + // no? Or should it always be all the fields? + $this->mOrderByStr = ''; + $fieldNum = 1; + foreach ( $this->mAliasedFieldNames as $fieldName ) { + if ( $fieldNum > 1 ) { + $this->mOrderByStr .= ', '; + } + if ( strpos( $fieldName, '(' ) === false && strpos( $fieldName, '.' ) === false ) { + $this->mOrderByStr .= $this->mCargoDB->addIdentifierQuotes( $fieldName ); + } else { + $this->mOrderByStr .= $fieldName; + } + $fieldNum++; + if ( $fieldNum > 5 ) { + break; + } } } } -- To view, visit https://gerrit.wikimedia.org/r/402761 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieaedbcb5e375aae27eabe99e0ba931522e185f05 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Cargo Gerrit-Branch: master Gerrit-Owner: Yaron KorenGerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits