Merge "Remove 'bot' check before trying the edit stash"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 6 Nov 2015 18:22:20 +0000 (18:22 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 6 Nov 2015 18:22:20 +0000 (18:22 +0000)
includes/htmlform/HTMLForm.php
includes/htmlform/OOUIHTMLForm.php
includes/jobqueue/JobQueueGroup.php
includes/specials/SpecialBrokenRedirects.php
includes/specials/SpecialDoubleRedirects.php

index e51620f..2b9a49a 100644 (file)
@@ -1359,6 +1359,18 @@ class HTMLForm extends ContextSource {
                return $this->mMethod;
        }
 
+       /**
+        * Wraps the given $section into an user-visible fieldset.
+        *
+        * @param string $legend Legend text for the fieldset
+        * @param string $section The section content in plain Html
+        * @param array $attributes Additional attributes for the fieldset
+        * @return string The fieldset's Html
+        */
+       protected function wrapFieldSetSection( $legend, $section, $attributes ) {
+               return Xml::fieldset( $legend, $section, $attributes ) . "\n";
+       }
+
        /**
         * @todo Document
         *
@@ -1425,7 +1437,7 @@ class HTMLForm extends ContextSource {
                                        if ( $fieldsetIDPrefix ) {
                                                $attributes['id'] = Sanitizer::escapeId( "$fieldsetIDPrefix$key" );
                                        }
-                                       $subsectionHtml .= Xml::fieldset( $legend, $section, $attributes ) . "\n";
+                                       $subsectionHtml .= $this->wrapFieldSetSection( $legend, $section, $attributes );
                                } else {
                                        // Just return the inputs, nothing fancy.
                                        $subsectionHtml .= $section;
index d328ecc..3238c2c 100644 (file)
@@ -108,6 +108,29 @@ class OOUIHTMLForm extends HTMLForm {
                return $html;
        }
 
+       protected function wrapFieldSetSection( $legend, $section, $attributes ) {
+               // to get a user visible effect, wrap the fieldset into a framed panel layout
+               $layout = new OOUI\PanelLayout( array(
+                       'expanded' => false,
+                       'padded' => true,
+                       'framed' => true,
+                       'infusable' => false,
+               ) );
+
+               $layout->appendContent(
+                       new OOUI\FieldsetLayout( array(
+                               'label' => $legend,
+                               'infusable' => false,
+                               'items' => array(
+                                       new OOUI\Widget( array(
+                                               'content' => new OOUI\HtmlSnippet( $section )
+                                       ) ),
+                               ),
+                       ) + $attributes )
+               );
+               return $layout;
+       }
+
        /**
         * Put a form section together from the individual fields' HTML, merging it and wrapping.
         * @param OOUI\\FieldLayout[] $fieldsHtml
index 4609d2d..d6247cb 100644 (file)
@@ -381,27 +381,24 @@ class JobQueueGroup {
         * @return mixed
         */
        private function getCachedConfigVar( $name ) {
-               global $wgConf;
-
+               // @TODO: cleanup this whole method with a proper config system
                if ( $this->wiki === wfWikiID() ) {
                        return $GLOBALS[$name]; // common case
                } else {
-                       $cache = ObjectCache::getLocalClusterInstance();
-                       list( $db, $prefix ) = wfSplitWikiID( $this->wiki );
-                       $key = wfForeignMemcKey( $db, $prefix, 'configvalue', $name );
-                       $value = $cache->get( $key ); // ('v' => ...) or false
-                       if ( is_array( $value ) ) {
-                               return $value['v'];
-                       } else {
-                               $value = $wgConf->getConfig( $this->wiki, $name );
-                               $cache->set(
-                                       $key,
-                                       array( 'v' => $value ),
-                                       $cache::TTL_DAY + mt_rand( 0, $cache::TTL_DAY )
-                               );
-
-                               return $value;
-                       }
+                       $wiki = $this->wiki;
+                       $cache = ObjectCache::getMainWANInstance();
+                       $value = $cache->getWithSetCallback(
+                               $cache->makeGlobalKey( 'jobqueue', 'configvalue', $wiki, $name ),
+                               $cache::TTL_DAY + mt_rand( 0, $cache::TTL_DAY ),
+                               function () use ( $wiki, $name ) {
+                                       global $wgConf;
+
+                                       return array( 'v' => $wgConf->getConfig( $wiki, $name ) );
+                               },
+                               array( 'pcTTL' => 30 )
+                       );
+
+                       return $value['v'];
                }
        }
 
index 701f75f..9ea18da 100644 (file)
@@ -121,12 +121,20 @@ class BrokenRedirectsPage extends QueryPage {
                        array( 'redirect' => 'no' )
                );
                $links = array();
-               $links[] = Linker::linkKnown(
-                       $fromObj,
-                       $this->msg( 'brokenredirects-edit' )->escaped(),
-                       array(),
-                       array( 'action' => 'edit' )
-               );
+               // if the page is editable, add an edit link
+               if (
+                       // check user permissions
+                       $this->getUser()->isAllowed( 'edit' ) &&
+                       // check, if the content model is editable through action=edit
+                       ContentHandler::getForTitle( $fromObj )->supportsDirectEditing()
+               ) {
+                       $links[] = Linker::linkKnown(
+                               $fromObj,
+                               $this->msg( 'brokenredirects-edit' )->escaped(),
+                               array(),
+                               array( 'action' => 'edit' )
+                       );
+               }
                $to = Linker::link(
                        $toObj,
                        null,
@@ -147,13 +155,37 @@ class BrokenRedirectsPage extends QueryPage {
                        );
                }
 
-               $out .= $this->msg( 'parentheses' )->rawParams( $this->getLanguage()
-                       ->pipeList( $links ) )->escaped();
+               if ( $links ) {
+                       $out .= $this->msg( 'parentheses' )->rawParams( $this->getLanguage()
+                               ->pipeList( $links ) )->escaped();
+               }
                $out .= " {$arr} {$to}";
 
                return $out;
        }
 
+
+       /**
+        * Cache page content model for performance
+        *
+        * @param IDatabase $db
+        * @param ResultWrapper $res
+        */
+       function preprocessResults( $db, $res ) {
+               if ( !$res->numRows() ) {
+                       return;
+               }
+
+               $batch = new LinkBatch;
+               foreach ( $res as $row ) {
+                       $batch->add( $row->namespace, $row->title );
+               }
+               $batch->execute();
+
+               // Back to start for display
+               $res->seek( 0 );
+       }
+
        protected function getGroupName() {
                return 'maintenance';
        }
index 6d40985..c04582e 100644 (file)
@@ -151,14 +151,24 @@ class DoubleRedirectsPage extends QueryPage {
                        array( 'redirect' => 'no' )
                );
 
-               $edit = Linker::linkKnown(
-                       $titleA,
-                       $this->msg( 'parentheses', $this->msg( 'editlink' )->text() )->escaped(),
-                       array(),
-                       array(
-                               'action' => 'edit'
-                       )
-               );
+               // if the page is editable, add an edit link
+               if (
+                       // check user permissions
+                       $this->getUser()->isAllowed( 'edit' ) &&
+                       // check, if the content model is editable through action=edit
+                       ContentHandler::getForTitle( $titleA )->supportsDirectEditing()
+               ) {
+                       $edit = Linker::linkKnown(
+                               $titleA,
+                               $this->msg( 'parentheses', $this->msg( 'editlink' )->text() )->escaped(),
+                               array(),
+                               array(
+                                       'action' => 'edit'
+                               )
+                       );
+               } else {
+                       $edit = '';
+               }
 
                $linkB = Linker::linkKnown(
                        $titleB,
@@ -175,6 +185,35 @@ class DoubleRedirectsPage extends QueryPage {
                return ( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" );
        }
 
+       /**
+        * Cache page content model and gender distinction for performance
+        *
+        * @param IDatabase $db
+        * @param ResultWrapper $res
+        */
+       function preprocessResults( $db, $res ) {
+               if ( !$res->numRows() ) {
+                       return;
+               }
+
+               $batch = new LinkBatch;
+               foreach ( $res as $row ) {
+                       $batch->add( $row->namespace, $row->title );
+                       if ( isset( $row->nsb ) ) {
+                               // lazy loaded when using cached results
+                               $batch->add( $row->nsb, $row->tb );
+                       }
+                       if ( isset( $row->iwc ) && !$row->iwc ) {
+                               // lazy loaded when using cached result, not added when interwiki link
+                               $batch->add( $row->nsc, $row->tc );
+                       }
+               }
+               $batch->execute();
+
+               // Back to start for display
+               $res->seek( 0 );
+       }
+
        protected function getGroupName() {
                return 'maintenance';
        }