Skip to content
Permalink
Browse files

Setting to force HttpVersion for RepositoryConnector, refs 1306

Default setting is `$GLOBALS['smwgSparqlRepositoryConnectorForcedHttpVersion'] = false;`
and should not be changed unless error 1306 was encountered.
  • Loading branch information...
mwjames committed Dec 17, 2015
1 parent ec9d82d commit 04e6dce5d1fad655308fc3b266b0c8b1e6536a4d
@@ -114,6 +114,21 @@
##
$GLOBALS['smwgSparqlQFeatures'] = SMW_SPARQL_QF_REDI | SMW_SPARQL_QF_SUBP | SMW_SPARQL_QF_SUBC;
##
# @see https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/1306
#
# Setting to explicitly force a CURLOPT_HTTP_VERSION for the endpoint communication
# and should not be changed unless an error as in #1306 was encountered.
#
# @see http://curl.haxx.se/libcurl/c/CURLOPT_HTTP_VERSION.html reads "... libcurl
# to use the specific HTTP versions. This is not sensible to do unless you have
# a good reason.""
#
# @since 2.3
# @default false === means to use the default as determined by cURL
##
$GLOBALS['smwgSparqlRepositoryConnectorForcedHttpVersion'] = false;
###
# Setting this option to true before including this file to enable the old
# Type: namespace that SMW used up to version 1.5.*. This should only be
@@ -139,7 +139,8 @@ public static function newFromGlobals() {
'smwgPropertyDependencyDetectionBlacklist' => $GLOBALS['smwgPropertyDependencyDetectionBlacklist'],
'smwgExportBCNonCanonicalFormUse' => $GLOBALS['smwgExportBCNonCanonicalFormUse'],
'smwgExportBCAuxiliaryUse' => $GLOBALS['smwgExportBCAuxiliaryUse'],
'smwgEnabledInTextAnnotationParserStrictMode' => $GLOBALS['smwgEnabledInTextAnnotationParserStrictMode']
'smwgEnabledInTextAnnotationParserStrictMode' => $GLOBALS['smwgEnabledInTextAnnotationParserStrictMode'],
'smwgSparqlRepositoryConnectorForcedHttpVersion' => $GLOBALS['smwgSparqlRepositoryConnectorForcedHttpVersion']
);
$settings = $settings + array(
@@ -62,6 +62,11 @@ class RepositoryConnectionProvider implements DBConnectionProvider {
*/
private $dataEndpoint = null;
/**
* @var boolean|integer
*/
private $httpVersion = false;
/**
* @since 2.0
*
@@ -84,6 +89,15 @@ public function __construct( $connectorId = null, $defaultGraph = null, $queryEn
$this->dataEndpoint = $dataEndpoint;
}
/**
* @since 2.3
*
* @return integer $httpVersion
*/
public function setHttpVersionTo( $httpVersion ) {
$this->httpVersion = $httpVersion;
}
/**
* @see DBConnectionProvider::getConnection
*
@@ -130,9 +144,16 @@ private function connectTo( $connectorId ) {
$this->dataEndpoint = $GLOBALS['smwgSparqlDataEndpoint'];
}
$curlRequest = new CurlRequest( curl_init() );
// https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/1306
if ( $this->httpVersion ) {
$curlRequest->setOption( CURLOPT_HTTP_VERSION, $this->httpVersion );
}
$connection = new $repositoryConnector(
new RepositoryClient( $this->defaultGraph, $this->queryEndpoint, $this->updateEndpoint, $this->dataEndpoint ),
new CurlRequest( curl_init() )
$curlRequest
);
if ( $this->isRepositoryConnection( $connection ) ) {
@@ -26,13 +26,19 @@ class SPARQLStoreFactory {
*/
private $store;
/**
* @var ApplicationFactory
*/
private $applicationFactory;
/**
* @since 2.2
*
* @param SPARQLStore $store
*/
public function __construct( SPARQLStore $store ) {
$this->store = $store;
$this->applicationFactory = ApplicationFactory::getInstance();
}
/**
@@ -52,19 +58,18 @@ public function newBaseStore( $storeId ) {
public function newMasterQueryEngine() {
$engineOptions = new EngineOptions();
$applicationFactory = ApplicationFactory::getInstance();
$propertyHierarchyLookup = new PropertyHierarchyLookup(
$this->store,
$applicationFactory->newCacheFactory()->newFixedInMemoryCache( 500 )
$this->applicationFactory->newCacheFactory()->newFixedInMemoryCache( 500 )
);
$propertyHierarchyLookup->setSubcategoryDepth(
$applicationFactory->getSettings()->get( 'smwgQSubcategoryDepth' )
$this->applicationFactory->getSettings()->get( 'smwgQSubcategoryDepth' )
);
$propertyHierarchyLookup->setSubpropertyDepth(
$applicationFactory->getSettings()->get( 'smwgQSubpropertyDepth' )
$this->applicationFactory->getSettings()->get( 'smwgQSubpropertyDepth' )
);
$circularReferenceGuard = new CircularReferenceGuard( 'sparql-query' );
@@ -101,9 +106,14 @@ public function newConnectionManager() {
$connectionManager = new ConnectionManager();
$repositoryConnectionProvider = new RepositoryConnectionProvider();
$repositoryConnectionProvider->setHttpVersionTo(
$this->applicationFactory->getSettings()->get( 'smwgSparqlRepositoryConnectorForcedHttpVersion' )
);
$connectionManager->registerConnectionProvider(
'sparql',
new RepositoryConnectionProvider()
$repositoryConnectionProvider
);
return $connectionManager;
@@ -62,6 +62,7 @@ public function testCanConstruct() {
public function testGetDefaultConnection() {
$instance = new RepositoryConnectionProvider( 'default' );
$instance->setHttpVersionTo( CURL_HTTP_VERSION_NONE );
$this->assertInstanceOf(
'\SMWSparqlDatabase',

0 comments on commit 04e6dce

Please sign in to comment.
You can’t perform that action at this time.