From: Alex Monk Date: Tue, 26 Apr 2016 16:46:46 +0000 (+0100) Subject: Allow specifying OutputPage object in Skin::subPageSubtitle parameters X-Git-Tag: 1.31.0-rc.0~6495^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22config_fonctions%22%2C%20%22image_process=%24process%22%29%20.%20%22?a=commitdiff_plain;h=167759abab4b767798be57fbf26c33fea42f1245;p=lhc%2Fweb%2Fwiklou.git Allow specifying OutputPage object in Skin::subPageSubtitle parameters To avoid ending up with API callers like this: https://gerrit.wikimedia.org/r/#/c/281463/1/ApiVisualEditorEdit.php Bug: T97700 Change-Id: Id27380de9577ad54cb2580b76a4f236e8dd491dd --- diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index fa46a460e7..729f56451b 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -646,18 +646,22 @@ abstract class Skin extends ContextSource { } /** + * @param OutputPage $out Defaults to $this->getOutput() if left as null * @return string */ - function subPageSubtitle() { - $out = $this->getOutput(); + function subPageSubtitle( $out = null ) { + if ( $out === null ) { + $out = $this->getOutput(); + } + $title = $out->getTitle(); $subpages = ''; if ( !Hooks::run( 'SkinSubPageSubtitle', [ &$subpages, $this, $out ] ) ) { return $subpages; } - if ( $out->isArticle() && MWNamespace::hasSubpages( $out->getTitle()->getNamespace() ) ) { - $ptext = $this->getTitle()->getPrefixedText(); + if ( $out->isArticle() && MWNamespace::hasSubpages( $title->getNamespace() ) ) { + $ptext = $title->getPrefixedText(); if ( strpos( $ptext, '/' ) !== false ) { $links = explode( '/', $ptext ); array_pop( $links );