r60561 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60560‎ | r60561 | r60562 >
Date:19:02, 2 January 2010
Author:mkroetzsch
Status:deferred
Tags:
Comment:
The property objects passed to print requests are controlled by them -- thus give them only a clone in SearchByProperty.
For this to work, __clone of SMWPropertyValue also needed to be defined.
(Besides this, SMW_PropertyValue now defines types for some new builtin properties, not used anywhere yet.)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Property.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_PrintRequest.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php
@@ -275,7 +275,9 @@
276276 $options->limit = $this->limit+1;
277277 $options->sort = true;
278278
279 - $printrequest = new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, "", $this->property);
 279+ // Note: printrequests change the caption of properties they get (they expect properties to be given to them)
 280+ // Since we want to continue using the property for our purposes, we give a clone to the print request.
 281+ $printrequest = new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, '', clone $this->property);
280282
281283 $params = array();
282284 $params['format'] = 'ul';
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_PrintRequest.php
@@ -47,6 +47,7 @@
4848 $this->m_outputformat = 'x'; // changed default for Boolean case
4949 }
5050 if ($this->m_data instanceof SMWDataValue) {
 51+ //$this->m_data = clone $data; // we assume that the caller denotes the object ot us; else he needs provide us with a clone
5152 $this->m_data->setCaption($label);
5253 }
5354 if (NULL != $params) $m_params = $params;
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Property.php
@@ -83,6 +83,15 @@
8484 }
8585
8686 /**
 87+ * We use the internal wikipage object to store some of this objects data.
 88+ * Clone it to make sure that data can be modified independelty from the
 89+ * original object's content.
 90+ */
 91+ public function __clone() {
 92+ if ($this->m_wikipage !== NULL) $this->m_wikipage = clone $this->m_wikipage;
 93+ }
 94+
 95+ /**
8796 * Extended parsing function to first check whether value refers to pre-defined
8897 * property, resolve aliases, and set internal property id accordingly.
8998 * @todo Accept/enforce property namespace.
@@ -393,6 +402,13 @@
394403 '_CONC' => array('__con',false),
395404 '_MDAT' => array('_dat',false),
396405 '_ERRP' => array('_wpp',false),
 406+ '_LIST' => array('__typ',true),
 407+ // "virtual" properties for encoding lists in n-ary datatypes (their type must never be used, hence use __err)
 408+ '_1' => array('__err',false),
 409+ '_2' => array('__err',false),
 410+ '_3' => array('__err',false),
 411+ '_4' => array('__err',false),
 412+ '_5' => array('__err',false),
397413 );
398414 wfRunHooks( 'smwInitProperties' );
399415 }

Status & tagging log