Phuedx has uploaded a new change for review.
https://gerrit.wikimedia.org/r/301104
Change subject: [Hygiene] Extend SkinMinerva#isAllowedPageAction
......................................................................
[Hygiene] Extend SkinMinerva#isAllowedPageAction
Move the user page related check from #preparePageActions to
#isAllowedPageAction to tidy up the former even further.
Bug: T140260
Change-Id: Idd20a2e28eb454a2dbaf57f0da4c41e2cbd3cfe6
---
M includes/skins/SkinMinerva.php
M tests/phpunit/skins/SkinMinervaPageActionsTest.php
2 files changed, 20 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/04/301104/1
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 4f5ea67..ee8a67c 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -140,9 +140,12 @@
* @return boolean
*/
protected function isAllowedPageAction( $action ) {
+ $title = $this->getTitle();
+
if (
! in_array( $action, $this->getMFConfig()->get(
'MinervaPageActions' ) )
- || $this->getTitle()->isMainPage()
+ || $title->isMainPage()
+ || ( $this->isUserPage && !$title->exists() )
) {
return false;
}
@@ -877,16 +880,7 @@
* @param BaseTemplate $tpl
*/
protected function preparePageActions( BaseTemplate $tpl ) {
- $title = $this->getTitle();
- // Reuse template data variable from SkinTemplate to construct
page menu
$menu = [];
-
- if ( $this->isUserPage ) {
- if ( !$this->getTitle()->exists() ) {
- $tpl->set( 'page_actions', $menu );
- return;
- }
- }
if ( $this->isAllowedPageAction( 'edit' ) ) {
$menu['edit'] = $this->createEditPageAction();
diff --git a/tests/phpunit/skins/SkinMinervaPageActionsTest.php
b/tests/phpunit/skins/SkinMinervaPageActionsTest.php
index f3826b5..cb8f0fe 100644
--- a/tests/phpunit/skins/SkinMinervaPageActionsTest.php
+++ b/tests/phpunit/skins/SkinMinervaPageActionsTest.php
@@ -103,4 +103,20 @@
$this->assertEquals( $expected,
$this->skin->isAllowedPageAction( 'edit' ) );
}
+
+ /**
+ * @covers SkinMinerva::isAllowedPageAction
+ */
+ public function test_page_actions_when_on_user_pages() {
+ $this->skin->isUserPage = true;
+
+ $this->assertFalse(
+ $this->skin->isAllowedPageAction( 'talk' ),
+ "No page actions are allowed when on a existing user's
page that hasn't been created yet."
+ );
+
+ $skin = $this->getSkin( Title::newFromText( 'User:Admin' ) );
+
+ $this->assertTrue( $skin->isAllowedPageAction( 'talk' ) );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/301104
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idd20a2e28eb454a2dbaf57f0da4c41e2cbd3cfe6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Phuedx <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits