Mollywhite has submitted this change and it was merged. Change subject: Use the wiki DB for the BookManagerv2DBname. ......................................................................
Use the wiki DB for the BookManagerv2DBname. Previously the DB name was hardcoded in, but this required any wiki to have a DB named "wikidb". Now the extension just gets the name of the wiki's DB when necessary. Change-Id: I919572ea4a0c66e605c8fb7af67f237dfd7f5929 --- M BookManagerv2.php M includes/JsonHooks.php M includes/RemoteSchema.php 3 files changed, 10 insertions(+), 22 deletions(-) Approvals: Mollywhite: Verified; Looks good to me, approved Raylton P. Sousa: Verified; Looks good to me, approved diff --git a/BookManagerv2.php b/BookManagerv2.php index 68324c5..f52f518 100644 --- a/BookManagerv2.php +++ b/BookManagerv2.php @@ -51,12 +51,6 @@ $wgBookManagerv2SchemaApiUri = 'http://meta.wikimedia.org/w/api.php'; /** - * @var bool|string: Value of $wgDBname for the MediaWiki instance housing - * schemas; false if not set. - */ -$wgBookManagerv2DBname = 'wikidb'; - -/** * Takes a string of JSON and formats it for readability. * @param string $json * @return string|null: Formatted JSON or null if input was invalid diff --git a/includes/JsonHooks.php b/includes/JsonHooks.php index 4483402..3322f88 100644 --- a/includes/JsonHooks.php +++ b/includes/JsonHooks.php @@ -30,24 +30,17 @@ * @return bool: Whether hooks and handler were registered. */ static function registerHandlers() { - global $wgHooks, $wgContentHandlers, $wgBookManagerv2DBname, - $wgDBname; + global $wgHooks, $wgContentHandlers; - if ( $wgBookManagerv2DBname === $wgDBname ) { - $wgContentHandlers[ 'JsonBook' ] = - 'JsonBookContentHandler'; + $wgContentHandlers[ 'JsonBook' ] = + 'JsonBookContentHandler'; - #$wgHooks[ 'BeforePageDisplay' ][] = - # 'JsonHooks::onBeforePageDisplay'; - $wgHooks[ 'CanonicalNamespaces' ][] = - 'JsonHooks::onCanonicalNamespaces'; - $wgHooks[ 'EditFilterMerged' ][] = + $wgHooks[ 'CanonicalNamespaces' ][] = + 'JsonHooks::onCanonicalNamespaces'; + $wgHooks[ 'EditFilterMerged' ][] = 'JsonHooks::onEditFilterMerged'; - return true; - } - - return false; + return true; } /** diff --git a/includes/RemoteSchema.php b/includes/RemoteSchema.php index f6bf52b..7359a78 100644 --- a/includes/RemoteSchema.php +++ b/includes/RemoteSchema.php @@ -45,13 +45,14 @@ * @param Http $http (optional) HTTP client */ function __construct( $title, $revision, $cache = NULL, $http = NULL ) { - global $wgBookManagerv2DBname; + $dbr = wfGetDB( DB_SLAVE ); + $BookManagerv2DBName = $dbr->getDBname(); $this->title = $title; $this->revision = $revision; $this->cache = $cache ?: wfGetCache( CACHE_ANYTHING ); $this->http = $http ?: new Http(); - $this->key = "schema:{$wgBookManagerv2DBname}:{$title}:{$revision}"; + $this->key = "schema:{$BookManagerv2DBname}:{$title}:{$revision}"; } /** -- To view, visit https://gerrit.wikimedia.org/r/72638 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I919572ea4a0c66e605c8fb7af67f237dfd7f5929 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/BookManagerv2 Gerrit-Branch: master Gerrit-Owner: Mollywhite <[email protected]> Gerrit-Reviewer: Mollywhite <[email protected]> Gerrit-Reviewer: Raylton P. Sousa <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
