Merge "Updated pear/net_smtp from 1.8.0 to 1.8.1"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 11 Feb 2019 00:58:25 +0000 (00:58 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 11 Feb 2019 00:58:25 +0000 (00:58 +0000)
includes/Linker.php
maintenance/attachLatest.php
tests/parser/ParserTestPrinter.php
tests/phpunit/includes/media/JpegPixelFormatTest.php

index cc1df39..049fb07 100644 (file)
@@ -114,15 +114,20 @@ class Linker {
                } else {
                        $text = $html; // null
                }
+
                if ( in_array( 'known', $options, true ) ) {
                        return $linkRenderer->makeKnownLink( $target, $text, $customAttribs, $query );
-               } elseif ( in_array( 'broken', $options, true ) ) {
+               }
+
+               if ( in_array( 'broken', $options, true ) ) {
                        return $linkRenderer->makeBrokenLink( $target, $text, $customAttribs, $query );
-               } elseif ( in_array( 'noclasses', $options, true ) ) {
+               }
+
+               if ( in_array( 'noclasses', $options, true ) ) {
                        return $linkRenderer->makePreloadedLink( $target, $text, '', $customAttribs, $query );
-               } else {
-                       return $linkRenderer->makeLink( $target, $text, $customAttribs, $query );
                }
+
+               return $linkRenderer->makeLink( $target, $text, $customAttribs, $query );
        }
 
        /**
@@ -193,9 +198,9 @@ class Linker {
                                        getFormattedNsText( $namespace );
                        }
                        return $context->msg( 'invalidtitle-knownnamespace', $namespace, $name, $title )->text();
-               } else {
-                       return $context->msg( 'invalidtitle-unknownnamespace', $namespace, $title )->text();
                }
+
+               return $context->msg( 'invalidtitle-unknownnamespace', $namespace, $title )->text();
        }
 
        /**
@@ -207,14 +212,12 @@ class Linker {
                if ( $target->getNamespace() == NS_SPECIAL && !$target->isExternal() ) {
                        list( $name, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
                                resolveAlias( $target->getDBkey() );
-                       if ( !$name ) {
-                               return $target;
+                       if ( $name ) {
+                               return SpecialPage::getTitleValueFor( $name, $subpage, $target->getFragment() );
                        }
-                       $ret = SpecialPage::getTitleValueFor( $name, $subpage, $target->getFragment() );
-                       return $ret;
-               } else {
-                       return $target;
                }
+
+               return $target;
        }
 
        /**
@@ -259,7 +262,9 @@ class Linker {
                return Html::element( 'img',
                        [
                                'src' => $url,
-                               'alt' => $alt ] );
+                               'alt' => $alt
+                       ]
+               );
        }
 
        /**
@@ -730,12 +735,15 @@ class Linker {
 
                if ( $wgUploadMissingFileUrl ) {
                        return wfAppendQuery( $wgUploadMissingFileUrl, $q );
-               } elseif ( $wgUploadNavigationUrl ) {
+               }
+
+               if ( $wgUploadNavigationUrl ) {
                        return wfAppendQuery( $wgUploadNavigationUrl, $q );
-               } else {
-                       $upload = SpecialPage::getTitleFor( 'Upload' );
-                       return $upload->getLocalURL( $q );
                }
+
+               $upload = SpecialPage::getTitleFor( 'Upload' );
+
+               return $upload->getLocalURL( $q );
        }
 
        /**
@@ -998,10 +1006,11 @@ class Linker {
        public static function userTalkLink( $userId, $userText ) {
                $userTalkPage = Title::makeTitle( NS_USER_TALK, $userText );
                $moreLinkAttribs['class'] = 'mw-usertoollinks-talk';
-               $userTalkLink = self::link( $userTalkPage,
-                                               wfMessage( 'talkpagelinktext' )->escaped(),
-                                               $moreLinkAttribs );
-               return $userTalkLink;
+
+               return self::link( $userTalkPage,
+                       wfMessage( 'talkpagelinktext' )->escaped(),
+                       $moreLinkAttribs
+               );
        }
 
        /**
@@ -1013,10 +1022,11 @@ class Linker {
        public static function blockLink( $userId, $userText ) {
                $blockPage = SpecialPage::getTitleFor( 'Block', $userText );
                $moreLinkAttribs['class'] = 'mw-usertoollinks-block';
-               $blockLink = self::link( $blockPage,
-                                        wfMessage( 'blocklink' )->escaped(),
-                                        $moreLinkAttribs );
-               return $blockLink;
+
+               return self::link( $blockPage,
+                       wfMessage( 'blocklink' )->escaped(),
+                       $moreLinkAttribs
+               );
        }
 
        /**
@@ -1027,10 +1037,10 @@ class Linker {
        public static function emailLink( $userId, $userText ) {
                $emailPage = SpecialPage::getTitleFor( 'Emailuser', $userText );
                $moreLinkAttribs['class'] = 'mw-usertoollinks-mail';
-               $emailLink = self::link( $emailPage,
-                                        wfMessage( 'emaillink' )->escaped(),
-                                        $moreLinkAttribs );
-               return $emailLink;
+               return self::link( $emailPage,
+                       wfMessage( 'emaillink' )->escaped(),
+                       $moreLinkAttribs
+               );
        }
 
        /**
@@ -1107,9 +1117,7 @@ class Linker {
 
                # Render autocomments and make links:
                $comment = self::formatAutocomments( $comment, $title, $local, $wikiId );
-               $comment = self::formatLinksInComment( $comment, $title, $local, $wikiId );
-
-               return $comment;
+               return self::formatLinksInComment( $comment, $title, $local, $wikiId );
        }
 
        /**
@@ -1166,9 +1174,11 @@ class Linker {
                                                $section = $auto;
                                                # Remove links that a user may have manually put in the autosummary
                                                # This could be improved by copying as much of Parser::stripSectionName as desired.
-                                               $section = str_replace( '[[:', '', $section );
-                                               $section = str_replace( '[[', '', $section );
-                                               $section = str_replace( ']]', '', $section );
+                                               $section = str_replace( [
+                                                       '[[:',
+                                                       '[[',
+                                                       ']]'
+                                               ], '', $section );
 
                                                // We don't want any links in the auto text to be linked, but we still
                                                // want to show any [[ ]]
@@ -1679,12 +1689,10 @@ class Linker {
                        $fallbackAnchor = htmlspecialchars( $fallbackAnchor );
                        $fallback = "<span id=\"$fallbackAnchor\"></span>";
                }
-               $ret = "<h$level$attribs"
+               return "<h$level$attribs"
                        . "$fallback<span class=\"mw-headline\" id=\"$anchorEscaped\">$html</span>"
                        . $link
                        . "</h$level>";
-
-               return $ret;
        }
 
        /**
@@ -1888,11 +1896,11 @@ class Linker {
                                $html = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
                        }
 
-                       return self::link( $title, $html, $attrs, $query, $options );
-               } else {
-                       $html = $context->msg( 'rollbacklink' )->escaped();
                        return self::link( $title, $html, $attrs, $query, $options );
                }
+
+               $html = $context->msg( 'rollbacklink' )->escaped();
+               return self::link( $title, $html, $attrs, $query, $options );
        }
 
        /**
index 897972c..4da0901 100644 (file)
@@ -24,6 +24,8 @@
  * @ingroup Maintenance
  */
 
+use MediaWiki\MediaWikiServices;
+
 require_once __DIR__ . '/Maintenance.php';
 
 /**
@@ -53,6 +55,7 @@ class AttachLatest extends Maintenance {
                        $conds,
                        __METHOD__ );
 
+               $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
                $n = 0;
                foreach ( $result as $row ) {
                        $pageId = intval( $row->page_id );
@@ -78,6 +81,7 @@ class AttachLatest extends Maintenance {
                        if ( $this->hasOption( 'fix' ) ) {
                                $page = WikiPage::factory( $title );
                                $page->updateRevisionOn( $dbw, $revision );
+                               $lbFactory->waitForReplication();
                        }
                        $n++;
                }
index 94d226c..fddee3d 100644 (file)
@@ -19,6 +19,8 @@
  * @ingroup Testing
  */
 
+use MediaWiki\Shell\Shell;
+
 /**
  * This is a TestRecorder responsible for printing information about progress,
  * success and failure to the console. It is specific to the parserTests.php
@@ -176,9 +178,6 @@ class ParserTestPrinter extends TestRecorder {
                $outfile = "$prefix-$outFileTail";
                $this->dumpToFile( $output, $outfile );
 
-               $shellInfile = wfEscapeShellArg( $infile );
-               $shellOutfile = wfEscapeShellArg( $outfile );
-
                global $wgDiff3;
                // we assume that people with diff3 also have usual diff
                if ( $this->useDwdiff ) {
@@ -187,7 +186,11 @@ class ParserTestPrinter extends TestRecorder {
                        $shellCommand = ( wfIsWindows() && !$wgDiff3 ) ? 'fc' : 'diff -au';
                }
 
-               $diff = wfShellExec( "$shellCommand $shellInfile $shellOutfile" );
+               $result = Shell::command()
+                       ->unsafeParams( $shellCommand )
+                       ->params( $infile, $outfile )
+                       ->execute();
+               $diff = $result->getStdout();
 
                unlink( $infile );
                unlink( $outfile );
index c0a3e90..630df54 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\Shell\Shell;
+
 /**
  * Tests related to JPEG chroma subsampling via $wgJpegPixelFormat setting.
  *
@@ -46,21 +49,21 @@ class JpegPixelFormatTest extends MediaWikiMediaTestCase {
                $path = $thumb->getLocalCopyPath();
                $this->assertTrue( is_string( $path ), "path returned for JPEG thumbnail for $fmtStr" );
 
-               $cmd = [
-                       'identify',
+               $result = Shell::command( 'identify',
                        '-format',
                        '%[jpeg:sampling-factor]',
                        $path
-               ];
-               $retval = null;
-               $output = wfShellExec( $cmd, $retval );
-               $this->assertTrue( $retval === 0, "ImageMagick's identify command should return success" );
+               )->execute();
+               $this->assertEquals( 0,
+                       $result->getExitCode(),
+                       "ImageMagick's identify command should return success"
+               );
 
                $expected = $samplingFactor;
-               $actual = trim( $output );
+               $actual = trim( $result->getStdout() );
                $this->assertEquals(
                        $expected,
-                       trim( $output ),
+                       $actual,
                        "IM identify expects JPEG chroma subsampling \"$expected\" for $fmtStr"
                );
        }