[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Fixed : Populate hierarchy fields in Cargo Tables
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/360916 ) Change subject: Fixed : Populate hierarchy fields in Cargo Tables .. Fixed : Populate hierarchy fields in Cargo Tables Hierarchy fields were not being populated. This patch fixes the above issue. Change-Id: I958d9c246d621b484f5acee3d6271a8ef4d3b86a --- M CargoFieldDescription.php M CargoUtils.php 2 files changed, 22 insertions(+), 6 deletions(-) Approvals: Yaron Koren: Looks good to me, approved jenkins-bot: Verified diff --git a/CargoFieldDescription.php b/CargoFieldDescription.php index 727136c..8c22c58 100644 --- a/CargoFieldDescription.php +++ b/CargoFieldDescription.php @@ -15,6 +15,7 @@ public $mAllowedValues = null; public $mIsHidden = false; public $mIsHierarchy = false; + public $mHierarchyStructure = null; public $mOtherParams = array(); /** @@ -68,12 +69,25 @@ // already used to separate // "extra parameters", so just // hardcode it to a semicolon. + if( $fieldDescription->mIsHierarchy == true ) { + // $paramValue contains "*" hierarchy structure + $fieldDescription->mHierarchyStructure = trim( $paramValue ); + // now make the allowed values param similar to the syntax + // used by other fields + $hierarchyNodesArray = explode( "\n", $paramValue ); + $allowedValuesArray = array(); + foreach ( $hierarchyNodesArray as $node ) { + // Remove prefix of multiple "*" + $allowedValuesArray[] = preg_replace( '/^[*]*/', '', $node ); + } + $paramValue = implode( ',', $allowedValuesArray ); + } $delimiter = ','; $allowedValuesStr = str_replace( "\\$delimiter", "\a", $paramValue ); $allowedValuesArray = explode( $delimiter, $allowedValuesStr ); foreach ( $allowedValuesArray as $i => $value ) { if ( $value == '' ) continue; - // Replace beep back with comma, trim. + // Replace beep back with delimiter, trim. $value = str_replace( "\a", $delimiter, trim( $value ) ); $fieldDescription->mAllowedValues[] = $value; } @@ -114,6 +128,8 @@ $fieldDescription->mIsHidden = true; } elseif ( $param == 'hierarchy' ) { $fieldDescription->mIsHierarchy = true; + } elseif ( $param == 'hierarchyStructure' ) { + $fieldDescription->mHierarchyStructure = $value; } } return $fieldDescription; @@ -152,6 +168,7 @@ } if ( $this->mIsHierarchy ) { $descriptionData['hierarchy'] = true; + $descriptionData['hierarchyStructure'] = $this->mHierarchyStructure; } foreach ( $this->mOtherParams as $otherParam => $value ) { $descriptionData[$otherParam] = $value; diff --git a/CargoUtils.php b/CargoUtils.php index eeb860b..50ecac6 100644 --- a/CargoUtils.php +++ b/CargoUtils.php @@ -730,11 +730,10 @@ $createIndexSQL .= $cdb->addIdentifierQuotes( '_right' ) . ')'; $cdb->query( $createIndexSQL ); $fieldTableNames[] = $fieldTableName; - //Insert Hierarchy Structure - $allowedValuesWikitext = $fieldDescription->mAllowedValues[0]; - $hierarchyTree = CargoHierarchy::newFromWikiText( $allowedValuesWikitext ); - $hierarchyStructureData =
[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Fixed : Populate hierarchy fields in Cargo Tables
Fz-29 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/360916 ) Change subject: Fixed : Populate hierarchy fields in Cargo Tables .. Fixed : Populate hierarchy fields in Cargo Tables Hierarchy fields were not being populated. This patch fixes the above issue. Change-Id: I958d9c246d621b484f5acee3d6271a8ef4d3b86a --- M CargoFieldDescription.php M CargoUtils.php 2 files changed, 23 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo refs/changes/16/360916/1 diff --git a/CargoFieldDescription.php b/CargoFieldDescription.php index 727136c..296904e 100644 --- a/CargoFieldDescription.php +++ b/CargoFieldDescription.php @@ -15,6 +15,7 @@ public $mAllowedValues = null; public $mIsHidden = false; public $mIsHierarchy = false; + public $mHierarchyStructure = null; public $mOtherParams = array(); /** @@ -68,12 +69,29 @@ // already used to separate // "extra parameters", so just // hardcode it to a semicolon. + if( $fieldDescription->mIsHierarchy == true ) { + // $paramValue contains "*" hierarchy structure + $fieldDescription->mHierarchyStructure = trim( $paramValue ); + // now make the allowed values param similar to the syntax + // used by other fields + $hierarchyNodesArray = explode( "\n", $paramValue ); + $allowedValuesArray = array(); + foreach ( $hierarchyNodesArray as $node ) { + $node = trim( $node ); + // Remove prefix of multiple "*" + $node = preg_replace( '/^[*]*/', '', $node ); + $node = trim( $node ); + + $allowedValuesArray[] = $node; + } + $paramValue = implode( ',', $allowedValuesArray ); + } $delimiter = ','; $allowedValuesStr = str_replace( "\\$delimiter", "\a", $paramValue ); $allowedValuesArray = explode( $delimiter, $allowedValuesStr ); foreach ( $allowedValuesArray as $i => $value ) { if ( $value == '' ) continue; - // Replace beep back with comma, trim. + // Replace beep back with delimiter, trim. $value = str_replace( "\a", $delimiter, trim( $value ) ); $fieldDescription->mAllowedValues[] = $value; } @@ -114,6 +132,8 @@ $fieldDescription->mIsHidden = true; } elseif ( $param == 'hierarchy' ) { $fieldDescription->mIsHierarchy = true; + } elseif ( $param == 'hierarchyStructure' ) { + $fieldDescription->mHierarchyStructure = $value; } } return $fieldDescription; @@ -152,6 +172,7 @@ } if ( $this->mIsHierarchy ) { $descriptionData['hierarchy'] = true; + $descriptionData['hierarchyStructure'] = $this->mHierarchyStructure; } foreach ( $this->mOtherParams as $otherParam => $value ) { $descriptionData[$otherParam] = $value; diff --git a/CargoUtils.php b/CargoUtils.php index eeb860b..2feb712 100644 --- a/CargoUtils.php +++ b/CargoUtils.php @@ -731,7 +731,7 @@ $cdb->query( $createIndexSQL ); $fieldTableNames[] = $fieldTableName; //Insert Hierarchy Structure - $allowedValuesWikitext = $fieldDescription->mAllowedValues[0]; +