Jeroen De Dauw has uploaded a new change for review.
https://gerrit.wikimedia.org/r/75309
Change subject: Update some class names to non-deprecated version
......................................................................
Update some class names to non-deprecated version
Change-Id: I6c287c437f82f01588cd0e20363597093b366771
---
M includes/dataitems/DIConcept.php
M includes/dataitems/SMW_DI_Bool.php
M includes/dataitems/SMW_DI_Container.php
M includes/dataitems/SMW_DI_GeoCoord.php
M includes/dataitems/SMW_DI_Number.php
M includes/dataitems/SMW_DI_Property.php
M includes/dataitems/SMW_DI_Time.php
M includes/dataitems/SMW_DI_URI.php
M includes/dataitems/SMW_DI_WikiPage.php
9 files changed, 34 insertions(+), 22 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki
refs/changes/09/75309/1
diff --git a/includes/dataitems/DIConcept.php b/includes/dataitems/DIConcept.php
index 20056e6..e9a9428 100644
--- a/includes/dataitems/DIConcept.php
+++ b/includes/dataitems/DIConcept.php
@@ -187,12 +187,12 @@
/**
* Create a data item from the provided serialization string and type
* ID.
- * @return SMWDIConcept
+ * @return DIConcept
*/
public static function doUnserialize( $serialization ) {
$result = unserialize( $serialization );
if ( $result === false ) {
- throw new SMWDataItemException( "Unserialization
failed." );
+ throw new DataItemException( "Unserialization failed."
);
}
return $result;
}
diff --git a/includes/dataitems/SMW_DI_Bool.php
b/includes/dataitems/SMW_DI_Bool.php
index 12126c9..1b51a13 100644
--- a/includes/dataitems/SMW_DI_Bool.php
+++ b/includes/dataitems/SMW_DI_Bool.php
@@ -3,6 +3,7 @@
* @file
* @ingroup SMWDataItems
*/
+use SMW\DataItemException;
/**
* This class implements Boolean data items.
@@ -22,7 +23,7 @@
public function __construct( $boolean ) {
if ( !is_bool( $boolean ) ) {
- throw new SMWDataItemException( "Initialization value
'$boolean' is not a boolean." );
+ throw new DataItemException( "Initialization value
'$boolean' is not a boolean." );
}
$this->m_boolean = ( $boolean == true );
@@ -55,7 +56,7 @@
} elseif ( $serialization == 'f' ) {
return new SMWDIBoolean( false );
} else {
- throw new SMWDataItemException( "Boolean data item
unserialised from illegal value '$serialization'" );
+ throw new DataItemException( "Boolean data item
unserialised from illegal value '$serialization'" );
}
}
diff --git a/includes/dataitems/SMW_DI_Container.php
b/includes/dataitems/SMW_DI_Container.php
index 3e644fb..68d4f46 100644
--- a/includes/dataitems/SMW_DI_Container.php
+++ b/includes/dataitems/SMW_DI_Container.php
@@ -4,6 +4,8 @@
* @ingroup SMWDataItems
*/
+use SMW\DataItemException;
+
/**
* Subclass of SMWSemanticData that is used to store the data in SMWDIContainer
* objects. It is special since the subject that the stored property-value
pairs
@@ -71,7 +73,7 @@
*/
public function getSubject() {
if ( $this->hasAnonymousSubject() ) {
- throw new SMWDataItemException("Trying to get the
subject of a container data item that has not been given any. This container
can only be used as a search pattern.");
+ throw new DataItemException("Trying to get the subject
of a container data item that has not been given any. This container can only
be used as a search pattern.");
} else {
return $this->mSubject;
}
@@ -182,7 +184,7 @@
/// TODO May issue an E_NOTICE when problems occur; catch this
$data = unserialize( $serialization );
if ( !( $data instanceof SMWContainerSemanticData ) ) {
- throw new SMWDataItemException( "Could not unserialize
SMWDIContainer from the given string." );
+ throw new DataItemException( "Could not unserialize
SMWDIContainer from the given string." );
}
return new SMWDIContainer( $data );
}
diff --git a/includes/dataitems/SMW_DI_GeoCoord.php
b/includes/dataitems/SMW_DI_GeoCoord.php
index a66ded0..109c783 100644
--- a/includes/dataitems/SMW_DI_GeoCoord.php
+++ b/includes/dataitems/SMW_DI_GeoCoord.php
@@ -1,5 +1,7 @@
<?php
+use SMW\DataItemException;
+
/**
* Implementation of dataitems that are geographic coordinates.
*
@@ -60,7 +62,7 @@
}
}
else {
- throw new SMWDataItemException( 'Invalid
coordinate data passed to the SMWDIGeoCoord constructor' );
+ throw new DataItemException( 'Invalid
coordinate data passed to the SMWDIGeoCoord constructor' );
}
}
elseif ( $count === 2 || $count === 3 ) {
@@ -72,7 +74,7 @@
}
}
else {
- throw new SMWDataItemException( 'Invalid coordinate
data passed to the SMWDIGeoCoord constructor' );
+ throw new DataItemException( 'Invalid coordinate data
passed to the SMWDIGeoCoord constructor' );
}
}
@@ -136,7 +138,7 @@
$count = count( $parts );
if ( $count !== 2 && $count !== 3 ) {
- throw new SMWDataItemException( 'Unserialization of
coordinates failed' );
+ throw new DataItemException( 'Unserialization of
coordinates failed' );
}
$coords = array( 'lat' => (float)$parts[0], 'lon' =>
(float)$parts[1] );
diff --git a/includes/dataitems/SMW_DI_Number.php
b/includes/dataitems/SMW_DI_Number.php
index ccdff6d..e9e0626 100644
--- a/includes/dataitems/SMW_DI_Number.php
+++ b/includes/dataitems/SMW_DI_Number.php
@@ -4,6 +4,8 @@
* @ingroup SMWDataItems
*/
+use SMW\DataItemException;
+
/**
* This class implements number data items.
*
@@ -22,7 +24,7 @@
public function __construct( $number ) {
if ( !is_numeric( $number ) ) {
- throw new SMWDataItemException( "Initialization value
'$number' is not a number." );
+ throw new DataItemException( "Initialization value
'$number' is not a number." );
}
$this->m_number = $number;
}
diff --git a/includes/dataitems/SMW_DI_Property.php
b/includes/dataitems/SMW_DI_Property.php
index 5f92dc6..ca74d61 100644
--- a/includes/dataitems/SMW_DI_Property.php
+++ b/includes/dataitems/SMW_DI_Property.php
@@ -3,6 +3,7 @@
* @file
* @ingroup SMWDataItems
*/
+use SMW\DataItemException;
/**
* This class implements Property data items.
@@ -204,7 +205,7 @@
try {
return new SMWDIWikiPage( $dbkey, SMW_NS_PROPERTY, '',
$subobjectName );
- } catch ( SMWDataItemException $e ) {
+ } catch ( DataItemException $e ) {
return null;
}
}
diff --git a/includes/dataitems/SMW_DI_Time.php
b/includes/dataitems/SMW_DI_Time.php
index acee9fa..f927847 100644
--- a/includes/dataitems/SMW_DI_Time.php
+++ b/includes/dataitems/SMW_DI_Time.php
@@ -3,6 +3,7 @@
* @file
* @ingroup SMWDataItems
*/
+use SMW\DataItemException;
/**
* This class implements time data items.
@@ -104,10 +105,10 @@
public function __construct( $calendarmodel, $year, $month = false,
$day = false,
$hour = false, $minute = false, $second =
false ) {
if ( ( $calendarmodel != self::CM_GREGORIAN ) && (
$calendarmodel != self::CM_JULIAN ) ) {
- throw new SMWDataItemException( "Unsupported calendar
model constant \"$calendarmodel\"." );
+ throw new DataItemException( "Unsupported calendar
model constant \"$calendarmodel\"." );
}
if ( $year == 0 ) {
- throw new SMWDataItemException( "There is no year 0 in
Gregorian and Julian calendars." );
+ throw new DataItemException( "There is no year 0 in
Gregorian and Julian calendars." );
}
$this->m_model = $calendarmodel;
$this->m_year = intval( $year );
@@ -120,10 +121,10 @@
( $this->m_minutes < 0 ) || ( $this->m_minutes > 59 ) ||
( $this->m_seconds < 0 ) || ( $this->m_seconds > 59 ) ||
( $this->m_month < 1 ) || ( $this->m_month > 12 ) ) {
- throw new SMWDataItemException( "Part of the date is
out of bounds." );
+ throw new DataItemException( "Part of the date is out
of bounds." );
}
if ( $this->m_day > self::getDayNumberForMonth( $this->m_month,
$this->m_year, $this->m_model ) ) {
- throw new SMWDataItemException( "Month {$this->m_month}
in year {$this->m_year} did not have {$this->m_day} days in this calendar
model." );
+ throw new DataItemException( "Month {$this->m_month} in
year {$this->m_year} did not have {$this->m_day} days in this calendar model."
);
}
if ( $month === false ) {
$this->m_precision = self::PREC_Y;
@@ -291,7 +292,7 @@
if ( is_numeric( $parts[$i] ) ) {
$values[$i] = intval( $parts[$i] );
} else {
- throw new SMWDataItemException(
"Unserialization failed: the string \"$serialization\" is no valid datetime
specification." );
+ throw new DataItemException(
"Unserialization failed: the string \"$serialization\" is no valid datetime
specification." );
}
} else {
$values[$i] = false;
@@ -299,7 +300,7 @@
}
if ( count( $parts ) <= 1 ) {
- throw new SMWDataItemException( "Unserialization
failed: the string \"$serialization\" is no valid URI." );
+ throw new DataItemException( "Unserialization failed:
the string \"$serialization\" is no valid URI." );
}
return new self( $values[0], $values[1], $values[2],
$values[3], $values[4], $values[5], $values[6] );
diff --git a/includes/dataitems/SMW_DI_URI.php
b/includes/dataitems/SMW_DI_URI.php
index 7397ce7..c7aa245 100644
--- a/includes/dataitems/SMW_DI_URI.php
+++ b/includes/dataitems/SMW_DI_URI.php
@@ -4,6 +4,8 @@
* @ingroup SMWDataItems
*/
+use SMW\DataItemException;
+
/**
* This class implements URI data items.
*
@@ -50,10 +52,10 @@
*/
public function __construct( $scheme, $hierpart, $query, $fragment ) {
if ( ( $scheme === '' ) || ( preg_match( '/[^a-zA-Z]/u',
$scheme ) ) ) {
- throw new SMWDataItemException( "Illegal URI scheme
\"$scheme\"." );
+ throw new DataItemException( "Illegal URI scheme
\"$scheme\"." );
}
if ( $hierpart === '' ) {
- throw new SMWDataItemException( "Illegal URI hierpart
\"$hierpart\"." );
+ throw new DataItemException( "Illegal URI hierpart
\"$hierpart\"." );
}
$this->m_scheme = $scheme;
$this->m_hierpart = $hierpart;
@@ -112,7 +114,7 @@
public static function doUnserialize( $serialization ) {
$parts = explode( ':', $serialization, 2 ); // try to split
"schema:rest"
if ( count( $parts ) <= 1 ) {
- throw new SMWDataItemException( "Unserialization
failed: the string \"$serialization\" is no valid URI." );
+ throw new DataItemException( "Unserialization failed:
the string \"$serialization\" is no valid URI." );
}
$scheme = $parts[0];
$parts = explode( '?', $parts[1], 2 ); // try to split
"hier-part?queryfrag"
diff --git a/includes/dataitems/SMW_DI_WikiPage.php
b/includes/dataitems/SMW_DI_WikiPage.php
index cb78bf9..11c3413 100644
--- a/includes/dataitems/SMW_DI_WikiPage.php
+++ b/includes/dataitems/SMW_DI_WikiPage.php
@@ -3,6 +3,7 @@
* @file
* @ingroup SMWDataItems
*/
+use SMW\DataItemException;
/**
* This class implements wiki page data items.
@@ -53,7 +54,7 @@
// Check if the provided value holds an integer
// (it can be of type string or float as well, as long as the
value is an int)
if ( !ctype_digit( ltrim( (string)$namespace, '-' ) ) ) {
- throw new SMWDataItemException( "Given namespace
'$namespace' is not an integer." );
+ throw new DataItemException( "Given namespace
'$namespace' is not an integer." );
}
$this->m_dbkey = $dbkey;
@@ -137,7 +138,7 @@
} elseif ( count( $parts ) == 4 ) {
return new SMWDIWikiPage( $parts[0], intval( $parts[1]
), $parts[2], $parts[3] );
} else {
- throw new SMWDataItemException( "Unserialization
failed: the string \"$serialization\" was not understood." );
+ throw new DataItemException( "Unserialization failed:
the string \"$serialization\" was not understood." );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/75309
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c287c437f82f01588cd0e20363597093b366771
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits