jenkins-bot has submitted this change and it was merged.

Change subject: Fixing UserProfile for invalid usernames
......................................................................


Fixing UserProfile for invalid usernames

Bug: 55601
Change-Id: I7986aa88ec82d64585ee43f715139f339039e3c5
---
M MobileFrontend.i18n.php
M includes/specials/SpecialUserProfile.php
2 files changed, 25 insertions(+), 5 deletions(-)

Approvals:
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index 7b0957c..deba765 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -313,6 +313,7 @@
        'mobile-frontend-profile-registration' => '$1 has been contributing to 
{{SITENAME}} for {{PLURAL:$2|$2 day|$2 days}} and {{GENDER:$1|has made}} 
{{PLURAL:$3|$3 edit|$3 edits}}.',
        'mobile-frontend-profile-usertalk' => 'View talk page.',
        'mobile-frontend-profile-noargs' => 'Please provide a username to view 
a profile.',
+       'mobile-frontend-profile-nouser' => 'Non-existent or invalid username',
        'mobile-frontend-profile-yours' => 'Visit your profile page.',
        'mobile-frontend-profile-userpage-link' => 'Visit user page.',
        'mobile-frontend-profile-user-desc-1' => '{{GENDER:$1|This user}} is a 
new editor.',
@@ -808,6 +809,10 @@
 
 If the user is logged in, this message is followed by:
 * {{msg-mw|Mobile-frontend-profile-yours}}',
+       'mobile-frontend-profile-nouser' => 'Message shown when the username 
requested is non-existent or invalid.
+
+If the user is logged in, this message is followed by:
+* {{msg-mw|Mobile-frontend-profile-yours}}',
        'mobile-frontend-profile-yours' => 'Label pointing user to their 
profile.
 
 Used if the user is logged in.
diff --git a/includes/specials/SpecialUserProfile.php 
b/includes/specials/SpecialUserProfile.php
index e5d5e94..81e387b 100644
--- a/includes/specials/SpecialUserProfile.php
+++ b/includes/specials/SpecialUserProfile.php
@@ -139,13 +139,27 @@
                $skin->setTemplateVariable( 'specialPageHeader', $heading );
        }
 
-       public function getHtmlNoArg() {
+       // FIXME: Change this into 404 error
+       protected function getHtmlNoArg() {
                $html = Html::element( 'p', array(), $this->msg( 
'mobile-frontend-profile-noargs' ) );
                $user = $this->getUser();
                if ( $user->isLoggedIn() ) {
                        $profileUrl = SpecialPage::getTitleFor( 
$this->getName(), $user->getName() )->getLocalURL();
                        $html .= Html::openElement( 'p', array() );
-                       $html .= Html::element( 'a', array( 'href' => 
$profileUrl ), $this->msg( 'mobile-frontend-profile-yours' ) );
+                       $html .= Html::element( 'a', array( 'href' => 
$profileUrl ), $this->msg( 'mobile-frontend-profile-yours' )->plain() );
+                       $html .= Html::closeElement( 'p', array() );
+               }
+               return $html;
+       }
+
+       // FIXME: Change this into 404 error (and possibly merge with 
getHtmlNoArg)
+       protected function getHtmlNoUser() {
+               $html = Html::element( 'p', array(), $this->msg( 
'mobile-frontend-profile-nouser' ) );
+               $user = $this->getUser();
+               if ( $user->isLoggedIn() ) {
+                       $profileUrl = SpecialPage::getTitleFor( 
$this->getName(), $user->getName() )->getLocalURL();
+                       $html .= Html::openElement( 'p', array() );
+                       $html .= Html::element( 'a', array( 'href' => 
$profileUrl ), $this->msg( 'mobile-frontend-profile-yours' )->plain() );
                        $html .= Html::closeElement( 'p', array() );
                }
                return $html;
@@ -167,8 +181,9 @@
                        $html = $this->getHtmlBetaAlphaOptIn();
                } else if ( $par ) {
                        $this->targetUser = User::newFromName( $par );
-                       // prepare content
-                       if ( $this->targetUser ) {
+                       // Make sure this is a valid registered user
+                       if ( $this->targetUser->getId() ) {
+                               // prepare content
                                $this->userInfo = new MobileUserInfo( 
$this->targetUser );
                                $this->setUserProfileUIElements();
                                $link = Linker::link( 
$this->targetUser->getUserPage(),
@@ -182,7 +197,7 @@
                                        . $link
                                        . Html::closeElement( 'div' );
                        } else {
-                               $html = $this->getHtmlNoArg();
+                               $html = $this->getHtmlNoUser();
                        }
                } else {
                        $html = $this->getHtmlNoArg();

-- 
To view, visit https://gerrit.wikimedia.org/r/89139
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7986aa88ec82d64585ee43f715139f339039e3c5
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to