diff --git a/includes/skins/SkinUserPageHelper.php b/includes/skins/SkinUserPageHelper.php index 7da2360..30f1d23 100644 --- a/includes/skins/SkinUserPageHelper.php +++ b/includes/skins/SkinUserPageHelper.php @@ -25,7 +25,7 @@ use User; class SkinUserPageHelper { /** - * @var Title + * @var Title|null */ private $title; /** @@ -39,9 +39,9 @@ class SkinUserPageHelper { private $pageUser; /** - * @param Title $title + * @param Title|null $title */ - public function __construct( Title $title ) { + public function __construct( Title $title = null ) { $this->title = $title; } @@ -51,7 +51,8 @@ class SkinUserPageHelper { */ private function fetchData() { if ( $this->fetchedData === false ) { - if ( $this->title->inNamespace( NS_USER ) && !$this->title->isSubpage() ) { + if ( $this->title && $this->title->inNamespace( NS_USER ) && !$this->title->isSubpage() + ) { $this->pageUser = $this->buildPageUserObject( $this->title ); } $this->fetchedData = true; diff --git a/tests/phpunit/skins/SkinUserPageHelperTest.php b/tests/phpunit/skins/SkinUserPageHelperTest.php index 778085c..6fd584c 100644 --- a/tests/phpunit/skins/SkinUserPageHelperTest.php +++ b/tests/phpunit/skins/SkinUserPageHelperTest.php @@ -24,6 +24,19 @@ class SkinUserPageHelperTest extends MediaWikiTestCase { $this->assertEquals( false, $helper->isUserPage() ); } + /** + * @covers ::isUserPage + * @covers ::fetchData + * @covers ::__construct + */ + public function testTitleIsNull() { + $title = null; + + $helper = new SkinUserPageHelper( $title ); + $this->assertEquals( null, $helper->getPageUser() ); + $this->assertEquals( false, $helper->isUserPage() ); + } + /** * @covers ::isUserPage * @covers ::fetchData