r45367 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45366‎ | r45367 | r45368 >
Date:13:28, 3 January 2009
Author:aaron
Status:reverted (Comments)
Tags:
Comment:
(bug 12458) Protected page titles should show only one protection notice
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1113,7 +1113,9 @@
11141114 else if( $result === false )
11151115 $errors[] = array('badaccess-group0'); # a generic "We don't want them to do that"
11161116 }
1117 - if( $doExpensiveQueries && !wfRunHooks( 'getUserPermissionsErrorsExpensive', array(&$this,&$user,$action,&$result) ) ) {
 1117+ if( $doExpensiveQueries && !wfRunHooks( 'getUserPermissionsErrorsExpensive',
 1118+ array(&$this,&$user,$action,&$result) ) )
 1119+ {
11181120 if( is_array($result) && count($result) && !is_array($result[0]) )
11191121 $errors[] = $result; # A single array representing an error
11201122 else if( is_array($result) && is_array($result[0]) )
@@ -1139,7 +1141,8 @@
11401142
11411143 # protect css/js subpages of user pages
11421144 # XXX: this might be better using restrictions
1143 - # XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssJsSubpage() from working
 1145+ # XXX: Find a way to work around the php bug that prevents using
 1146+ # $this->userCanEditCssJsSubpage() from working
11441147 if( $this->isCssJsSubpage() && !$user->isAllowed('editusercssjs')
11451148 && !preg_match('/^'.preg_quote($user->getName(), '/').'\//', $this->mTextform) )
11461149 {
@@ -1161,39 +1164,41 @@
11621165 $right = ( $right == 'sysop' ) ? 'protect' : $right;
11631166 if( '' != $right && !$user->isAllowed( $right ) ) {
11641167 $pages = '';
1165 - foreach( $cascadingSources as $page )
 1168+ foreach( $cascadingSources as $page ) {
11661169 $pages .= '* [[:' . $page->getPrefixedText() . "]]\n";
 1170+ }
11671171 $errors[] = array( 'cascadeprotected', count( $cascadingSources ), $pages );
11681172 }
11691173 }
11701174 }
11711175 }
11721176
1173 - foreach( $this->getRestrictions($action) as $right ) {
1174 - // Backwards compatibility, rewrite sysop -> protect
1175 - if( $right == 'sysop' ) {
1176 - $right = 'protect';
1177 - }
1178 - if( '' != $right && !$user->isAllowed( $right ) ) {
1179 - // Users with 'editprotected' permission can edit protected pages
1180 - if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) {
1181 - // Users with 'editprotected' permission cannot edit protected pages
1182 - // with cascading option turned on.
1183 - if( $this->mCascadeRestriction ) {
 1177+ # Get restrictions on each action, 'create' handled below
 1178+ if( $action != 'create' ) {
 1179+ foreach( $this->getRestrictions($action) as $right ) {
 1180+ // Backwards compatibility, rewrite sysop -> protect
 1181+ if( $right == 'sysop' ) {
 1182+ $right = 'protect';
 1183+ }
 1184+ if( '' != $right && !$user->isAllowed( $right ) ) {
 1185+ // Users with 'editprotected' permission can edit protected pages
 1186+ if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) {
 1187+ // Users with 'editprotected' permission cannot edit protected pages
 1188+ // with cascading option turned on.
 1189+ if( $this->mCascadeRestriction ) {
 1190+ $errors[] = array( 'protectedpagetext', $right );
 1191+ } else {
 1192+ // Nothing, user can edit!
 1193+ }
 1194+ } else {
11841195 $errors[] = array( 'protectedpagetext', $right );
1185 - } else {
1186 - // Nothing, user can edit!
11871196 }
1188 - } else {
1189 - $errors[] = array( 'protectedpagetext', $right );
11901197 }
11911198 }
11921199 }
11931200
1194 - if( $action == 'protect' ) {
1195 - if( $this->getUserPermissionsErrors('edit', $user) != array() ) {
1196 - $errors[] = array( 'protect-cantedit' ); // If they can't edit, they shouldn't protect.
1197 - }
 1201+ if( $action == 'protect' && $this->getUserPermissionsErrors('edit',$user) != array() ) {
 1202+ $errors[] = array( 'protect-cantedit' ); // If they can't edit, they shouldn't protect.
11981203 }
11991204
12001205 if( $action == 'create' ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r45488Pull back r45367 "(bug 12458) Protected page titles should show only one prot...brion04:31, 7 January 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   02:05, 7 January 2009

This just looks wrong... won't this now fail to bring up the regular protection notices when there's not a title protection thingy?

I hate the logic in here, it's all illegible. :P

#Comment by Brion VIBBER (talk | contribs)   04:31, 7 January 2009

Reverted for now in r45488

Status & tagging log