[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Fix for 7af3648c8d98 - got blank aliases working again
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/401528 ) Change subject: Fix for 7af3648c8d98 - got blank aliases working again .. Fix for 7af3648c8d98 - got blank aliases working again It's necessary for smartSplit() to return blank values for field=alias combinations. Change-Id: Icb4d55f8544805ac72897a06f624d9e88d1d5aed --- M includes/CargoSQLQuery.php M includes/CargoUtils.php 2 files changed, 8 insertions(+), 3 deletions(-) Approvals: Yaron Koren: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/CargoSQLQuery.php b/includes/CargoSQLQuery.php index 77685f1..3a475bb 100644 --- a/includes/CargoSQLQuery.php +++ b/includes/CargoSQLQuery.php @@ -191,7 +191,7 @@ // displayed. $blankAliasCount = 0; foreach ( $fieldStrings as $i => $fieldString ) { - $fieldStringParts = CargoUtils::smartSplit( '=', $fieldString ); + $fieldStringParts = CargoUtils::smartSplit( '=', $fieldString, true ); if ( count( $fieldStringParts ) == 2 ) { $fieldName = trim( $fieldStringParts[0] ); $alias = trim( $fieldStringParts[1] ); diff --git a/includes/CargoUtils.php b/includes/CargoUtils.php index ca0f294..9561881 100644 --- a/includes/CargoUtils.php +++ b/includes/CargoUtils.php @@ -204,10 +204,11 @@ * lexically. * @param string $delimiter The delimiter to split by. * @param string $string The string to split. -* @return string[] Array of substrings (with no empty values). +* @param boolean $includeBlankValues Whether to include blank values in the returned array. +* @return string[] Array of substrings (with or without blank values). * @throws MWException On unmatched quotes or incomplete escape sequences. */ - static function smartSplit( $delimiter, $string ) { + static function smartSplit( $delimiter, $string, $includeBlankValues = false ) { if ( $string == '' ) { return array(); } @@ -254,6 +255,10 @@ throw new MWException( "Error: incomplete escape sequence." ); } + if ( $includeBlankValues ) { + return $returnValues; + } + // Remove empty strings (but not other quasi-empty values, like '0') and re-key the array. $noEmptyStrings = function($s) { return $s !== ''; -- To view, visit https://gerrit.wikimedia.org/r/401528 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icb4d55f8544805ac72897a06f624d9e88d1d5aed 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]: Fix for 7af3648c8d98 - got blank aliases working again
Yaron Koren has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/401528 ) Change subject: Fix for 7af3648c8d98 - got blank aliases working again .. Fix for 7af3648c8d98 - got blank aliases working again It's necessary for smartSplit() to return blank values for field=alias combinations. Change-Id: Icb4d55f8544805ac72897a06f624d9e88d1d5aed --- M includes/CargoSQLQuery.php M includes/CargoUtils.php 2 files changed, 8 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo refs/changes/28/401528/2 diff --git a/includes/CargoSQLQuery.php b/includes/CargoSQLQuery.php index 77685f1..3a475bb 100644 --- a/includes/CargoSQLQuery.php +++ b/includes/CargoSQLQuery.php @@ -191,7 +191,7 @@ // displayed. $blankAliasCount = 0; foreach ( $fieldStrings as $i => $fieldString ) { - $fieldStringParts = CargoUtils::smartSplit( '=', $fieldString ); + $fieldStringParts = CargoUtils::smartSplit( '=', $fieldString, true ); if ( count( $fieldStringParts ) == 2 ) { $fieldName = trim( $fieldStringParts[0] ); $alias = trim( $fieldStringParts[1] ); diff --git a/includes/CargoUtils.php b/includes/CargoUtils.php index ca0f294..9561881 100644 --- a/includes/CargoUtils.php +++ b/includes/CargoUtils.php @@ -204,10 +204,11 @@ * lexically. * @param string $delimiter The delimiter to split by. * @param string $string The string to split. -* @return string[] Array of substrings (with no empty values). +* @param boolean $includeBlankValues Whether to include blank values in the returned array. +* @return string[] Array of substrings (with or without blank values). * @throws MWException On unmatched quotes or incomplete escape sequences. */ - static function smartSplit( $delimiter, $string ) { + static function smartSplit( $delimiter, $string, $includeBlankValues = false ) { if ( $string == '' ) { return array(); } @@ -254,6 +255,10 @@ throw new MWException( "Error: incomplete escape sequence." ); } + if ( $includeBlankValues ) { + return $returnValues; + } + // Remove empty strings (but not other quasi-empty values, like '0') and re-key the array. $noEmptyStrings = function($s) { return $s !== ''; -- To view, visit https://gerrit.wikimedia.org/r/401528 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icb4d55f8544805ac72897a06f624d9e88d1d5aed 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