r97266 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97265‎ | r97266 | r97267 >
Date:13:40, 16 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fix unserialization bug
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_CompatibilityHelpers.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_URI.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Types.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_URI.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_URI.php
@@ -141,7 +141,7 @@
142142
143143 // Now create the URI data item:
144144 try {
145 - $this->m_dataitem = new SMWDIUri( $scheme, $hierpart, $query, $fragment, $this->m_typeid);
 145+ $this->m_dataitem = new SMWDIUri( $scheme, $hierpart, $query, $fragment, $this->m_typeid );
146146 } catch ( SMWDataItemException $e ) {
147147 $this->addError( wfMsgForContent( 'smw_baduri', $this->m_wikitext ) );
148148 $this->m_dataitem = new SMWDIUri( 'http', '//example.com', '', '', $this->m_typeid ); // define data item to have some value
@@ -244,11 +244,13 @@
245245 */
246246 public function getURL() {
247247 global $wgUrlProtocols;
 248+
248249 foreach ( $wgUrlProtocols as $prot ) {
249250 if ( ( $prot == $this->m_dataitem->getScheme() . ':' ) || ( $prot == $this->m_dataitem->getScheme() . '://' ) ) {
250251 return $this->m_dataitem->getURI();
251252 }
252253 }
 254+
253255 return '';
254256 }
255257
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Types.php
@@ -34,7 +34,7 @@
3535 }
3636
3737 public static function getTypeUriFromTypeId( $typeId ) {
38 - return new SMWDIUri( 'http', '//semantic-mediawiki.org/swivt/1.0', '', $typeId );
 38+ return new SMWDIUri( 'http', 'semantic-mediawiki.org/swivt/1.0', '', $typeId );
3939 }
4040
4141 protected function parseUserValue( $value ) {
@@ -82,7 +82,7 @@
8383 */
8484 protected function loadDataItem( SMWDataItem $dataItem ) {
8585 if ( ( $dataItem instanceof SMWDIUri ) && ( $dataItem->getScheme() == 'http' ) &&
86 - ( $dataItem->getHierpart() == '//semantic-mediawiki.org/swivt/1.0' ) &&
 86+ ( $dataItem->getHierpart() == 'semantic-mediawiki.org/swivt/1.0' ) &&
8787 ( $dataItem->getQuery() == '' ) ) {
8888 $this->m_isAlias = false;
8989 $this->m_typeId = $dataItem->getFragment();
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_CompatibilityHelpers.php
@@ -48,7 +48,7 @@
4949 if ( $typeid == '__typ' && $dbkeys[0]{0} == '_' ) { // b/c: old data stored as type ids
5050 return SMWTypesValue::getTypeUriFromTypeId( $dbkeys[0] );
5151 } else {
52 - return SMWDIUri::doUnserialize( $dbkeys[0]);
 52+ return SMWDIUri::doUnserialize( $dbkeys[0] );
5353 }
5454 case SMWDataItem::TYPE_TIME:
5555 $timedate = explode( 'T', $dbkeys[0], 2 );
Index: trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_URI.php
@@ -71,11 +71,13 @@
7272 'http', 'https', 'ftp'
7373 );
7474
75 - return $this->m_scheme . ':'
 75+ $uri = $this->m_scheme . ':'
7676 . ( in_array( $this->m_scheme, $schemesWithDoubleslesh ) ? '//' : '' )
7777 . $this->m_hierpart
7878 . ( $this->m_query ? '?' . $this->m_query : '' )
7979 . ( $this->m_fragment ? '#' . $this->m_fragment : '' );
 80+
 81+ return $uri;
8082 }
8183
8284 public function getScheme() {
@@ -125,6 +127,9 @@
126128 $hierpart = $parts[0];
127129 $fragment = ( count( $parts ) == 2 ) ? $parts[1] : '';
128130 }
 131+
 132+ $hierpart = ltrim( $hierpart, '/' );
 133+
129134 return new SMWDIUri( $scheme, $hierpart, $query, $fragment );
130135 }
131136