diff --git a/includes/dataitems/SMW_DI_Property.php b/includes/dataitems/SMW_DI_Property.php index a4be012760..d4ea0da064 100644 --- a/includes/dataitems/SMW_DI_Property.php +++ b/includes/dataitems/SMW_DI_Property.php @@ -62,6 +62,13 @@ class DIProperty extends SMWDataItem { */ private $m_proptypeid; + /** + * Interwiki prefix for when a property represents a non-local entity + * + * @var string + */ + private $interwiki = ''; + /** * Initialise a property. This constructor checks that keys of * predefined properties do really exist (in the current configuration @@ -188,6 +195,15 @@ public function getLabel() { return $prefix . PropertyRegistry::getInstance()->findPropertyLabelById( $this->m_key ); } + /** + * @since 2.4 + * + * @param string $interwiki + */ + public function setInterwiki( $interwiki ) { + $this->interwiki = $interwiki; + } + /** * Get an object of type SMWDIWikiPage that represents the page which * relates to this property, or null if no such page exists. The latter @@ -212,7 +228,7 @@ public function getDiWikiPage( $subobjectName = '' ) { } try { - return new SMWDIWikiPage( $dbkey, SMW_NS_PROPERTY, '', $subobjectName ); + return new SMWDIWikiPage( $dbkey, SMW_NS_PROPERTY, $this->interwiki, $subobjectName ); } catch ( DataItemException $e ) { return null; } @@ -257,7 +273,7 @@ public function findPropertyTypeID() { if ( !isset( $this->m_proptypeid ) ) { if ( $this->isUserDefined() ) { // normal property - $diWikiPage = new SMWDIWikiPage( $this->getKey(), SMW_NS_PROPERTY, '' ); + $diWikiPage = new SMWDIWikiPage( $this->getKey(), SMW_NS_PROPERTY, $this->interwiki ); $typearray = StoreFactory::getStore()->getPropertyValues( $diWikiPage, new self( '_TYPE' ) ); if ( count( $typearray ) >= 1 ) { // some types given, pick one (hopefully unique) diff --git a/includes/datavalues/SMW_DV_WikiPage.php b/includes/datavalues/SMW_DV_WikiPage.php index d61d72ca2d..202f543211 100644 --- a/includes/datavalues/SMW_DV_WikiPage.php +++ b/includes/datavalues/SMW_DV_WikiPage.php @@ -195,7 +195,7 @@ public function getShortWikiText( $linked = null ) { return $this->m_caption !== false ? $this->m_caption : $this->getWikiValue(); } - if ( $this->m_dataitem->getNamespace() == NS_FILE ) { + if ( $this->m_dataitem->getNamespace() == NS_FILE && $this->m_dataitem->getInterwiki() === '' ) { $linkEscape = ''; $defaultCaption = '|' . $this->getShortCaptionText() . '|frameless|border|text-top'; } else { @@ -277,7 +277,7 @@ public function getLongWikiText( $linked = null ) { if ( is_null( $linked ) || $linked === false || $this->m_outformat == '-' ) { return $this->getWikiValue(); - } elseif ( $this->m_dataitem->getNamespace() == NS_FILE ) { + } elseif ( $this->m_dataitem->getNamespace() == NS_FILE && $this->m_dataitem->getInterwiki() === '' ) { // Embed images and other files // Note that the embedded file links to the image, hence needs no additional link text. // There should not be a linebreak after an impage, just like there is no linebreak after diff --git a/includes/query/SMW_Query.php b/includes/query/SMW_Query.php index bd81da413f..b78c98591c 100644 --- a/includes/query/SMW_Query.php +++ b/includes/query/SMW_Query.php @@ -59,6 +59,13 @@ class SMWQuery { */ private $subject; + /** + * Describes a non-local (remote) query source + * + * @var string|null + */ + private $querySource = null; + /** * Constructor. * @param $description SMWDescription object describing the query conditions @@ -94,6 +101,24 @@ public function getSubject() { return $this->subject; } + /** + * @since 2.4 + * + * @param string + */ + public function setQuerySource( $querySource ) { + $this->querySource = $querySource; + } + + /** + * @since 2.4 + * + * @return string + */ + public function getQuerySource() { + return $this->querySource; + } + /** * Sets the mainlabel. * @@ -226,7 +251,7 @@ public function setUnboundLimit( $limit ) { * @param array $sortKeys */ public function setSortKeys( array $sortKeys ) { - $this->sortKeys = $sortKeys; + $this->sortkeys = $sortKeys; } /** @@ -235,7 +260,7 @@ public function setSortKeys( array $sortKeys ) { * @return array */ public function getSortKeys() { - return $this->sortKeys; + return $this->sortkeys; } /** @@ -294,6 +319,13 @@ public function toArray() { 'querymode' => $this->querymode ); + // @2.4 Keep the queryID stable with previous versions unless + // a query source is selected. The "same" query executed on different + // remote systems requires a different queryID + if ( $this->querySource !== '' ) { + $serialized['parameters']['source'] = $this->querySource; + } + foreach ( $this->getExtraPrintouts() as $printout ) { $serialization = $printout->getSerialisation(); if ( $serialization !== '?#' ) { diff --git a/includes/query/SMW_QueryProcessor.php b/includes/query/SMW_QueryProcessor.php index 5dcadf8f35..fbdb5fdbbb 100644 --- a/includes/query/SMW_QueryProcessor.php +++ b/includes/query/SMW_QueryProcessor.php @@ -125,6 +125,7 @@ static public function createQuery( $queryString, array $params, $context = self $query->setExtraPrintouts( $extraPrintouts ); $query->setMainLabel( $params['mainlabel']->getValue() ); $query->addErrors( $qp->getErrors() ); // keep parsing errors for later output + $query->setQuerySource( $params['source']->getValue() ); // set mode, limit, and offset: $query->querymode = $querymode; diff --git a/includes/storage/SMW_QueryResult.php b/includes/storage/SMW_QueryResult.php index 1677b83a9f..8414598f21 100644 --- a/includes/storage/SMW_QueryResult.php +++ b/includes/storage/SMW_QueryResult.php @@ -354,9 +354,10 @@ public function toArray() { return array_merge( $serializeArray, array( 'meta'=> array( - 'hash' => md5( FormatJson::encode( $serializeArray ) ), + 'hash' => HashBuilder::createHashIdForContent( $serializeArray ), 'count' => $this->getCount(), - 'offset' => $this->mQuery->getOffset() + 'offset' => $this->mQuery->getOffset(), + 'source' => $this->mQuery->getQuerySource() ) ) );