Mwjames has uploaded a new change for review.
https://gerrit.wikimedia.org/r/96886
Change subject: Follow-up to use DataTypeRegistry in core
......................................................................
Follow-up to use DataTypeRegistry in core
Change-Id: Ib64cb57e07650e3d249356cc59ca18af8c390c36
---
M includes/ContentProcessor.php
M includes/datavalues/SMW_DV_Types.php
M includes/export/SMW_Exporter.php
M includes/hooks/SpecialStatsAddExtra.php
M includes/parserhooks/SetParserFunction.php
M includes/parserhooks/SubobjectParserFunction.php
M includes/serializer/Deserializers/SemanticDataDeserializer.php
M includes/specials/SMW_SpecialTypes.php
M includes/storage/SMW_SparqlStoreQueryEngine.php
M includes/storage/SQLStore/PropertyTableDefinitionBuilder.php
M includes/storage/SQLStore/SMW_SQLStore3.php
M includes/storage/SQLStore/SMW_SQLStore3_Queries.php
M includes/storage/SQLStore/SMW_SQLStore3_Readers.php
M includes/storage/SQLStore/SMW_Sql3StubSemanticData.php
14 files changed, 44 insertions(+), 54 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki
refs/changes/86/96886/1
diff --git a/includes/ContentProcessor.php b/includes/ContentProcessor.php
index d966594..3e374bf 100644
--- a/includes/ContentProcessor.php
+++ b/includes/ContentProcessor.php
@@ -277,7 +277,7 @@
// Add properties to the semantic container
foreach ( $properties as $property ) {
- $dataValue = DataValueFactory::newPropertyValue(
+ $dataValue =
DataValueFactory::getInstance()->newPropertyValue(
$property,
$value,
$valueCaption,
diff --git a/includes/datavalues/SMW_DV_Types.php
b/includes/datavalues/SMW_DV_Types.php
index 2ddaf31..1d8d26e 100644
--- a/includes/datavalues/SMW_DV_Types.php
+++ b/includes/datavalues/SMW_DV_Types.php
@@ -1,8 +1,6 @@
<?php
-/**
- * @file
- * @ingroup SMWDataValues
- */
+
+use SMW\DataTypeRegistry;
/**
* This datavalue implements special processing suitable for defining types of
@@ -55,12 +53,12 @@
}
$this->m_givenLabel = smwfNormalTitleText( $value );
- $this->m_typeId = SMWDataValueFactory::findTypeID(
$this->m_givenLabel );
+ $this->m_typeId = DataTypeRegistry::getInstance()->findTypeId(
$this->m_givenLabel );
if ( $this->m_typeId === '' ) {
$this->addError( wfMessage( 'smw_unknowntype',
$this->m_givenLabel )->inContentLanguage()->text() );
$this->m_realLabel = $this->m_givenLabel;
} else {
- $this->m_realLabel =
SMWDataValueFactory::findTypeLabel( $this->m_typeId );
+ $this->m_realLabel =
DataTypeRegistry::getInstance()->findTypeLabel( $this->m_typeId );
}
$this->m_isAlias = ( $this->m_realLabel === $this->m_givenLabel
) ? false : true;
@@ -83,7 +81,7 @@
( $dataItem->getQuery() === '' ) ) {
$this->m_isAlias = false;
$this->m_typeId = $dataItem->getFragment();
- $this->m_realLabel =
SMWDataValueFactory::findTypeLabel( $this->m_typeId );
+ $this->m_realLabel =
DataTypeRegistry::getInstance()->findTypeLabel( $this->m_typeId );
$this->m_caption = $this->m_givenLabel =
$this->m_realLabel;
$this->m_dataitem = $dataItem;
return true;
@@ -162,7 +160,7 @@
* @return string
*/
public function getDBkey() {
- return ( $this->isValid() ) ? SMWDataValueFactory::findTypeID(
$this->m_realLabel ) : '';
+ return ( $this->isValid() ) ?
DataTypeRegistry::getInstance()->findTypeID( $this->m_realLabel ) : '';
}
/**
diff --git a/includes/export/SMW_Exporter.php b/includes/export/SMW_Exporter.php
index f169853..1e01da1 100644
--- a/includes/export/SMW_Exporter.php
+++ b/includes/export/SMW_Exporter.php
@@ -1,8 +1,7 @@
<?php
-/**
- * @file
- * @ingroup SMW
- */
+
+use SMW\DataTypeRegistry;
+use SMW\DataValueFactory;
/**
* SMWExporter is a class for converting internal page-based data
(SMWSemanticData) into
@@ -280,7 +279,7 @@
}
if ( $importURI ) {
- $importValue = SMWDataValueFactory::newDataItemValue(
current( $importDis ), $importProperty );
+ $importValue =
DataValueFactory::getInstance()->newDataItemValue( current( $importDis ),
$importProperty );
$namespace = $importValue->getNS();
$namespaceId = $importValue->getNSID();
$localName = $importValue->getLocalName();
@@ -373,7 +372,7 @@
*/
static public function getOWLPropertyType( $type = '' ) {
if ( $type instanceof SMWDIWikiPage ) {
- $type = SMWDataValueFactory::findTypeID( str_replace(
'_', ' ', $type->getDBkey() ) );
+ $type = DataTypeRegistry::getInstance()->findTypeId(
str_replace( '_', ' ', $type->getDBkey() ) );
} elseif ( $type == false ) {
$type = '';
} // else keep $type
diff --git a/includes/hooks/SpecialStatsAddExtra.php
b/includes/hooks/SpecialStatsAddExtra.php
index be7c49e..8a48c9b 100644
--- a/includes/hooks/SpecialStatsAddExtra.php
+++ b/includes/hooks/SpecialStatsAddExtra.php
@@ -91,7 +91,8 @@
}
}
-
$this->extraStats['smw-statistics']['smw-statistics-datatype-count'] = count(
DataValueFactory::getKnownTypeLabels() );
+ $count = count(
DataTypeRegistry::getInstance()->getKnownTypeLabels() );
+
$this->extraStats['smw-statistics']['smw-statistics-datatype-count'] = $count;
return true;
diff --git a/includes/parserhooks/SetParserFunction.php
b/includes/parserhooks/SetParserFunction.php
index 117fa24..549d80c 100644
--- a/includes/parserhooks/SetParserFunction.php
+++ b/includes/parserhooks/SetParserFunction.php
@@ -59,7 +59,7 @@
foreach ( $parameters->toArray() as $property => $values ){
foreach ( $values as $value ) {
$this->parserData->addDataValue(
- DataValueFactory::newPropertyValue(
+
DataValueFactory::getInstance()->newPropertyValue(
$property,
$value
)
diff --git a/includes/parserhooks/SubobjectParserFunction.php
b/includes/parserhooks/SubobjectParserFunction.php
index 2b46882..1d96af6 100644
--- a/includes/parserhooks/SubobjectParserFunction.php
+++ b/includes/parserhooks/SubobjectParserFunction.php
@@ -106,7 +106,7 @@
foreach ( $parameters->toArray() as $property => $values ){
foreach ( $values as $value ) {
$this->subobject->addDataValue(
- DataValueFactory::newPropertyValue(
$property, $value )
+
DataValueFactory::getInstance()->newPropertyValue( $property, $value )
);
}
}
diff --git a/includes/serializer/Deserializers/SemanticDataDeserializer.php
b/includes/serializer/Deserializers/SemanticDataDeserializer.php
index 4e8db4f..85fd7b5 100644
--- a/includes/serializer/Deserializers/SemanticDataDeserializer.php
+++ b/includes/serializer/Deserializers/SemanticDataDeserializer.php
@@ -3,7 +3,7 @@
namespace SMW\Deserializers;
use SMW\SemanticData;
-use SMW\DataValueFactory;
+use SMW\DataTypeRegistry;
use SMW\DIProperty;
use SMW\DIWikiPage;
@@ -198,7 +198,7 @@
protected function getDataItemId( DIProperty $property ) {
if ( !isset( $this->dataItemTypeIdCache[ $property->getKey() ]
) ) {
- $this->dataItemTypeIdCache[ $property->getKey() ] =
DataValueFactory::getDataItemId( $property->findPropertyTypeID() );
+ $this->dataItemTypeIdCache[ $property->getKey() ] =
DataTypeRegistry::getInstance()->getDataItemId( $property->findPropertyTypeID()
);
}
return $this->dataItemTypeIdCache[ $property->getKey() ];
diff --git a/includes/specials/SMW_SpecialTypes.php
b/includes/specials/SMW_SpecialTypes.php
index 66bc8b8..93fa4cf 100644
--- a/includes/specials/SMW_SpecialTypes.php
+++ b/includes/specials/SMW_SpecialTypes.php
@@ -1,13 +1,16 @@
<?php
+use SMW\DataTypeRegistry;
+use SMW\DataValueFactory;
+
/**
- * This special page for MediaWiki provides information about types. Type
information is
+ * This special page for MediaWiki provides information about types. Type
information is
* stored in the smw_attributes database table, gathered both from the
annotations in
* articles, and from metadata already some global variables managed by
SMWTypeHandlerFactory,
* and in Type: Wiki pages. This only reports on the Type: Wiki pages.
- *
+ *
* @file SMW_SpecialTypes.php
- *
+ *
* @ingroup SMWSpecialPage
* @ingroup SpecialPage
*
@@ -37,13 +40,13 @@
$wgOut->addHTML( $html );
SMWOutputs::commitToOutputPage( $wgOut );
- wfProfileOut( 'smwfDoSpecialTypes (SMW)' );
+ wfProfileOut( 'smwfDoSpecialTypes (SMW)' );
}
protected function getTypesList() {
$html = '<p>' . wfMessage( 'smw_types_docu' )->escaped() .
"</p><br />\n";
- $typeLabels = SMWDataValueFactory::getKnownTypeLabels();
+ $typeLabels =
DataTypeRegistry::getInstance()->getKnownTypeLabels();
asort( $typeLabels, SORT_STRING );
$html .= "<ul>\n";
@@ -63,7 +66,7 @@
$from = $wgRequest->getVal( 'from' );
$until = $wgRequest->getVal( 'until' );
- $typeValue = SMWDataValueFactory::newTypeIDValue( '__typ',
$typeLabel );
+ $typeValue = DataValueFactory::getInstance()->newTypeIDValue(
'__typ', $typeLabel );
if ( !$typeValue->isValid() ) {
return $this->msg( 'smw-special-types-no-such-type'
)->escaped();
diff --git a/includes/storage/SMW_SparqlStoreQueryEngine.php
b/includes/storage/SMW_SparqlStoreQueryEngine.php
index 3c32c6f..e00193f 100644
--- a/includes/storage/SMW_SparqlStoreQueryEngine.php
+++ b/includes/storage/SMW_SparqlStoreQueryEngine.php
@@ -699,8 +699,7 @@
}
//*** Build the condition ***//
- $typeId = $diProperty->findPropertyTypeID();
- $diType = SMWDataValueFactory::getDataItemId( $typeId );
+ $diType = DataTypeRegistry::getInstance()->getDataItemId(
$diProperty->findPropertyTypeID() );
// for types that use helper properties in encoding values,
refer to this helper property:
if ( SMWExporter::hasHelperExpElement( $diType ) ) {
$propertyExpElement =
SMWExporter::getResourceElementForProperty( $diNonInverseProperty, true );
@@ -893,8 +892,7 @@
}
if ( $diType == SMWDataItem::TYPE_NOTYPE ) {
- $typeId = $orderByProperty->findPropertyTypeID();
- $diType = SMWDataValueFactory::getDataItemId( $typeId );
+ $diType =
DataTypeRegistry::getInstance()->getDataItemId(
$orderByProperty->findPropertyTypeID() );
}
$this->addOrderByData( $sparqlCondition, $mainVariable, $diType
);
diff --git a/includes/storage/SQLStore/PropertyTableDefinitionBuilder.php
b/includes/storage/SQLStore/PropertyTableDefinitionBuilder.php
index 93502aa..c8657c6 100644
--- a/includes/storage/SQLStore/PropertyTableDefinitionBuilder.php
+++ b/includes/storage/SQLStore/PropertyTableDefinitionBuilder.php
@@ -2,7 +2,7 @@
namespace SMW\SQLStore;
-use SMW\DataValueFactory;
+use SMW\DataTypeRegistry;
use SMWDIProperty;
/**
@@ -143,7 +143,7 @@
protected function getSpecialProperties( array $specialProperties ) {
foreach( $specialProperties as $propertyKey ) {
$this->addPropertyTable(
- DataValueFactory::getDataItemId(
SMWDIProperty::getPredefinedPropertyTypeId( $propertyKey ) ),
+ DataTypeRegistry::getInstance()->getDataItemId(
SMWDIProperty::getPredefinedPropertyTypeId( $propertyKey ) ),
$this->getTablePrefix() . strtolower(
$propertyKey ),
$propertyKey
);
diff --git a/includes/storage/SQLStore/SMW_SQLStore3.php
b/includes/storage/SQLStore/SMW_SQLStore3.php
index 74c7cb8..b8be77d 100644
--- a/includes/storage/SQLStore/SMW_SQLStore3.php
+++ b/includes/storage/SQLStore/SMW_SQLStore3.php
@@ -5,7 +5,7 @@
use SMW\SQLStore\UnusedPropertiesCollector;
use SMW\SQLStore\PropertiesCollector;
use SMW\SQLStore\StatisticsCollector;
-use SMW\DataValueFactory;
+use SMW\DataTypeRegistry;
use SMW\Settings;
/**
@@ -253,7 +253,7 @@
* @return SMWDataItemHandler
*/
public function getDataItemHandlerForDatatype( $typeid ) {
- $dataItemId = DataValueFactory::getDataItemId( $typeid );
+ $dataItemId = DataTypeRegistry::getInstance()->getDataItemId(
$typeid );
return $this->getDataItemHandlerForDIType( $dataItemId );
}
@@ -677,7 +677,7 @@
* @return string
*/
public static function findTypeTableId( $typeid ) {
- $dataItemId = DataValueFactory::getDataItemId( $typeid );
+ $dataItemId = DataTypeRegistry::getInstance()->getDataItemId(
$typeid );
return self::findDiTypeTableId( $dataItemId );
}
diff --git a/includes/storage/SQLStore/SMW_SQLStore3_Queries.php
b/includes/storage/SQLStore/SMW_SQLStore3_Queries.php
index 807c4b2..bd9e0d5 100644
--- a/includes/storage/SQLStore/SMW_SQLStore3_Queries.php
+++ b/includes/storage/SQLStore/SMW_SQLStore3_Queries.php
@@ -1,9 +1,6 @@
<?php
-/**
- * @file
- * @ingroup SMWStore
- * @since 1.8
- */
+
+use SMW\DataTypeRegistry;
/**
* Class for representing a single (sub)query description. Simple data
@@ -684,7 +681,7 @@
}
$typeid = $property->findPropertyTypeID();
- $diType = SMWDataValueFactory::getDataItemId( $typeid );
+ $diType = DataTypeRegistry::getInstance()->getDataItemId(
$typeid );
if ( $property->isInverse() && $diType !=
SMWDataItem::TYPE_WIKIPAGE ) {
// can only invert properties that point to pages
$query->type = SMWSQLStore3Query::Q_NOQUERY;
diff --git a/includes/storage/SQLStore/SMW_SQLStore3_Readers.php
b/includes/storage/SQLStore/SMW_SQLStore3_Readers.php
index c9cb0fb..2f37d6b 100644
--- a/includes/storage/SQLStore/SMW_SQLStore3_Readers.php
+++ b/includes/storage/SQLStore/SMW_SQLStore3_Readers.php
@@ -1,9 +1,6 @@
<?php
-/**
- * @file
- * @ingroup SMWStore
- * @since 1.8
- */
+
+use SMW\DataTypeRegistry;
/**
* Class to provide all basic read methods for SMWSQLStore3.
@@ -64,7 +61,7 @@
if ( $filter !== false ) {
$relevant = false;
foreach ( $filter as $typeId ) {
- $diType =
SMWDataValueFactory::getDataItemId( $typeId );
+ $diType =
DataTypeRegistry::getInstance()->getDataItemId( $typeId );
$relevant = $relevant || (
$proptable->getDiType() == $diType );
if ( $relevant ) break;
}
@@ -191,7 +188,7 @@
$data = $this->fetchSemanticData( $pid, $property,
$proptables[$tableid], false, $requestoptions );
$result = array();
$propertyTypeId = $property->findPropertyTypeID();
- $propertyDiId = SMWDataValueFactory::getDataItemId(
$propertyTypeId );
+ $propertyDiId =
DataTypeRegistry::getInstance()->getDataItemId( $propertyTypeId );
foreach ( $data as $dbkeys ) {
try {
diff --git a/includes/storage/SQLStore/SMW_Sql3StubSemanticData.php
b/includes/storage/SQLStore/SMW_Sql3StubSemanticData.php
index df24f87..20338ca 100644
--- a/includes/storage/SQLStore/SMW_Sql3StubSemanticData.php
+++ b/includes/storage/SQLStore/SMW_Sql3StubSemanticData.php
@@ -1,9 +1,6 @@
<?php
-/**
- * @file
- * @ingroup SMWStore
- * @since 1.8
- */
+
+use SMW\DataTypeRegistry;
/**
* This class provides a subclass of SMWSemanticData that can store
@@ -117,7 +114,7 @@
// Not catching exception here; the
$this->unstubProperty( $property->getKey(), $property );
$propertyTypeId = $property->findPropertyTypeID();
- $propertyDiId = SMWDataValueFactory::getDataItemId(
$propertyTypeId );
+ $propertyDiId =
DataTypeRegistry::getInstance()->getDataItemId( $propertyTypeId );
foreach ( $this->mStubPropVals[$property->getKey()] as
$dbkeys ) {
try {
--
To view, visit https://gerrit.wikimedia.org/r/96886
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib64cb57e07650e3d249356cc59ca18af8c390c36
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits