jenkins-bot has submitted this change and it was merged.
Change subject: Remove termWeight field from TermIndexEntry
......................................................................
Remove termWeight field from TermIndexEntry
This patch does *not* drop the term_weight field from the terms table.
But the field is not exposed any more via the TermIndexEntry class.
This makes the field a private implementation detail of TermSqlIndex.
The weight is still calculated, stored and used for ordering, but not
exposed any more. It was not used anyway outside of TermSqlIndex.
Change-Id: I25cf98c4dc72c52aae5bd5545066a2f577b4fb2c
---
M lib/includes/Store/Sql/TermSqlIndex.php
M lib/includes/Store/TermIndex.php
M lib/includes/TermIndexEntry.php
M lib/tests/phpunit/TermIndexEntryTest.php
4 files changed, 4 insertions(+), 41 deletions(-)
Approvals:
Hoo man: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/includes/Store/Sql/TermSqlIndex.php
b/lib/includes/Store/Sql/TermSqlIndex.php
index 42c6a25..e850bef 100644
--- a/lib/includes/Store/Sql/TermSqlIndex.php
+++ b/lib/includes/Store/Sql/TermSqlIndex.php
@@ -57,7 +57,6 @@
'term_type' => 'termType',
'term_language' => 'termLanguage',
'term_text' => 'termText',
- 'term_weight' => 'termWeight',
'term_entity_id' => 'entityId',
);
@@ -540,7 +539,7 @@
$rows = $dbr->select(
$this->tableName,
- array_keys( $this->termFieldMap ),
+ array_keys( $this->termFieldMap + [ 'term_weight' =>
null ] ),
array( $dbr->makeList( $termConditions, LIST_OR ) ),
__METHOD__,
$queryOptions
@@ -766,8 +765,6 @@
if ( $key === 'term_entity_id' ) {
$value = (int)$value;
- } elseif ( $key === 'term_weight' ) {
- $value = (float)$value;
}
$matchingTerm[$this->termFieldMap[$key]] =
$value;
diff --git a/lib/includes/Store/TermIndex.php b/lib/includes/Store/TermIndex.php
index 13161ea..26c45ef 100644
--- a/lib/includes/Store/TermIndex.php
+++ b/lib/includes/Store/TermIndex.php
@@ -87,7 +87,7 @@
* method parameters.
*
* The return value is an array of Terms where entityId, entityType,
- * termType, termLanguage, termText, termWeight are all set.
+ * termType, termLanguage, termText are all set.
*
* @since 0.2
*
@@ -121,7 +121,7 @@
* method parameters.
*
* The return value is an array of Terms where entityId, entityType,
- * termType, termLanguage, termText, termWeight are all set.
+ * termType, termLanguage, termText are all set.
*
* @since 0.5
*
diff --git a/lib/includes/TermIndexEntry.php b/lib/includes/TermIndexEntry.php
index 1c9677d..50ab944 100644
--- a/lib/includes/TermIndexEntry.php
+++ b/lib/includes/TermIndexEntry.php
@@ -42,7 +42,6 @@
'termType',
'termLanguage',
'termText',
- 'termWeight',
);
/**
@@ -69,9 +68,6 @@
break;
case 'termText':
$this->setText( $value );
- break;
- case 'termWeight':
- $this->setWeight( $value );
break;
default:
throw new MWException( 'Invalid term
field provided' );
@@ -152,30 +148,6 @@
}
/**
- * @since 0.5
- *
- * @param float $weight
- *
- * @throws MWException
- */
- public function setWeight( $weight ) {
- if ( !is_float( $weight ) ) {
- throw new MWException( 'Term weight code can only be a
float' );
- }
-
- $this->fields['termWeight'] = $weight;
- }
-
- /**
- * @since 0.5
- *
- * @return float|null
- */
- public function getWeight() {
- return array_key_exists( 'termWeight', $this->fields ) ?
$this->fields['termWeight'] : null;
- }
-
- /**
* @param string $entityType
*
* @throws MWException
@@ -251,7 +223,6 @@
/**
* Imposes an canonical but arbitrary order on Term objects.
* Useful for sorting lists of terms for comparison.
- * This comparison DOES NOT use termWeight
*
* @param self $a
* @param self $b
@@ -259,10 +230,7 @@
* @return int Returns 1 if $a is greater than $b, -1 if $b is greater
than $a, and 0 otherwise.
*/
public static function compare( self $a, self $b ) {
- $fieldNames = self::$fieldNames;
- unset( $fieldNames[array_search( 'termWeight', $fieldNames )] );
-
- foreach ( $fieldNames as $n ) {
+ foreach ( self::$fieldNames as $n ) {
$exists = array_key_exists( $n, $a->fields );
if ( $exists !== array_key_exists( $n, $b->fields ) ) {
diff --git a/lib/tests/phpunit/TermIndexEntryTest.php
b/lib/tests/phpunit/TermIndexEntryTest.php
index 4bc139f..abe51e9 100644
--- a/lib/tests/phpunit/TermIndexEntryTest.php
+++ b/lib/tests/phpunit/TermIndexEntryTest.php
@@ -29,7 +29,6 @@
'termType' =>
TermIndexEntry::TYPE_LABEL,
'termLanguage' => 'en',
'termText' => 'foo',
- 'termWeight' => 1.234,
]
],
[
@@ -65,7 +64,6 @@
$this->assertEquals( isset( $fields['termType'] ) ?
$fields['termType'] : null, $term->getType() );
$this->assertEquals( isset( $fields['termLanguage'] ) ?
$fields['termLanguage'] : null, $term->getLanguage() );
$this->assertEquals( isset( $fields['termText'] ) ?
$fields['termText'] : null, $term->getText() );
- $this->assertEquals( isset( $fields['termWeight'] ) ?
$fields['termWeight'] : null, $term->getWeight() );
}
public function testClone() {
--
To view, visit https://gerrit.wikimedia.org/r/322856
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I25cf98c4dc72c52aae5bd5545066a2f577b4fb2c
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: WMDE-leszek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits