Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/177237
Change subject: Use 'property' string constant to avoid dependencies
......................................................................
Use 'property' string constant to avoid dependencies
Change-Id: I1cfe9dce853f6af63c78422b4ac92a39b10479ce
---
M client/includes/WikibaseClient.php
M lib/includes/EntityFactory.php
M lib/includes/serializers/EntitySerializer.php
M lib/includes/store/TermPropertyLabelResolver.php
M lib/includes/store/sql/SqlEntityInfoBuilder.php
M lib/tests/phpunit/Validators/NotEntityIdValidatorTest.php
M lib/tests/phpunit/entity/EntityFactoryTest.php
M lib/tests/phpunit/formatters/EntityIdLinkFormatterTest.php
M lib/tests/phpunit/formatters/EntityIdTitleFormatterTest.php
M lib/tests/phpunit/serializers/SerializerFactoryTest.php
M lib/tests/phpunit/store/MockPropertyInfoStore.php
M lib/tests/phpunit/store/TermPropertyLabelResolverTest.php
M repo/includes/Validators/EntityConstraintProvider.php
M repo/includes/Validators/TermValidatorFactory.php
M repo/includes/WikibaseRepo.php
M repo/tests/phpunit/includes/IO/EntityIdReaderTest.php
M repo/tests/phpunit/includes/LabelDescriptionDuplicateDetectorTest.php
M repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php
18 files changed, 34 insertions(+), 51 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/37/177237/1
diff --git a/client/includes/WikibaseClient.php
b/client/includes/WikibaseClient.php
index d3cb261..6250f26 100644
--- a/client/includes/WikibaseClient.php
+++ b/client/includes/WikibaseClient.php
@@ -31,7 +31,6 @@
use Wikibase\DataModel\Entity\DispatchingEntityIdParser;
use Wikibase\DataModel\Entity\EntityIdParser;
use Wikibase\DataModel\Entity\Item;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\DataModel\Entity\PropertyDataTypeLookup;
use Wikibase\DirectSqlStore;
use Wikibase\EntityFactory;
@@ -584,7 +583,7 @@
public function getEntityFactory() {
$entityClasses = array(
Item::ENTITY_TYPE => 'Wikibase\DataModel\Entity\Item',
- Property::ENTITY_TYPE =>
'Wikibase\DataModel\Entity\Property',
+ 'property' => 'Wikibase\DataModel\Entity\Property',
);
//TODO: provide a hook or registry for adding more.
diff --git a/lib/includes/EntityFactory.php b/lib/includes/EntityFactory.php
index 75e699e..b2b8df1 100644
--- a/lib/includes/EntityFactory.php
+++ b/lib/includes/EntityFactory.php
@@ -6,7 +6,6 @@
use OutOfBoundsException;
use Wikibase\DataModel\Entity\Entity;
use Wikibase\DataModel\Entity\Item;
-use Wikibase\DataModel\Entity\Property;
/**
* Factory for Entity objects.
@@ -50,7 +49,7 @@
if ( $instance === false ) {
$typeToClass = array(
Item::ENTITY_TYPE =>
'Wikibase\DataModel\Entity\Item',
- Property::ENTITY_TYPE =>
'Wikibase\DataModel\Entity\Property',
+ 'property' =>
'Wikibase\DataModel\Entity\Property',
);
$instance = new static( $typeToClass );
diff --git a/lib/includes/serializers/EntitySerializer.php
b/lib/includes/serializers/EntitySerializer.php
index 4d0b9cb..cbb955c 100644
--- a/lib/includes/serializers/EntitySerializer.php
+++ b/lib/includes/serializers/EntitySerializer.php
@@ -7,7 +7,6 @@
use Wikibase\DataModel\Entity\BasicEntityIdParser;
use Wikibase\DataModel\Entity\Entity;
use Wikibase\DataModel\Entity\Item;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\EntityFactory;
/**
@@ -98,7 +97,7 @@
$this->entityFactory = new EntityFactory(
array(
Item::ENTITY_TYPE =>
'Wikibase\DataModel\Entity\Item',
- Property::ENTITY_TYPE =>
'Wikibase\DataModel\Entity\Property',
+ 'property' =>
'Wikibase\DataModel\Entity\Property',
)
);
} else {
diff --git a/lib/includes/store/TermPropertyLabelResolver.php
b/lib/includes/store/TermPropertyLabelResolver.php
index 7530d45..d3fafa4 100644
--- a/lib/includes/store/TermPropertyLabelResolver.php
+++ b/lib/includes/store/TermPropertyLabelResolver.php
@@ -4,7 +4,6 @@
use BagOStuff;
use Wikibase\DataModel\Entity\EntityId;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\DataModel\Entity\PropertyId;
/**
@@ -126,13 +125,13 @@
$termTemplate = new Term( array(
'termType' => 'label',
'termLanguage' => $this->lang,
- 'entityType' => Property::ENTITY_TYPE
+ 'entityType' => 'property',
) );
$terms = $this->termIndex->getMatchingTerms(
array( $termTemplate ),
'label',
- Property::ENTITY_TYPE,
+ 'property',
array(
'caseSensitive' => true,
'prefixSearch' => false,
diff --git a/lib/includes/store/sql/SqlEntityInfoBuilder.php
b/lib/includes/store/sql/SqlEntityInfoBuilder.php
index 8d6c469..a5a8ed6 100644
--- a/lib/includes/store/sql/SqlEntityInfoBuilder.php
+++ b/lib/includes/store/sql/SqlEntityInfoBuilder.php
@@ -10,7 +10,6 @@
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\EntityIdParser;
use Wikibase\DataModel\Entity\EntityIdParsingException;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\DataModel\LegacyIdInterpreter;
use Wikibase\Lib\Store\EntityInfoBuilder;
@@ -455,12 +454,12 @@
wfProfileIn( __METHOD__ );
- if ( empty( $this->numericIdsByType[Property::ENTITY_TYPE] ) ) {
+ if ( empty( $this->numericIdsByType['property'] ) ) {
// there are no Property entities, so there is nothing
to do.
return;
}
- $numericPropertyIds =
$this->numericIdsByType[Property::ENTITY_TYPE];
+ $numericPropertyIds = $this->numericIdsByType['property'];
$dbw = $this->getConnection( DB_SLAVE );
@@ -473,7 +472,7 @@
$this->injectDataTypes( $res );
$this->setDefaultValue( 'datatype', null, function( $entity ) {
- return $entity['type'] === Property::ENTITY_TYPE;
+ return $entity['type'] === 'property';
} );
$this->releaseConnection( $dbw );
diff --git a/lib/tests/phpunit/Validators/NotEntityIdValidatorTest.php
b/lib/tests/phpunit/Validators/NotEntityIdValidatorTest.php
index a91e08d..52808d9 100644
--- a/lib/tests/phpunit/Validators/NotEntityIdValidatorTest.php
+++ b/lib/tests/phpunit/Validators/NotEntityIdValidatorTest.php
@@ -1,8 +1,8 @@
<?php
+
namespace Wikibase\Test\Validators;
use Wikibase\DataModel\Entity\BasicEntityIdParser;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\Validators\NotEntityIdValidator;
/**
@@ -21,8 +21,8 @@
return array(
'empty' => array( '', 'label-no-entityid', null, null ),
'silly' => array( 'silly', 'label-no-entityid', null,
null ),
- 'allowed type' => array( 'Q13', 'label-no-entityid',
array( Property::ENTITY_TYPE ), null ),
- 'forbidden type' => array( 'P13', 'label-no-entityid',
array( Property::ENTITY_TYPE ), 'label-no-entityid' ),
+ 'allowed type' => array( 'Q13', 'label-no-entityid',
array( 'property' ), null ),
+ 'forbidden type' => array( 'P13', 'label-no-entityid',
array( 'property' ), 'label-no-entityid' ),
'all forbidden' => array( 'Q13', 'label-no-entityid',
null, 'label-no-entityid' ),
);
}
diff --git a/lib/tests/phpunit/entity/EntityFactoryTest.php
b/lib/tests/phpunit/entity/EntityFactoryTest.php
index 04401b9..46f5cb3 100644
--- a/lib/tests/phpunit/entity/EntityFactoryTest.php
+++ b/lib/tests/phpunit/entity/EntityFactoryTest.php
@@ -3,7 +3,6 @@
namespace Wikibase\Test;
use Wikibase\DataModel\Entity\Item;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\EntityFactory;
/**
@@ -23,7 +22,7 @@
$this->assertInternalType( 'array', $types );
$this->assertTrue( in_array( Item::ENTITY_TYPE, $types ), "must
contain item type" );
- $this->assertTrue( in_array( Property::ENTITY_TYPE, $types ),
"must contain property type" );
+ $this->assertTrue( in_array( 'property', $types ), "must
contain property type" );
}
public static function provideIsEntityType() {
@@ -50,7 +49,7 @@
public static function provideNewEmpty() {
return array(
array( Item::ENTITY_TYPE,
'Wikibase\DataModel\Entity\Item' ),
- array( Property::ENTITY_TYPE,
'Wikibase\DataModel\Entity\Property' ),
+ array( 'property', 'Wikibase\DataModel\Entity\Property'
),
);
}
diff --git a/lib/tests/phpunit/formatters/EntityIdLinkFormatterTest.php
b/lib/tests/phpunit/formatters/EntityIdLinkFormatterTest.php
index 357c914..e89d702 100644
--- a/lib/tests/phpunit/formatters/EntityIdLinkFormatterTest.php
+++ b/lib/tests/phpunit/formatters/EntityIdLinkFormatterTest.php
@@ -9,7 +9,6 @@
use Wikibase\DataModel\Entity\EntityIdValue;
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\ItemId;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\Lib\EntityIdLinkFormatter;
@@ -62,7 +61,7 @@
switch ( $entityId->getEntityType() ) {
case Item::ENTITY_TYPE:
return Title::makeTitle( NS_MAIN, 'ITEM-TEST--'
. $entityId->getSerialization() );
- case Property::ENTITY_TYPE:
+ case 'property':
return Title::makeTitle( NS_MAIN,
'PROPERTY-TEST--' . $entityId->getSerialization() );
default:
throw new LogicException( "oops!" );
diff --git a/lib/tests/phpunit/formatters/EntityIdTitleFormatterTest.php
b/lib/tests/phpunit/formatters/EntityIdTitleFormatterTest.php
index 6b14262..0d07a2b 100644
--- a/lib/tests/phpunit/formatters/EntityIdTitleFormatterTest.php
+++ b/lib/tests/phpunit/formatters/EntityIdTitleFormatterTest.php
@@ -9,7 +9,6 @@
use Wikibase\DataModel\Entity\EntityIdValue;
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\ItemId;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\Lib\EntityIdTitleFormatter;
@@ -62,7 +61,7 @@
switch ( $entityId->getEntityType() ) {
case Item::ENTITY_TYPE:
return Title::makeTitle( NS_MAIN, 'ITEM-TEST--'
. $entityId->getSerialization() );
- case Property::ENTITY_TYPE:
+ case 'property':
return Title::makeTitle( NS_MAIN,
'PROPERTY-TEST--' . $entityId->getSerialization() );
default:
throw new LogicException( "oops!" );
diff --git a/lib/tests/phpunit/serializers/SerializerFactoryTest.php
b/lib/tests/phpunit/serializers/SerializerFactoryTest.php
index 60b985a..43d49ba 100644
--- a/lib/tests/phpunit/serializers/SerializerFactoryTest.php
+++ b/lib/tests/phpunit/serializers/SerializerFactoryTest.php
@@ -4,7 +4,6 @@
use Wikibase\DataModel\Claim\Claim;
use Wikibase\DataModel\Entity\Item;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\DataModel\Reference;
use Wikibase\DataModel\Snak\PropertyNoValueSnak;
use Wikibase\Lib\Serializers\SerializationOptions;
@@ -85,7 +84,7 @@
public function entityTypeProvider() {
return array(
array( Item::ENTITY_TYPE ),
- array( Property::ENTITY_TYPE ),
+ array( 'property' ),
);
}
diff --git a/lib/tests/phpunit/store/MockPropertyInfoStore.php
b/lib/tests/phpunit/store/MockPropertyInfoStore.php
index 18d59bb..7abfefa 100644
--- a/lib/tests/phpunit/store/MockPropertyInfoStore.php
+++ b/lib/tests/phpunit/store/MockPropertyInfoStore.php
@@ -3,7 +3,6 @@
namespace Wikibase\Test;
use InvalidArgumentException;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\PropertyInfoStore;
@@ -33,7 +32,7 @@
* @throws InvalidArgumentException
*/
public function getPropertyInfo( PropertyId $propertyId ) {
- if ( $propertyId->getEntityType() !== Property::ENTITY_TYPE ) {
+ if ( $propertyId->getEntityType() !== 'property' ) {
throw new InvalidArgumentException( 'Property ID
expected! ' . $propertyId );
}
diff --git a/lib/tests/phpunit/store/TermPropertyLabelResolverTest.php
b/lib/tests/phpunit/store/TermPropertyLabelResolverTest.php
index 74e5304..46aceb5 100644
--- a/lib/tests/phpunit/store/TermPropertyLabelResolverTest.php
+++ b/lib/tests/phpunit/store/TermPropertyLabelResolverTest.php
@@ -4,7 +4,6 @@
use HashBagOStuff;
use Wikibase\DataModel\Entity\Item;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\PropertyLabelResolver;
use Wikibase\Term;
@@ -62,28 +61,28 @@
'termType' => 'label',
'termLanguage' => 'de',
'entityId' => 1,
- 'entityType' => Property::ENTITY_TYPE,
+ 'entityType' => 'property',
'termText' => 'Eins',
) ),
new Term( array(
'termType' => 'label',
'termLanguage' => 'de',
'entityId' => 2,
- 'entityType' => Property::ENTITY_TYPE,
+ 'entityType' => 'property',
'termText' => 'Zwei',
) ),
new Term( array(
'termType' => 'label',
'termLanguage' => 'de',
'entityId' => 3,
- 'entityType' => Property::ENTITY_TYPE,
+ 'entityType' => 'property',
'termText' => 'Drei',
) ),
new Term( array(
'termType' => 'label',
'termLanguage' => 'de',
'entityId' => 4,
- 'entityType' => Property::ENTITY_TYPE,
+ 'entityType' => 'property',
'termText' => 'vier', // lower case
) ),
@@ -92,7 +91,7 @@
'termType' => 'label',
'termLanguage' => 'en',
'entityId' => 1,
- 'entityType' => Property::ENTITY_TYPE,
+ 'entityType' => 'property',
'termText' => 'One',
) ),
new Term( array(
@@ -106,14 +105,14 @@
'termType' => 'alias', // not a label
'termLanguage' => 'en',
'entityId' => 3,
- 'entityType' => Property::ENTITY_TYPE,
+ 'entityType' => 'property',
'termText' => 'Three',
) ),
new Term( array(
'termType' => 'description', // not a label
'termLanguage' => 'en',
'entityId' => 4,
- 'entityType' => Property::ENTITY_TYPE,
+ 'entityType' => 'property',
'termText' => 'Four',
) ),
);
diff --git a/repo/includes/Validators/EntityConstraintProvider.php
b/repo/includes/Validators/EntityConstraintProvider.php
index 4df1851..49bbc30 100644
--- a/repo/includes/Validators/EntityConstraintProvider.php
+++ b/repo/includes/Validators/EntityConstraintProvider.php
@@ -3,7 +3,6 @@
namespace Wikibase\Validators;
use Wikibase\DataModel\Entity\Item;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\LabelDescriptionDuplicateDetector;
use Wikibase\Lib\Store\SiteLinkLookup;
@@ -54,7 +53,7 @@
$validators = array();
switch ( $entityType ) {
- case Property::ENTITY_TYPE:
+ case 'property':
$validators[] = new LabelUniquenessValidator(
$this->duplicateDetector );
break;
@@ -83,7 +82,7 @@
$validators = $this->getUpdateValidators( $entityType );
switch ( $entityType ) {
- case Property::ENTITY_TYPE:
+ case 'property':
break;
case Item::ENTITY_TYPE:
diff --git a/repo/includes/Validators/TermValidatorFactory.php
b/repo/includes/Validators/TermValidatorFactory.php
index 7048375..414370d 100644
--- a/repo/includes/Validators/TermValidatorFactory.php
+++ b/repo/includes/Validators/TermValidatorFactory.php
@@ -6,7 +6,6 @@
use ValueValidators\ValueValidator;
use Wikibase\DataModel\Entity\EntityIdParser;
use Wikibase\DataModel\Entity\Item;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\LabelDescriptionDuplicateDetector;
use Wikibase\Lib\Store\SiteLinkLookup;
@@ -105,8 +104,8 @@
$validators = $this->getCommonTermValidators();
//TODO: Make this configurable. Use a builder. Allow more types
to register.
- if ( $entityType === Property::ENTITY_TYPE ) {
- $validators[] = new NotEntityIdValidator(
$this->idParser, 'label-no-entityid', array( Property::ENTITY_TYPE ) );
+ if ( $entityType === 'property' ) {
+ $validators[] = new NotEntityIdValidator(
$this->idParser, 'label-no-entityid', array( 'property' ) );
}
return new CompositeValidator( $validators, true );
diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php
index d155e75..4f6b3fa 100644
--- a/repo/includes/WikibaseRepo.php
+++ b/repo/includes/WikibaseRepo.php
@@ -21,7 +21,6 @@
use Wikibase\DataModel\Entity\DispatchingEntityIdParser;
use Wikibase\DataModel\Entity\EntityIdParser;
use Wikibase\DataModel\Entity\Item;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\DataModel\Entity\PropertyDataTypeLookup;
use Wikibase\EntityFactory;
use Wikibase\EntityParserOutputGeneratorFactory;
@@ -771,7 +770,7 @@
// @TODO: We should have smth. like this for namespaces too
$map = array(
Item::ENTITY_TYPE => CONTENT_MODEL_WIKIBASE_ITEM,
- Property::ENTITY_TYPE => CONTENT_MODEL_WIKIBASE_PROPERTY
+ 'property' => CONTENT_MODEL_WIKIBASE_PROPERTY
);
wfRunHooks( 'WikibaseContentModelMapping', array( &$map ) );
@@ -785,7 +784,7 @@
public function getEntityFactory() {
$entityClasses = array(
Item::ENTITY_TYPE => 'Wikibase\DataModel\Entity\Item',
- Property::ENTITY_TYPE =>
'Wikibase\DataModel\Entity\Property',
+ 'property' => 'Wikibase\DataModel\Entity\Property',
);
//TODO: provide a hook or registry for adding more.
diff --git a/repo/tests/phpunit/includes/IO/EntityIdReaderTest.php
b/repo/tests/phpunit/includes/IO/EntityIdReaderTest.php
index a70ad23..0f5b08a 100644
--- a/repo/tests/phpunit/includes/IO/EntityIdReaderTest.php
+++ b/repo/tests/phpunit/includes/IO/EntityIdReaderTest.php
@@ -6,7 +6,6 @@
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\ItemId;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\Repo\IO\EntityIdReader;
use Wikibase\Repo\IO\LineReader;
@@ -73,7 +72,7 @@
'EntityIdReaderTest.txt', null, 100, array(
$q1, $p2, $q3, $p4 )
),
'just properties' => array(
- 'EntityIdReaderTest.txt',
Property::ENTITY_TYPE, 100, array( $p2, $p4 )
+ 'EntityIdReaderTest.txt', 'property', 100,
array( $p2, $p4 )
),
'limit' => array(
'EntityIdReaderTest.txt', null, 2, array( $q1,
$p2 )
diff --git
a/repo/tests/phpunit/includes/LabelDescriptionDuplicateDetectorTest.php
b/repo/tests/phpunit/includes/LabelDescriptionDuplicateDetectorTest.php
index 408ba29..397ec33 100644
--- a/repo/tests/phpunit/includes/LabelDescriptionDuplicateDetectorTest.php
+++ b/repo/tests/phpunit/includes/LabelDescriptionDuplicateDetectorTest.php
@@ -6,7 +6,6 @@
use ValueValidators\Result;
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\ItemId;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\LabelDescriptionDuplicateDetector;
use Wikibase\Term;
use Wikibase\Validators\UniquenessViolation;
@@ -45,7 +44,7 @@
'termType' => Term::TYPE_LABEL,
'termLanguage' => 'en',
'entityId' => 17,
- 'entityType' => Property::ENTITY_TYPE,
+ 'entityType' => 'property',
'termText' => 'property label',
) );
@@ -98,7 +97,7 @@
'other entity type' => array(
$world,
- Property::ENTITY_TYPE,
+ 'property',
array( 'en' => 'item label' ),
null,
null,
diff --git
a/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php
b/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php
index 832f532..ca222df 100644
--- a/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php
+++ b/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php
@@ -5,7 +5,6 @@
use Wikibase\DataModel\Entity\BasicEntityIdParser;
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\ItemId;
-use Wikibase\DataModel\Entity\Property;
use Wikibase\DataModel\Term\AliasGroupList;
use Wikibase\DataModel\Term\Fingerprint;
use Wikibase\DataModel\Term\Term;
@@ -100,7 +99,7 @@
public function testGetLabelValidator_property() {
$builders = $this->newFactory( 8, array( 'en' ) );
- $validator = $builders->getLabelValidator(
Property::ENTITY_TYPE );
+ $validator = $builders->getLabelValidator( 'property' );
$this->assertInstanceOf( 'ValueValidators\ValueValidator',
$validator );
--
To view, visit https://gerrit.wikimedia.org/r/177237
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1cfe9dce853f6af63c78422b4ac92a39b10479ce
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