http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88142
Revision: 88142
Author: mkroetzsch
Date: 2011-05-15 10:31:14 +0000 (Sun, 15 May 2011)
Log Message:
-----------
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
trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SqlStubSemanticData.php
Modified: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
2011-05-15 10:22:12 UTC (rev 88141)
+++ trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
2011-05-15 10:31:14 UTC (rev 88142)
@@ -165,7 +165,9 @@
if ( !array_key_exists( $sid, $this->m_semdata ) ) { // new
cache entry
$this->m_semdata[$sid] = new SMWSqlStubSemanticData(
$subject, false );
$this->m_semdata[$sid]->addPropertyStubValue( '_SKEY',
array( $sortkey ) );
- $this->m_sdstate[$sid] = array( '__key' );
+ $this->m_sdstate[$sid] = array();
+ // Note: the sortkey is always set but belongs to no
property table,
+ // hence no entry in $this->m_sdstate[$sid] is made.
}
if ( ( count( $this->m_semdata ) > 20 ) && (
self::$in_getSemanticData == 1 ) ) {
@@ -809,9 +811,12 @@
}
// Finally update caches (may be important if jobs are directly
following this call)
- $this->m_semdata[$sid] = clone $data;
+ $this->m_semdata[$sid] =
SMWSqlStubSemanticData::newFromSemanticData( $data );
// Everything that one can know.
- $this->m_sdstate[$sid] = array_keys( self::getPropertyTables()
);
+ $this->m_sdstate[$sid] = array();
+ foreach ( self::getPropertyTables() as $tableId =>
$tableDeclaration ) {
+ $this->m_sdstate[$sid][$tableId] = true;
+ }
wfRunHooks( 'SMWSQLStore2::updateDataAfter', array( $this,
$data ) );
Modified:
trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SqlStubSemanticData.php
===================================================================
---
trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SqlStubSemanticData.php
2011-05-15 10:22:12 UTC (rev 88141)
+++
trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SqlStubSemanticData.php
2011-05-15 10:31:14 UTC (rev 88142)
@@ -39,6 +39,26 @@
protected $mSubject;
/**
+ * Create a new SMWSqlStubSemanticData object that holds the data of a
+ * given SMWSemanticData object. Array assignments create copies in PHP
+ * so the arrays are distinct in input and output object. The object
+ * references are copied as references in a shallow way. This is
+ * sufficient as the data items used there are immutable.
+ *
+ * @param $semanticData SMWSemanticData
+ * @return SMWSqlStubSemanticData
+ */
+ public static function newFromSemanticData( SMWSemanticData
$semanticData ) {
+ $result = new SMWSqlStubSemanticData(
$semanticData->getSubject() );
+ $result->mPropVals = $semanticData->mPropVals;
+ $result->mProperties = $semanticData->mProperties;
+ $result->mHasVisibleProps = $semanticData->mHasVisibleProps;
+ $result->mHasVisibleSpecs = $semanticData->mHasVisibleSpecs;
+ $result->stubObject = $semanticData->stubObject;
+ return $result;
+ }
+
+ /**
* Get the array of all properties that have stored values.
*
* @return array of SMWDIProperty objects
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs