r88142 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88141‎ | r88142 | r88143 >
Date:10:31, 15 May 2011
Author:mkroetzsch
Status:ok
Tags:
Comment:
Convert SemanticData to SqlStubSemanticData when keeping it in the internal cache after an update, and ensure that the completeness of this data is recorded correctly (no later attempts to extend it).

Either of these changes fixes Bug 28991, which is thus closed twice now (we can keep one closing for later, in case someone reopens it).
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SqlStubSemanticData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SqlStubSemanticData.php
@@ -39,6 +39,26 @@
4040 protected $mSubject;
4141
4242 /**
 43+ * Create a new SMWSqlStubSemanticData object that holds the data of a
 44+ * given SMWSemanticData object. Array assignments create copies in PHP
 45+ * so the arrays are distinct in input and output object. The object
 46+ * references are copied as references in a shallow way. This is
 47+ * sufficient as the data items used there are immutable.
 48+ *
 49+ * @param $semanticData SMWSemanticData
 50+ * @return SMWSqlStubSemanticData
 51+ */
 52+ public static function newFromSemanticData( SMWSemanticData $semanticData ) {
 53+ $result = new SMWSqlStubSemanticData( $semanticData->getSubject() );
 54+ $result->mPropVals = $semanticData->mPropVals;
 55+ $result->mProperties = $semanticData->mProperties;
 56+ $result->mHasVisibleProps = $semanticData->mHasVisibleProps;
 57+ $result->mHasVisibleSpecs = $semanticData->mHasVisibleSpecs;
 58+ $result->stubObject = $semanticData->stubObject;
 59+ return $result;
 60+ }
 61+
 62+ /**
4363 * Get the array of all properties that have stored values.
4464 *
4565 * @return array of SMWDIProperty objects
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -165,7 +165,9 @@
166166 if ( !array_key_exists( $sid, $this->m_semdata ) ) { // new cache entry
167167 $this->m_semdata[$sid] = new SMWSqlStubSemanticData( $subject, false );
168168 $this->m_semdata[$sid]->addPropertyStubValue( '_SKEY', array( $sortkey ) );
169 - $this->m_sdstate[$sid] = array( '__key' );
 169+ $this->m_sdstate[$sid] = array();
 170+ // Note: the sortkey is always set but belongs to no property table,
 171+ // hence no entry in $this->m_sdstate[$sid] is made.
170172 }
171173
172174 if ( ( count( $this->m_semdata ) > 20 ) && ( self::$in_getSemanticData == 1 ) ) {
@@ -809,9 +811,12 @@
810812 }
811813
812814 // Finally update caches (may be important if jobs are directly following this call)
813 - $this->m_semdata[$sid] = clone $data;
 815+ $this->m_semdata[$sid] = SMWSqlStubSemanticData::newFromSemanticData( $data );
814816 // Everything that one can know.
815 - $this->m_sdstate[$sid] = array_keys( self::getPropertyTables() );
 817+ $this->m_sdstate[$sid] = array();
 818+ foreach ( self::getPropertyTables() as $tableId => $tableDeclaration ) {
 819+ $this->m_sdstate[$sid][$tableId] = true;
 820+ }
816821
817822 wfRunHooks( 'SMWSQLStore2::updateDataAfter', array( $this, $data ) );
818823

Status & tagging log