Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/268401
Change subject: Helpful exception message when Wikibase Client/Repo not set up
properly
......................................................................
Helpful exception message when Wikibase Client/Repo not set up properly
This is relevant when you are adding (for example) the ArticlePlaceholder
extension to your LocalSettings.php, but you forgot to add
WikibaseClient.php too. Code in article placeholder will call
WikibaseClient::getDefaultInstance(), but this will fail with totally
non-helpful exceptions, because the default config is not loaded.
If you think there is a better way to help the user fix the problem,
please tell me.
Change-Id: I6205b853afa32c29003d36e00e026b898439da3a
---
M client/includes/WikibaseClient.php
M repo/includes/WikibaseRepo.php
2 files changed, 13 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/01/268401/1
diff --git a/client/includes/WikibaseClient.php
b/client/includes/WikibaseClient.php
index 04ea126..50e4a09 100644
--- a/client/includes/WikibaseClient.php
+++ b/client/includes/WikibaseClient.php
@@ -479,11 +479,17 @@
* Returns a new instance constructed from global settings.
* IMPORTANT: Use only when it is not feasible to inject an instance
properly.
*
+ * @throws MWException
* @return WikibaseClient
*/
private static function newInstance() {
global $wgContLang, $wgWBClientSettings, $wgWBClientDataTypes;
+ if ( !is_array( $wgWBClientDataTypes ) ) {
+ throw new MWException( '$wgWBClientDataTypes must be an
array. Maybe you forgot to '
+ . 'require WikibaseClient.php in your
LocalSettings.php?' );
+ }
+
$dataTypeDefinitions = $wgWBClientDataTypes;
Hooks::run( 'WikibaseClientDataTypes', array(
&$dataTypeDefinitions ) );
diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php
index 9a4cf94..64ee6aa 100644
--- a/repo/includes/WikibaseRepo.php
+++ b/repo/includes/WikibaseRepo.php
@@ -12,6 +12,7 @@
use IContextSource;
use Language;
use MediaWiki\Site\MediaWikiPageNameNormalizer;
+use MWException;
use RequestContext;
use Serializers\Serializer;
use SiteSQLStore;
@@ -230,11 +231,17 @@
/**
* IMPORTANT: Use only when it is not feasible to inject an instance
properly.
*
+ * @throws MWException
* @return WikibaseRepo
*/
private static function newInstance() {
global $wgWBRepoDataTypes, $wgWBRepoSettings, $wgContLang;
+ if ( !is_array( $wgWBRepoDataTypes ) ) {
+ throw new MWException( '$wgWBRepoDataTypes must be an
array. Maybe you forgot to '
+ . 'require Wikibase.php in your
LocalSettings.php?' );
+ }
+
$dataTypeDefinitions = $wgWBRepoDataTypes;
Hooks::run( 'WikibaseRepoDataTypes', array(
&$dataTypeDefinitions ) );
--
To view, visit https://gerrit.wikimedia.org/r/268401
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6205b853afa32c29003d36e00e026b898439da3a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits