Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register connection providers early, refs 4170 #4195

Merged
merged 1 commit into from Aug 4, 2019
Merged

Conversation

mwjames
Copy link
Contributor

@mwjames mwjames commented Aug 3, 2019

This PR is made in reference to: #4170

This PR addresses or contains:

This PR includes:

  • Tests (unit/integration)
  • CI build passed

Analysis

Due to SemanticCite being registered before SemanticMediaWiki it caused:

wfLoadExtension( 'SemanticCite' );
enableSemantics( 'example.org' );
[70c83752cac7731351c6966d] .../index.php/Main_Page RuntimeException from line 49 of ...\extensions\SemanticMediaWiki\src\Connection\ConnectionManager.php: mw.db is not registered as connection provider

Backtrace:

#0 ...\extensions\SemanticMediaWiki\src\Store.php(598): SMW\Connection\ConnectionManager->getConnection(string)
#1 ...\extensions\SemanticMediaWiki\src\SQLStore\SQLStore.php(656): SMW\Store->getConnection(string)
#2 ...\extensions\SemanticMediaWiki\src\SQLStore\SQLStoreFactory.php(409): SMW\SQLStore\SQLStore->getConnection(string)
#3 ...\extensions\SemanticMediaWiki\includes\storage\SQLStore\SMW_Sql3SmwIds.php(956): SMW\SQLStore\SQLStoreFactory->newPropertyTableHashes(SMW\SQLStore\EntityStore\IdCacheManager)
#4 ...\extensions\SemanticMediaWiki\includes\storage\SQLStore\SMW_Sql3SmwIds.php(152): SMWSql3SmwIds->initCache()
#5 ...\extensions\SemanticMediaWiki\src\SQLStore\SQLStoreFactory.php(133): SMWSql3SmwIds->__construct(SMW\Elastic\ElasticStore, SMW\SQLStore\SQLStoreFactory)
#6 ...\extensions\SemanticMediaWiki\src\SQLStore\SQLStore.php(158): SMW\SQLStore\SQLStoreFactory->newEntityTable()
#7 ...\extensions\SemanticMediaWiki\src\Elastic\ElasticStore.php(60): SMW\SQLStore\SQLStore->__construct()
#8 ...\extensions\SemanticMediaWiki\src\StoreFactory.php(61): SMW\Elastic\ElasticStore->__construct()
#9 ...\extensions\SemanticMediaWiki\src\StoreFactory.php(42): SMW\StoreFactory::newFromClass(string)
#10 ...\extensions\SemanticMediaWiki\src\Services\SharedServicesContainer.php(100): SMW\StoreFactory::getStore(string)
#11 [internal function]: SMW\Services\SharedServicesContainer->newStore(Onoi\CallbackContainer\CallbackContainerBuilder, string)
#12 ...\vendor\onoi\callback-container\src\CallbackContainerBuilder.php(260): call_user_func_array(array, array)
#13 ...\vendor\onoi\callback-container\src\CallbackContainerBuilder.php(288): Onoi\CallbackContainer\CallbackContainerBuilder->getReturnValueFromCallbackHandlerFor(string, array)
#14 ...\vendor\onoi\callback-container\src\CallbackContainerBuilder.php(195): Onoi\CallbackContainer\CallbackContainerBuilder->getReturnValueFromSingletonFor(string, array)
#15 ...\extensions\SemanticMediaWiki\src\Services\ServicesFactory.php(228): Onoi\CallbackContainer\CallbackContainerBuilder->singleton(string, NULL)
#16 ...\extensions\SemanticCite\SemanticCite.php(154): SMW\Services\ServicesFactory->getStore()
#17 ...\includes\Setup.php(938): SemanticCite::onExtensionFunction()
#18 ...\includes\WebStart.php(77): require_once(string)
#19 ...\index.php(39): require(string)
#20 {main}

The reason is that SemanticCite::onExtensionFunction is called before SemanticMediaWiki::onExtensionFunction. Use SemanticMediaWiki::initExtension which runs before the onExtensionFunction execution.

@mwjames mwjames merged commit 3228e71 into master Aug 4, 2019
@mwjames mwjames deleted the connection-providers branch August 4, 2019 03:52
mwjames added a commit that referenced this pull request Aug 4, 2019
@kghbln kghbln added this to the SMW 3.1.0 milestone Aug 4, 2019
JeroenDeDauw pushed a commit that referenced this pull request Jul 12, 2021
Causes: Premature access to service container
Caused by: https://gerrit.wikimedia.org/r/651539

Drawbacks with the change: Cannot load SMW extensions before
calling enableSemantics. See: #4195
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants