Thiemo Mättig (WMDE) has uploaded a new change for review.

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

Change subject: LegacyIdInterpreter::newIdFromTypeAndNumber is static
......................................................................

LegacyIdInterpreter::newIdFromTypeAndNumber is static

Change-Id: I86e78d07f917f91642a9b65f0a3f3f1dfa8aa31c
---
M lib/includes/Term.php
M lib/includes/store/sql/SqlEntityInfoBuilder.php
M lib/includes/store/sql/TermSqlIndex.php
M repo/includes/store/sql/EntityPerPageTable.php
4 files changed, 12 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/09/149309/1

diff --git a/lib/includes/Term.php b/lib/includes/Term.php
index 2f79c7e..3939407 100644
--- a/lib/includes/Term.php
+++ b/lib/includes/Term.php
@@ -184,9 +184,11 @@
        }
 
        /**
+        * @see TermSqlIndex::getMatchingIDs
+        *
         * @since 0.2
+        *
         * @return EntityId|null
-        * @see \Wikibase\TermSqlIndex::getMatchingIDs
         */
        public function getEntityId() {
                $entityType = $this->getEntityType();
@@ -195,8 +197,7 @@
                        $numericId = $this->fields['entityId'];
 
                        // FIXME: this only works for items and properties
-                       $idParser = new LegacyIdInterpreter();
-                       return $idParser->newIdFromTypeAndNumber( $entityType, 
$numericId );
+                       return LegacyIdInterpreter::newIdFromTypeAndNumber( 
$entityType, $numericId );
                }
 
                return null;
diff --git a/lib/includes/store/sql/SqlEntityInfoBuilder.php 
b/lib/includes/store/sql/SqlEntityInfoBuilder.php
index 4c9b2bd..98ef85d 100644
--- a/lib/includes/store/sql/SqlEntityInfoBuilder.php
+++ b/lib/includes/store/sql/SqlEntityInfoBuilder.php
@@ -384,12 +384,10 @@
         * @throws InvalidArgumentException
         */
        private function injectTerms( ResultWrapper $dbResult ) {
-               $idParser = new LegacyIdInterpreter();
-
                foreach ( $dbResult as $row ) {
                        // FIXME: this only works for items and properties
-                       $id = $idParser->newIdFromTypeAndNumber( 
$row->term_entity_type, (int)$row->term_entity_id );
-                       $key = $id->getSerialization();
+                       $entityId = 
LegacyIdInterpreter::newIdFromTypeAndNumber( $row->term_entity_type, 
(int)$row->term_entity_id );
+                       $key = $entityId->getSerialization();
 
                        if ( !isset( $this->entityInfo[$key] ) ) {
                                continue;
diff --git a/lib/includes/store/sql/TermSqlIndex.php 
b/lib/includes/store/sql/TermSqlIndex.php
index d72848e..6a7a137 100644
--- a/lib/includes/store/sql/TermSqlIndex.php
+++ b/lib/includes/store/sql/TermSqlIndex.php
@@ -571,13 +571,10 @@
 
                $this->releaseConnection( $db );
 
-               $idParser = new LegacyIdInterpreter();
-
                $entityIds = array_map(
-                       function( $entity ) use ( $idParser ) {
+                       function( $entity ) {
                                // FIXME: this only works for items and 
properties
-                               $entityId = $idParser->newIdFromTypeAndNumber( 
$entity->term_entity_type, (int)$entity->term_entity_id );
-                               return $entityId;
+                               return 
LegacyIdInterpreter::newIdFromTypeAndNumber( $entity->term_entity_type, 
(int)$entity->term_entity_id );
                        },
                        iterator_to_array( $entities )
                );
@@ -720,11 +717,10 @@
 
                // turn numbers into entity ids
                $result = array();
-               $idParser = new LegacyIdInterpreter();
 
                foreach ( $numericIds as $numericId ) {
                        // FIXME: this only works for items and properties
-                       $result[] = $idParser->newIdFromTypeAndNumber( 
$entityType, $numericId );
+                       $result[] = 
LegacyIdInterpreter::newIdFromTypeAndNumber( $entityType, $numericId );
                }
 
                wfProfileOut( __METHOD__ );
@@ -1075,4 +1071,5 @@
        public function supportsWeight() {
                return !Settings::get( 'withoutTermWeight' );
        }
+
 }
diff --git a/repo/includes/store/sql/EntityPerPageTable.php 
b/repo/includes/store/sql/EntityPerPageTable.php
index 7550f81..99e5758 100644
--- a/repo/includes/store/sql/EntityPerPageTable.php
+++ b/repo/includes/store/sql/EntityPerPageTable.php
@@ -253,14 +253,12 @@
                return $this->getEntityIdsFromRows( $rows );
        }
 
-       protected function getEntityIdsFromRows( $rows ) {
+       protected function getEntityIdsFromRows( array $rows ) {
                $entities = array();
-
-               $legacyIdParser = new LegacyIdInterpreter();
 
                foreach ( $rows as $row ) {
                        // FIXME: this only works for items and properties
-                       $entities[] = $legacyIdParser->newIdFromTypeAndNumber( 
$row->entity_type, (int)$row->entity_id );
+                       $entities[] = 
LegacyIdInterpreter::newIdFromTypeAndNumber( $row->entity_type, 
(int)$row->entity_id );
                }
 
                return $entities;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I86e78d07f917f91642a9b65f0a3f3f1dfa8aa31c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

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

Reply via email to