r71882 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71881‎ | r71882 | r71883 >
Date:12:31, 29 August 2010
Author:siebrand
Status:resolved (Comments)
Tags:brion 
Comment:
(bug 24391) Prevent use of Special:ContactPage for blocked users.

Patch contributed by Thomas Shone. Committer updated indentation and variable name.
Modified paths:
  • /trunk/extensions/ContactPage/SpecialContact.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContactPage/SpecialContact.php
@@ -52,6 +52,26 @@
5353 return;
5454 }
5555
 56+ // Blocked users cannot use the contact form.
 57+ if ( $wgUser->isBlocked() ) {
 58+ $wgOut->setPageTitle( wfMsg( 'blockedtitle' ) );
 59+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
 60+ $wgOut->setArticleRelated( false );
 61+
 62+ $ip = wfGetIP();
 63+ $blocker = User::whoIs( $wgUser->mBlock->mBy );
 64+ $blockReason = $wgUser->mBlock->mReason;
 65+
 66+ if ( strval( $blockReason ) === '' ) {
 67+ $blockReason = wfMsg( 'blockednoreason' );
 68+ }
 69+
 70+ $wgOut->addWikiMsg( 'blockedtext', $ip, $blockReason, $blocker );
 71+ $wgOut->returnToMain( false );
 72+
 73+ return;
 74+ }
 75+
5676 $f = new EmailContactForm( $nu );
5777
5878 if ( 'success' == $action ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r71929Only deny use of contact form if sending e-mail is blocked instead of blockin...siebrand06:57, 30 August 2010
r74175Follow-up r71882 and r71929: Fix bug in r71929. Check should be reversed.siebrand23:13, 2 October 2010
r80845ContactPage extension fixes:...brion08:00, 24 January 2011

Comments

#Comment by P858snake (talk | contribs)   23:08, 29 August 2010

Shouldn't this only check if they a blocked from sending emails? Seems pointless to possibly allow them send emails native-ly via the MW system but block them from using the contact form.

#Comment by Platonides (talk | contribs)   23:23, 29 August 2010

I partly agree. If it is a registered user, it should only check that it is not blocked with "don't send emails". If on the other hand it is an anon, it may make sense to block all blocked ips from using it. Although there are legitimate reasons for a blocked ip to use this, so... make this a use of 'block for sending mails' checkbox for ips?.

#Comment by Siebrand (talk | contribs)   23:13, 2 October 2010

So how to proceed?

#Comment by Siebrand (talk | contribs)   14:18, 23 October 2010

As none of the two earlier commenters appear to be interested in this issue any longer, I'm setting it to new. Nothing to be fixed now, apparently.

#Comment by Brion VIBBER (talk | contribs)   07:41, 24 January 2011

Note on correct way to do the block check at r71929

Additionally, the 'you are blocked' output duplicates code in OutputPage::blockedPage(), and is missing parameters which cause bogus output when it is triggered:

User is blocked

Your username or IP address has been blocked.

The block was made by 10.0.1.2. The reason given is no reason given.

  • Start of block: $8
  • Expiry of block: $6
  • Intended blockee: $7

You can contact 10.0.1.2 or another administrator to discuss the block. You cannot use the 'e-mail this user' feature unless a valid e-mail address is specified in your account preferences and you have not been blocked from using it. Your current IP address is , and the block ID is #$5. Please include all above details in any queries you make.

Return to Main Page.

Should probably call $wgOut->blockedPage() directly here and let it worry about the formatting details.

#Comment by Brion VIBBER (talk | contribs)   08:02, 24 January 2011

r80845 fixes both of these; marking resolved.

Status & tagging log