From 3f433ae4cab4c2d0461ab7774d9fa1aa81953ddb Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 7 Jan 2009 04:31:06 +0000 Subject: [PATCH] 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. --- includes/Title.php | 49 +++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 179bc66753..515a3b6501 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1117,9 +1117,7 @@ class Title { else if( $result === false ) $errors[] = array('badaccess-group0'); # a generic "We don't want them to do that" } - if( $doExpensiveQueries && !wfRunHooks( 'getUserPermissionsErrorsExpensive', - array(&$this,&$user,$action,&$result) ) ) - { + if( $doExpensiveQueries && !wfRunHooks( 'getUserPermissionsErrorsExpensive', array(&$this,&$user,$action,&$result) ) ) { if( is_array($result) && count($result) && !is_array($result[0]) ) $errors[] = $result; # A single array representing an error else if( is_array($result) && is_array($result[0]) ) @@ -1145,8 +1143,7 @@ class Title { # protect css/js subpages of user pages # XXX: this might be better using restrictions - # XXX: Find a way to work around the php bug that prevents using - # $this->userCanEditCssJsSubpage() from working + # XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssJsSubpage() from working if( $this->isCssJsSubpage() && !$user->isAllowed('editusercssjs') && !preg_match('/^'.preg_quote($user->getName(), '/').'\//', $this->mTextform) ) { @@ -1168,41 +1165,39 @@ class Title { $right = ( $right == 'sysop' ) ? 'protect' : $right; if( '' != $right && !$user->isAllowed( $right ) ) { $pages = ''; - foreach( $cascadingSources as $page ) { + foreach( $cascadingSources as $page ) $pages .= '* [[:' . $page->getPrefixedText() . "]]\n"; - } $errors[] = array( 'cascadeprotected', count( $cascadingSources ), $pages ); } } } } - # Get restrictions on each action, 'create' handled below - if( $action != 'create' ) { - foreach( $this->getRestrictions($action) as $right ) { - // Backwards compatibility, rewrite sysop -> protect - if( $right == 'sysop' ) { - $right = 'protect'; - } - if( '' != $right && !$user->isAllowed( $right ) ) { - // Users with 'editprotected' permission can edit protected pages - if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) { - // Users with 'editprotected' permission cannot edit protected pages - // with cascading option turned on. - if( $this->mCascadeRestriction ) { - $errors[] = array( 'protectedpagetext', $right ); - } else { - // Nothing, user can edit! - } - } else { + foreach( $this->getRestrictions($action) as $right ) { + // Backwards compatibility, rewrite sysop -> protect + if( $right == 'sysop' ) { + $right = 'protect'; + } + if( '' != $right && !$user->isAllowed( $right ) ) { + // Users with 'editprotected' permission can edit protected pages + if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) { + // Users with 'editprotected' permission cannot edit protected pages + // with cascading option turned on. + if( $this->mCascadeRestriction ) { $errors[] = array( 'protectedpagetext', $right ); + } else { + // Nothing, user can edit! } + } else { + $errors[] = array( 'protectedpagetext', $right ); } } } - if( $action == 'protect' && $this->getUserPermissionsErrors('edit',$user) != array() ) { - $errors[] = array( 'protect-cantedit' ); // If they can't edit, they shouldn't protect. + if( $action == 'protect' ) { + if( $this->getUserPermissionsErrors('edit', $user) != array() ) { + $errors[] = array( 'protect-cantedit' ); // If they can't edit, they shouldn't protect. + } } if( $action == 'create' ) { -- 2.20.1