Mwalker has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/57658


Change subject: Making Translations work again...
......................................................................

Making Translations work again...

There was some code rot in here. Fixing it up in preperation
for deployment.

Change-Id: Ifd5b8de41269b8f37480462b5d9e79e937217c62
---
M includes/Banner.php
M includes/BannerMessageGroup.php
M includes/CNDatabase.php
M special/SpecialCentralNotice.php
4 files changed, 14 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice 
refs/changes/58/57658/1

diff --git a/includes/Banner.php b/includes/Banner.php
index 6247cbe..56181a4 100644
--- a/includes/Banner.php
+++ b/includes/Banner.php
@@ -504,6 +504,7 @@
        /**
         * Updates any metadata required for banner/translation extension 
integration.
         *
+        * @param array  $pageResult        Return from 
WikiPage->doEditContent()
         * @param string $name              Raw name of banner
         * @param string $body              Body text of banner
         * @param array  $priorityLangs     Languages to emphasize during 
translation
diff --git a/includes/BannerMessageGroup.php b/includes/BannerMessageGroup.php
index c153b13..4e9d31e 100644
--- a/includes/BannerMessageGroup.php
+++ b/includes/BannerMessageGroup.php
@@ -199,8 +199,7 @@
         * @return bool
         */
        public static function registerGroupHook( &$list ) {
-               global $wgCentralDBname;
-               $dbr = wfGetDB( DB_MASTER, array(), $wgCentralDBname );
+               $dbr = CNDatabase::getDb( DB_MASTER ); // Must be explicitly 
master for runs under a jobqueue
 
                // Create the base aggregate group
                $conf = array();
diff --git a/includes/CNDatabase.php b/includes/CNDatabase.php
index 194ac27..9e5e905 100644
--- a/includes/CNDatabase.php
+++ b/includes/CNDatabase.php
@@ -7,20 +7,22 @@
        /**
         * Gets a database object. Will be the master if the user is logged in.
         *
-        * @param string|bool $wiki        Wiki database to connect to, if 
false will be
-        *                                 the Infrastructure DB
-        * @param bool        $forceSlave  If true will force a slave 
connection; otherwise
-        *                                 this will return a master if logged 
in.
+        * @param int|bool    $force   If false will return a DB master/slave 
based on users permissions.
+        *                             Set to DB_MASTER or DB_SLAVE to force 
that type.
+        * @param string|bool $wiki    Wiki database to connect to, if false 
will be the Infrastructure DB
         *
         * @return DatabaseBase
         */
-       public static function getDb( $wiki = false, $forceSlave = false ) {
+       public static function getDb( $force = false, $wiki = false ) {
                global $wgCentralDBname;
                global $wgUser;
 
-               $dbmode = DB_SLAVE;
-               if ( $wgUser->isLoggedIn() && !$forceSlave ) {
+               if ( $wgUser->isAllowed( 'centralnotice-admin' ) ) {
                        $dbmode = DB_MASTER;
+               } elseif ( $force === false ) {
+                       $dbmode = DB_SLAVE;
+               } else {
+                       $dbmode = $force;
                }
 
                $db = ( $wiki === false ) ? $wgCentralDBname : $wiki;
diff --git a/special/SpecialCentralNotice.php b/special/SpecialCentralNotice.php
index 7fcce65..5fc4130 100644
--- a/special/SpecialCentralNotice.php
+++ b/special/SpecialCentralNotice.php
@@ -1104,8 +1104,10 @@
 
                        // Banner
                        $banner = new Banner( $row->tmp_name );
+                       $renderer = new BannerRenderer( $this->getContext(), 
$banner );
                        $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
-                               $banner->previewFieldSet( $this->getContext(), 
true )
+                               $renderer->linkTo() . '<br/>' .
+                               $renderer->previewFieldSet( 
$this->getContext(), true )
                        );
 
                        $htmlOut .= Xml::closeElement( 'tr' );

-- 
To view, visit https://gerrit.wikimedia.org/r/57658
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd5b8de41269b8f37480462b5d9e79e937217c62
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to