r45488 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45487‎ | r45488 | r45489 >
Date:04:31, 7 January 2009
Author:brion
Status:ok
Tags:
Comment:
Pull back r45367 "(bug 12458) Protected page titles should show only one protection notice"
This code seems messy and looks wrong; it looks like it won't take various protections into account.
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1117,9 +1117,7 @@
11181118 else if( $result === false )
11191119 $errors[] = array('badaccess-group0'); # a generic "We don't want them to do that"
11201120 }
1121 - if( $doExpensiveQueries && !wfRunHooks( 'getUserPermissionsErrorsExpensive',
1122 - array(&$this,&$user,$action,&$result) ) )
1123 - {
 1121+ if( $doExpensiveQueries && !wfRunHooks( 'getUserPermissionsErrorsExpensive', array(&$this,&$user,$action,&$result) ) ) {
11241122 if( is_array($result) && count($result) && !is_array($result[0]) )
11251123 $errors[] = $result; # A single array representing an error
11261124 else if( is_array($result) && is_array($result[0]) )
@@ -1145,8 +1143,7 @@
11461144
11471145 # protect css/js subpages of user pages
11481146 # XXX: this might be better using restrictions
1149 - # XXX: Find a way to work around the php bug that prevents using
1150 - # $this->userCanEditCssJsSubpage() from working
 1147+ # XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssJsSubpage() from working
11511148 if( $this->isCssJsSubpage() && !$user->isAllowed('editusercssjs')
11521149 && !preg_match('/^'.preg_quote($user->getName(), '/').'\//', $this->mTextform) )
11531150 {
@@ -1168,41 +1165,39 @@
11691166 $right = ( $right == 'sysop' ) ? 'protect' : $right;
11701167 if( '' != $right && !$user->isAllowed( $right ) ) {
11711168 $pages = '';
1172 - foreach( $cascadingSources as $page ) {
 1169+ foreach( $cascadingSources as $page )
11731170 $pages .= '* [[:' . $page->getPrefixedText() . "]]\n";
1174 - }
11751171 $errors[] = array( 'cascadeprotected', count( $cascadingSources ), $pages );
11761172 }
11771173 }
11781174 }
11791175 }
11801176
1181 - # Get restrictions on each action, 'create' handled below
1182 - if( $action != 'create' ) {
1183 - foreach( $this->getRestrictions($action) as $right ) {
1184 - // Backwards compatibility, rewrite sysop -> protect
1185 - if( $right == 'sysop' ) {
1186 - $right = 'protect';
1187 - }
1188 - if( '' != $right && !$user->isAllowed( $right ) ) {
1189 - // Users with 'editprotected' permission can edit protected pages
1190 - if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) {
1191 - // Users with 'editprotected' permission cannot edit protected pages
1192 - // with cascading option turned on.
1193 - if( $this->mCascadeRestriction ) {
1194 - $errors[] = array( 'protectedpagetext', $right );
1195 - } else {
1196 - // Nothing, user can edit!
1197 - }
1198 - } else {
 1177+ foreach( $this->getRestrictions($action) as $right ) {
 1178+ // Backwards compatibility, rewrite sysop -> protect
 1179+ if( $right == 'sysop' ) {
 1180+ $right = 'protect';
 1181+ }
 1182+ if( '' != $right && !$user->isAllowed( $right ) ) {
 1183+ // Users with 'editprotected' permission can edit protected pages
 1184+ if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) {
 1185+ // Users with 'editprotected' permission cannot edit protected pages
 1186+ // with cascading option turned on.
 1187+ if( $this->mCascadeRestriction ) {
11991188 $errors[] = array( 'protectedpagetext', $right );
 1189+ } else {
 1190+ // Nothing, user can edit!
12001191 }
 1192+ } else {
 1193+ $errors[] = array( 'protectedpagetext', $right );
12011194 }
12021195 }
12031196 }
12041197
1205 - if( $action == 'protect' && $this->getUserPermissionsErrors('edit',$user) != array() ) {
1206 - $errors[] = array( 'protect-cantedit' ); // If they can't edit, they shouldn't protect.
 1198+ if( $action == 'protect' ) {
 1199+ if( $this->getUserPermissionsErrors('edit', $user) != array() ) {
 1200+ $errors[] = array( 'protect-cantedit' ); // If they can't edit, they shouldn't protect.
 1201+ }
12071202 }
12081203
12091204 if( $action == 'create' ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r45367(bug 12458) Protected page titles should show only one protection noticeaaron13:28, 3 January 2009

Status & tagging log