Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/188358
Change subject: Use proper EntityFactory methods
......................................................................
Use proper EntityFactory methods
Change-Id: I673c4d1f72848987748a2006b136812a85597e0c
---
M lib/includes/serializers/EntitySerializer.php
M repo/includes/specials/SpecialEntitiesWithoutPage.php
2 files changed, 5 insertions(+), 13 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/58/188358/1
diff --git a/lib/includes/serializers/EntitySerializer.php
b/lib/includes/serializers/EntitySerializer.php
index 4d0b9cb..8c71443 100644
--- a/lib/includes/serializers/EntitySerializer.php
+++ b/lib/includes/serializers/EntitySerializer.php
@@ -190,9 +190,9 @@
* @throws InvalidArgumentException
*/
public function newFromSerialization( array $data ) {
- $validTypes = $this->entityFactory->getEntityTypes();
-
- if ( !array_key_exists( 'type', $data ) || !in_array(
$data['type'], $validTypes ) ) {
+ if ( !array_key_exists( 'type', $data )
+ || !$this->entityFactory->isEntityType( $data['type'] )
+ ) {
throw new InvalidArgumentException( 'Invalid entity
serialization' );
}
diff --git a/repo/includes/specials/SpecialEntitiesWithoutPage.php
b/repo/includes/specials/SpecialEntitiesWithoutPage.php
index bdd7c97..41bfc11 100644
--- a/repo/includes/specials/SpecialEntitiesWithoutPage.php
+++ b/repo/includes/specials/SpecialEntitiesWithoutPage.php
@@ -34,13 +34,6 @@
private $type = null;
/**
- * Map entity types to objects representing the corresponding entity
- *
- * @var array
- */
- private $possibleTypes;
-
- /**
* @var string
*/
private $termType;
@@ -114,11 +107,10 @@
}
$this->type = $request->getText( 'type', $this->type );
- $this->possibleTypes = $this->entityFactory->getEntityTypes();
if ( $this->type === '' ) {
$this->type = null;
}
- if ( $this->type !== null && !in_array( $this->type,
$this->possibleTypes ) ) {
+ if ( $this->type !== null &&
!$this->entityFactory->isEntityType( $this->type ) ) {
$this->showErrorHTML( $this->msg(
'wikibase-entitieswithoutlabel-invalid-type', $this->type )->parse() );
$this->type = null;
}
@@ -130,7 +122,7 @@
private function setForm() {
$typeSelect = new XmlSelect( 'type',
'wb-entitieswithoutpage-type', $this->type );
$typeSelect->addOption( $this->msg(
'wikibase-entitieswithoutlabel-label-alltypes' )->text(), '' );
- foreach( $this->possibleTypes as $type ) {
+ foreach ( $this->entityFactory->getEntityTypes() as $type ) {
// Messages: wikibase-entity-item,
wikibase-entity-property, wikibase-entity-query
$typeSelect->addOption( $this->msg( 'wikibase-entity-'
. $type )->text(), $type );
}
--
To view, visit https://gerrit.wikimedia.org/r/188358
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I673c4d1f72848987748a2006b136812a85597e0c
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