From 167759abab4b767798be57fbf26c33fea42f1245 Mon Sep 17 00:00:00 2001 From: Alex Monk Date: Tue, 26 Apr 2016 17:46:46 +0100 Subject: [PATCH] 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 --- includes/skins/Skin.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 ); -- 2.20.1