Merge "Allow and use type Language instead of string for $lang of doEditSectionLink"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 11 Oct 2018 19:52:13 +0000 (19:52 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 11 Oct 2018 19:52:13 +0000 (19:52 +0000)
1  2 
RELEASE-NOTES-1.32
includes/parser/ParserOutput.php
includes/skins/Skin.php

diff --combined RELEASE-NOTES-1.32
@@@ -344,14 -344,6 +344,14 @@@ because of Phabricator reports
    removed. Use the 'ChangesListSpecialPageStructuredFilters' hook instead.
  * DeferredUpdates::setImmediateMode(), deprecated since 1.29, has been removed.
  * File / MediaHandler::getStreamHeaders(), deprecated since 1.30, was removed.
 +* The hook 'DoEditSectionLink', deprecated since 1.25, has been removed. Use
 +  the hook 'SkinEditSectionLinks' instead.
 +* The hook 'UserGetImplicitGroups', deprecated since 1.25, has been removed.
 +* The global function wfRunHooks, deprecated since 1.25, has now been removed.
 +  Use Hooks::run().
 +* The hook 'UnknownAction', deprecated since 1.19, has now been removed.
 +* The hook 'ParserLimitReport', deprecated since 1.22, has been removed. Use
 +  the hooks 'ParserLimitReportPrepare' and 'ParserLimitReportFormat' instead.
  
  === Deprecations in 1.32 ===
  * HTMLForm::setSubmitProgressive() is deprecated. No need to call it. Submit
    as a string. They should be given as a OOUI\FieldLayout object instead.
    Notably, this affects fields defined in the 'GetPreferences' hook, because
    Special:Preferences uses an OOUI form now. (If possible, don't use 'rawrow'.)
+ * In Skin::doEditSectionLink omitting the parameters $tooltip and $lang is
+   deprecated. For the $lang parameter, types other than Language are
+   deprecated.
  
  === Other changes in 1.32 ===
  * (T198811) The following tables have had their UNIQUE indexes turned into
@@@ -338,7 -338,7 +338,7 @@@ class ParserOutput extends CacheTime 
                                        return $skin->doEditSectionLink( $editsectionPage,
                                                $editsectionSection,
                                                $editsectionContent,
-                                               $wgLang->getCode()
+                                               $wgLang
                                        );
                                },
                                $text
                );
        }
  
 -      // TODO remove this method once old parser cache objects have expired, probably mid-October 2018
 -      public function __wakeup() {
 -              // T203716 remove wrapper that was added by logic in an older version of this class,
 -              // where the wrapper was included in mText. This might sometimes remove a wrapper that's
 -              // genuine content (manually added to a system message), but that will work out OK, see below.
 -              $text = $this->getRawText();
 -              $start = Html::openElement( 'div', [
 -                      'class' => 'mw-parser-output'
 -              ] );
 -              $startLen = strlen( $start );
 -              $end = Html::closeElement( 'div' );
 -              $endPos = strrpos( $text, $end );
 -              $endLen = strlen( $end );
 -              if ( substr( $text, 0, $startLen ) === $start && $endPos !== false
 -                       // if the closing div is followed by real content, bail out of unwrapping
 -                       && preg_match( '/^(?>\s*<!--.*?-->)*\s*$/s', substr( $text, $endPos + $endLen ) )
 -              ) {
 -                      $text = substr( $text, $startLen );
 -                      $text = substr( $text, 0, $endPos - $startLen ) .
 -                                      substr( $text, $endPos - $startLen + $endLen );
 -                      $this->setText( $text );
 -                      // We found a wrapper to remove, so the ParserOutput was probably created by the
 -                      // code path that now contains an addWrapperDivClass( 'mw-parser-output' ) call,
 -                      // but it did not contain it when this object was cached, so we need to fix the
 -                      // wrapper class variable.
 -                      // If this was a message with a manually added wrapper, we are technically wrong about
 -                      // this but we were wrong about the unwrapping as well so it will work out just right,
 -                      // except when this is a normal page view of such a message page, in which case
 -                      // it will be single-wrapped instead of double-wrapped (harmless) or something wants
 -                      // render the message with unwrap=true (in which case the message won't be wrapped even
 -                      // though it should, but the few code paths using unwrap=true only do it for real pages).
 -                      $this->clearWrapperDivClass();
 -                      $this->addWrapperDivClass( 'mw-parser-output' );
 -              }
 -      }
 -
        /**
         * Merges internal metadata such as flags, accessed options, and profiling info
         * from $source into this ParserOutput. This should be used whenever the state of $source
diff --combined includes/skins/Skin.php
@@@ -1610,15 -1610,20 +1610,20 @@@ abstract class Skin extends ContextSour
         * @param string $section The designation of the section being pointed to,
         *   to be included in the link, like "&section=$section"
         * @param string|null $tooltip The tooltip to use for the link: will be escaped
-        *   and wrapped in the 'editsectionhint' message
-        * @param string $lang Language code
+        *   and wrapped in the 'editsectionhint' message.
+        *   Not setting this parameter is deprecated.
+        * @param Language|string $lang Language object or language code string.
+        *   Type string is deprecated. Not setting this parameter is deprecated.
         * @return string HTML to use for edit link
         */
        public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) {
                // HTML generated here should probably have userlangattributes
                // added to it for LTR text on RTL pages
  
-               $lang = wfGetLangObj( $lang );
+               if ( !$lang instanceof Language ) {
+                       wfDeprecated( __METHOD__ . ' with other type than Language for $lang', '1.32' );
+                       $lang = wfGetLangObj( $lang );
+               }
  
                $attribs = [];
                if ( !is_null( $tooltip ) ) {
                );
  
                $result .= '<span class="mw-editsection-bracket">]</span></span>';
 -              // Deprecated, use SkinEditSectionLinks hook instead
 -              Hooks::run(
 -                      'DoEditSectionLink',
 -                      [ $this, $nt, $section, $tooltip, &$result, $lang ],
 -                      '1.25'
 -              );
                return $result;
        }