MaxSem has uploaded a new change for review.
https://gerrit.wikimedia.org/r/171987
Change subject: [doesn't work] use wikidata.org in debug mode
......................................................................
[doesn't work] use wikidata.org in debug mode
Change-Id: I9b47fa2a9e54ab9e908e9bf846b6cc920050cdd0
---
M includes/Hooks.php
M includes/QuestionPicker.php
M includes/WikibaseConnector.php
3 files changed, 42 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiGrok
refs/changes/87/171987/1
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 1f808a6..2aa7d56 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -58,6 +58,7 @@
$list = array();
if ( $config->get( 'WikiGrokDebug' ) ) {
+ $campaigns->setDebugMode( true );
$item = $out->getRequest()->getText(
'wikidataid', $item );
$debugCampaigns = $config->get(
'WikiGrokDebugCampaigns' );
if ( isset( $debugCampaigns[$item] ) ) {
diff --git a/includes/QuestionPicker.php b/includes/QuestionPicker.php
index d0fa33d..3d3f5bb 100644
--- a/includes/QuestionPicker.php
+++ b/includes/QuestionPicker.php
@@ -19,6 +19,16 @@
}
/**
+ * Enables or disables debug mode. If it's on, information from
wikidata.org will be used
+ * independently of local configuration.
+ *
+ * @param bool $mode
+ */
+ public function setDebugMode( $mode ) {
+ $this->wikibase->setDebugMode( $mode );
+ }
+
+ /**
* @return \Config
*/
public function getConfig() {
diff --git a/includes/WikibaseConnector.php b/includes/WikibaseConnector.php
index 5ecfb1d..d65c0d2 100644
--- a/includes/WikibaseConnector.php
+++ b/includes/WikibaseConnector.php
@@ -14,13 +14,25 @@
*/
class WikibaseConnector {
private $entityLookup = null;
+ private $debugMode = false;
+
+ /**
+ * Enables or disables debug mode. If it's on, information from
wikidata.org will be used
+ * independently of local configuration.
+ *
+ * @param bool $mode
+ */
+ public function setDebugMode( $mode ) {
+ $this->debugMode = $mode;
+ $this->entityLookup = null;
+ }
/**
* @return \Wikibase\Lib\Store\EntityLookup
*/
public function getEntityLookup() {
if ( !$this->entityLookup ) {
- $this->entityLookup =
WikibaseClient::getDefaultInstance()
+ $this->entityLookup = $this->getClient()
->getStore()
->getEntityLookup();
}
@@ -139,4 +151,22 @@
return $values;
}
+
+ /**
+ * Creates a WikibaseClient instance
+ *
+ * @return WikibaseClient
+ */
+ protected function getClient() {
+ global $wgContLang;
+poo@$%@$#$534
+ if ( $this->debugMode ) {
+ $settings = new \Wikibase\Settings;
+ $settings->initFromGlobals();
+ $settings->setSetting( 'repoUrl', '//www.wikidata.org'
);
+ return new WikibaseClient( $settings, $wgContLang );
+ } else {
+ return WikibaseClient::getDefaultInstance();
+ }
+ }
}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/171987
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b47fa2a9e54ab9e908e9bf846b6cc920050cdd0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikiGrok
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits