From 2c323de6f4edac797a945cbb8ef798655f830762 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Mon, 30 Mar 2015 13:20:05 -0700 Subject: [PATCH] Add SpecialLog::getLogTypesOnUser() So extensions like Renameuser can get the list without having to re-implement the core list and hook. Bug: T78575 Change-Id: I47a814ff1ba0b50c8ff891fe7f69d18bd46661a6 --- includes/specials/SpecialLog.php | 37 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php index 44a2c343ab..88184f92d5 100644 --- a/includes/specials/SpecialLog.php +++ b/includes/specials/SpecialLog.php @@ -29,17 +29,6 @@ * @ingroup SpecialPage */ class SpecialLog extends SpecialPage { - /** - * List log type for which the target is a user - * Thus if the given target is in NS_MAIN we can alter it to be an NS_USER - * Title user instead. - */ - private $typeOnUser = array( - 'block', - 'newusers', - 'rights', - ); - public function __construct() { parent::__construct( 'Log' ); } @@ -106,8 +95,7 @@ class SpecialLog extends SpecialPage { # Some log types are only for a 'User:' title but we might have been given # only the username instead of the full title 'User:username'. This part try # to lookup for a user by that name and eventually fix user input. See bug 1697. - Hooks::run( 'GetLogTypesOnUser', array( &$this->typeOnUser ) ); - if ( in_array( $opts->getValue( 'type' ), $this->typeOnUser ) ) { + if ( in_array( $opts->getValue( 'type' ), self::getLogTypesOnUser() ) ) { # ok we have a type of log which expect a user title. $target = Title::newFromText( $opts->getValue( 'page' ) ); if ( $target && $target->getNamespace() === NS_MAIN ) { @@ -121,6 +109,29 @@ class SpecialLog extends SpecialPage { $this->show( $opts, $qc ); } + /** + * List log type for which the target is a user + * Thus if the given target is in NS_MAIN we can alter it to be an NS_USER + * Title user instead. + * + * @since 1.25 + * @return array + */ + public static function getLogTypesOnUser() { + static $types = null; + if ( $types !== null ) { + return $types; + } + $types = array( + 'block', + 'newusers', + 'rights', + ); + + Hooks::run( 'GetLogTypesOnUser', array( &$types ) ); + return $types; + } + /** * Return an array of subpages that this special page will accept. * -- 2.20.1