Merge "Linker: Deprecate formatSize()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 15 Sep 2016 20:18:46 +0000 (20:18 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 15 Sep 2016 20:18:46 +0000 (20:18 +0000)
1  2 
RELEASE-NOTES-1.28
includes/DummyLinker.php
includes/Linker.php

diff --combined RELEASE-NOTES-1.28
@@@ -54,12 -54,6 +54,12 @@@ production
  * mw.Api has a new option, useUS, to use U+001F (Unit Separator) when
    appropriate for sending multi-valued parameters. This defaults to true when
    the mw.Api instance seems to be for the local wiki.
 +* After a client performs an action which alters a database that has replica databases,
 +  MediaWiki will wait for the replica databases to synchronize with the master database
 +  while it renders the HTML output. However, if the output is a redirect to another wiki
 +  on the wiki farm with a different domain, MediaWiki will instead alter the redirect
 +  URL to include a ?cpPosTime parameter that triggers the database synchronization when
 +  the URL is followed by the client. The same-domain case uses a new cpPosTime cookie.
  
  === External library changes in 1.28 ===
  
@@@ -144,6 -138,7 +144,7 @@@ changes to languages because of Phabric
    MediaWiki\Linker\LinkRenderer. In addition, the LinkBegin and LinkEnd hooks
    were replaced by HtmlPageLinkRendererBegin and HtmlPageLinkRendererEnd
    respectively. See docs/hooks.txt for the specific changes needed for those hooks.
+ * Linker::formatSize() was deprecated. Use Language::formatSize() directly.
  * Aliases for Linker methods, deprecated since 1.21, were removed from Skin:
    * Skin::commentBlock() (use Linker::commentBlock() instead)
    * Skin::generateRollback() (use Linker::generateRollback() instead)
  * OOjs UI PHP widgets constructed with the `'infusable' => true` config option
    will no longer be automatically infused. You should call `OO.ui.infuse()`
    on them yourself from your JavaScript code.
 +* parserTests.php has moved to tests/parser/parserTests.php
 +* The command line options specific to parser tests have been removed from
 +  phpunit.php: --regex and --keep-uploads. Instead of --regex, use --filter.
 +  Instead of --keep-uploads, use the same option to parserTests.php, but you
 +  must specify a directory with --upload-dir.
  
  == Compatibility ==
  
diff --combined includes/DummyLinker.php
@@@ -453,17 -453,12 +453,17 @@@ class DummyLinker 
                );
        }
  
 +      /**
 +       * @deprecated since 1.28, use TemplatesOnThisPageFormatter directly
 +       */
        public function formatTemplates(
                $templates,
                $preview = false,
                $section = false,
                $more = null
        ) {
 +              wfDeprecated( __METHOD__, '1.28' );
 +
                return Linker::formatTemplates(
                        $templates,
                        $preview,
                return Linker::formatHiddenCategories( $hiddencats );
        }
  
+       /**
+        * @deprecated since 1.28, use Language::formatSize() directly
+        */
        public function formatSize( $size ) {
+               wfDeprecated( __METHOD__, '1.28' );
                return Linker::formatSize( $size );
        }
  
diff --combined includes/Linker.php
@@@ -1919,8 -1919,6 +1919,8 @@@ class Linker 
        }
  
        /**
 +       * @deprecated since 1.28, use TemplatesOnThisPageFormatter directly
 +       *
         * Returns HTML for the "templates used on this page" list.
         *
         * Make an HTML list of templates, and then add a "More..." link at
        public static function formatTemplates( $templates, $preview = false,
                $section = false, $more = null
        ) {
 -              global $wgLang;
 -
 -              $outText = '';
 -              if ( count( $templates ) > 0 ) {
 -                      # Do a batch existence check
 -                      $batch = new LinkBatch;
 -                      foreach ( $templates as $title ) {
 -                              $batch->addObj( $title );
 -                      }
 -                      $batch->execute();
 -
 -                      # Construct the HTML
 -                      $outText = '<div class="mw-templatesUsedExplanation">';
 -                      if ( $preview ) {
 -                              $outText .= wfMessage( 'templatesusedpreview' )->numParams( count( $templates ) )
 -                                      ->parseAsBlock();
 -                      } elseif ( $section ) {
 -                              $outText .= wfMessage( 'templatesusedsection' )->numParams( count( $templates ) )
 -                                      ->parseAsBlock();
 -                      } else {
 -                              $outText .= wfMessage( 'templatesused' )->numParams( count( $templates ) )
 -                                      ->parseAsBlock();
 -                      }
 -                      $outText .= "</div><ul>\n";
 -
 -                      usort( $templates, 'Title::compare' );
 -                      foreach ( $templates as $titleObj ) {
 -                              $protected = '';
 -                              $restrictions = $titleObj->getRestrictions( 'edit' );
 -                              if ( $restrictions ) {
 -                                      // Check backwards-compatible messages
 -                                      $msg = null;
 -                                      if ( $restrictions === [ 'sysop' ] ) {
 -                                              $msg = wfMessage( 'template-protected' );
 -                                      } elseif ( $restrictions === [ 'autoconfirmed' ] ) {
 -                                              $msg = wfMessage( 'template-semiprotected' );
 -                                      }
 -                                      if ( $msg && !$msg->isDisabled() ) {
 -                                              $protected = $msg->parse();
 -                                      } else {
 -                                              // Construct the message from restriction-level-*
 -                                              // e.g. restriction-level-sysop, restriction-level-autoconfirmed
 -                                              $msgs = [];
 -                                              foreach ( $restrictions as $r ) {
 -                                                      $msgs[] = wfMessage( "restriction-level-$r" )->parse();
 -                                              }
 -                                              $protected = wfMessage( 'parentheses' )
 -                                                      ->rawParams( $wgLang->commaList( $msgs ) )->escaped();
 -                                      }
 -                              }
 -                              if ( $titleObj->quickUserCan( 'edit' ) ) {
 -                                      $editLink = self::link(
 -                                              $titleObj,
 -                                              wfMessage( 'editlink' )->escaped(),
 -                                              [],
 -                                              [ 'action' => 'edit' ]
 -                                      );
 -                              } else {
 -                                      $editLink = self::link(
 -                                              $titleObj,
 -                                              wfMessage( 'viewsourcelink' )->escaped(),
 -                                              [],
 -                                              [ 'action' => 'edit' ]
 -                                      );
 -                              }
 -                              $outText .= '<li>' . self::link( $titleObj )
 -                                      . wfMessage( 'word-separator' )->escaped()
 -                                      . wfMessage( 'parentheses' )->rawParams( $editLink )->escaped()
 -                                      . wfMessage( 'word-separator' )->escaped()
 -                                      . $protected . '</li>';
 -                      }
 +              wfDeprecated( __METHOD__, '1.28' );
  
 -                      if ( $more instanceof Title ) {
 -                              $outText .= '<li>' . self::link( $more, wfMessage( 'moredotdotdot' ) ) . '</li>';
 -                      } elseif ( $more ) {
 -                              $outText .= "<li>$more</li>";
 -                      }
 +              $type = false;
 +              if ( $preview ) {
 +                      $type = 'preview';
 +              } elseif ( $section ) {
 +                      $type = 'section';
 +              }
  
 -                      $outText .= '</ul>';
 +              if ( $more instanceof Message ) {
 +                      $more = $more->toString();
                }
 -              return $outText;
 +
 +              $formatter = new TemplatesOnThisPageFormatter(
 +                      RequestContext::getMain(),
 +                      MediaWikiServices::getInstance()->getLinkRenderer()
 +              );
 +              return $formatter->format( $templates, $type, $more );
        }
  
        /**
        }
  
        /**
+        * @deprecated since 1.28, use Language::formatSize() directly
+        *
         * Format a size in bytes for output, using an appropriate
         * unit (B, KB, MB or GB) according to the magnitude in question
         *
         * @return string
         */
        public static function formatSize( $size ) {
+               wfDeprecated( __METHOD__, '1.28' );
                global $wgLang;
                return htmlspecialchars( $wgLang->formatSize( $size ) );
        }