* @return array Array of arrays of the arguments to wfMsg to explain permissions problems.
*/
public function getUserPermissionsErrors( $action, $user, $doExpensiveQueries = true ) {
+ if( !StubObject::isRealObject( $user ) ) {
+ //Since StubObject is always used on globals, we can unstub $wgUser here and set $user = $wgUser
+ global $wgUser;
+ $wgUser->_unstub( '', 5 );
+ $user = $wgUser;
+ }
$errors = $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries );
global $wgContLang;
$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!
- }
+ // Users with 'editprotected' permission can edit protected
+ // pages if protection is not with cascading option turned on.
+ if( $action=='edit' && $user->isAllowed( 'editprotected' ) && !$this->areRestrictionsCascading() ) {
+ // Nothing, user can edit!
} else {
$errors[] = array( 'protectedpagetext', $right );
}
* The restriction array is an array of each type, each of which contains an array of unique groups
*/
public function getCascadeProtectionSources( $get_pages = true ) {
- global $wgEnableCascadingProtection, $wgRestrictionTypes;
+ global $wgRestrictionTypes;
# Define our dimension of restrictions types
$pagerestrictions = array();
foreach( $wgRestrictionTypes as $action )
$pagerestrictions[$action] = array();
- if (!$wgEnableCascadingProtection)
- return array( false, $pagerestrictions );
-
if ( isset( $this->mCascadeSources ) && $get_pages ) {
return array( $this->mCascadeSources, $this->mCascadingRestrictions );
} else if ( isset( $this->mHasCascadingRestrictions ) && !$get_pages ) {
wfProfileIn( __METHOD__ );
- $dbr = wfGetDb( DB_SLAVE );
+ $dbr = wfGetDB( DB_SLAVE );
if ( $this->getNamespace() == NS_IMAGE ) {
$tables = array ('imagelinks', 'page_restrictions');
if ($this->mLatestID !== false)
return $this->mLatestID;
- $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB(DB_MASTER) : wfGetDB(DB_SLAVE);
+ $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
return $this->mLatestID = $db->selectField( 'revision',
"max(rev_id)",
array('rev_page' => $this->getArticleID($flags)),