Namit has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/195036

Change subject: Changed handling of blank aliases in Cargo queries
......................................................................

Changed handling of blank aliases in Cargo queries

Blank aliases are assigned internal aliases of the form
"Blank value X", where X is different for each blank alias.
The alias is mapped back to blank before being displayed.

Bug: T91222
Change-Id: I32c92d3167d8bb9647c7a0ec32acdeb4df2a7c09
---
M CargoSQLQuery.php
M formats/CargoListFormat.php
2 files changed, 11 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/36/195036/1

diff --git a/CargoSQLQuery.php b/CargoSQLQuery.php
index 0dae5e5..07aeeb2 100644
--- a/CargoSQLQuery.php
+++ b/CargoSQLQuery.php
@@ -127,7 +127,7 @@
                                . "please use \"group by=\" instead." );
                        }
                }
-
+               $count_blank_alias = 0;
                foreach ( $fieldNames as $i => $fieldName ) {
                        $fieldNameParts = CargoUtils::smartSplit( '=', 
$fieldName );
                        if ( count( $fieldNameParts ) == 2 ) {
@@ -149,8 +149,13 @@
                                        $alias = $realFieldName;
                                }
                        }
+                       if ( empty( $alias ) ) {
+                               $count_blank_alias++;
+                               $alias = "Blank value $count_blank_alias";
+                       }
                        $this->mAliasedFieldNames[$alias] = $fieldName;
                }
+               unset( $count_blank_alias );
        }
 
        /**
diff --git a/formats/CargoListFormat.php b/formats/CargoListFormat.php
index 0c634d0..453dc24 100644
--- a/formats/CargoListFormat.php
+++ b/formats/CargoListFormat.php
@@ -43,7 +43,11 @@
                                } else {
                                        $text .= ', ';
                                }
-                               $text .= "<span 
class=\"cargoFieldName\">$fieldName:</span> $fieldValue";
+                               if ( empty( $fieldName ) || substr_count( 
$fieldName, 'Blank value ' ) == 1 ) {
+                                       $text .= $fieldValue;
+                               } else {
+                                       $text .= "<span 
class=\"cargoFieldName\">$fieldName:</span> $fieldValue";
+                               }
                        }
                }
                if ( $startParenthesisAdded ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/195036
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I32c92d3167d8bb9647c7a0ec32acdeb4df2a7c09
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Namit <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to