From: Andrew Garrett Date: Sat, 13 Jan 2007 02:37:02 +0000 (+0000) Subject: Possibly partial patch to make userCanEdit avoid running cascade-protection queries... X-Git-Tag: 1.31.0-rc.0~54438 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/fiche.php?a=commitdiff_plain;h=78eb71793d05771693ee4e6c36e4f64cf08dfc80;p=lhc%2Fweb%2Fwiklou.git Possibly partial patch to make userCanEdit avoid running cascade-protection queries on page-view. --- diff --git a/includes/Parser.php b/includes/Parser.php index ff1b757cea..3a9db6d933 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -3395,7 +3395,7 @@ class Parser global $wgMaxTocLevel, $wgContLang; $doNumberHeadings = $this->mOptions->getNumberHeadings(); - if( !$this->mTitle->userCanEdit() ) { + if( !$this->mTitle->quickUserCanEdit() ) { $showEditLink = 0; } else { $showEditLink = $this->mOptions->getEditSection(); diff --git a/includes/ParserCache.php b/includes/ParserCache.php index 37a42b7f5c..b8e43e90d7 100644 --- a/includes/ParserCache.php +++ b/includes/ParserCache.php @@ -35,7 +35,7 @@ class ParserCache { function getKey( &$article, &$user ) { global $action; $hash = $user->getPageRenderingHash(); - if( !$article->mTitle->userCanEdit() ) { + if( !$article->mTitle->quickUserCanEdit() ) { // section edit links are suppressed even if the user has them on $edit = '!edit=0'; } else { diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 015b8cacb3..1308868e3d 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -664,7 +664,7 @@ class SkinTemplate extends Skin { true); wfProfileIn( "$fname-edit" ); - if ( $this->mTitle->userCanEdit() && ( $this->mTitle->exists() || $this->mTitle->userCanCreate() ) ) { + if ( $this->mTitle->quickUserCanEdit() && ( $this->mTitle->exists() || $this->mTitle->userCanCreate( false ) ) ) { $istalk = $this->mTitle->isTalkPage(); $istalkclass = $istalk?' istalk':''; $content_actions['edit'] = array( diff --git a/includes/Title.php b/includes/Title.php index 5a3aec030e..10fd9a327c 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1077,16 +1077,23 @@ class Title { return $this->mWatched; } + function quickUserCan( $action ) { + return $this->userCan( $action, false ); + } + /** * Can $wgUser perform $action this page? * @param string $action action that permission needs to be checked for + * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries. * @return boolean * @private */ - function userCan($action) { + function userCan( $action, $doExpensiveQueries = true ) { $fname = 'Title::userCan'; wfProfileIn( $fname ); + !$doExpensiveQueries or die(wfBacktrace() ); + global $wgUser, $wgNamespaceProtection; $result = null; @@ -1172,8 +1179,12 @@ class Title { * @return boolean * @access public */ - function userCanEdit() { - return $this->userCan('edit'); + function userCanEdit( $doExpensiveQueries = true ) { + return $this->userCan( 'edit', $doExpensiveQueries ); + } + + function quickUserCanEdit( ) { + return $this->userCanEdit( false ); } /** @@ -1181,8 +1192,8 @@ class Title { * @return boolean * @access public */ - function userCanCreate() { - return $this->userCan('create'); + function userCanCreate( $doExpensiveQueries = true ) { + return $this->userCan( 'create', $doExpensiveQueries ); } /** @@ -1190,8 +1201,8 @@ class Title { * @return boolean * @access public */ - function userCanMove() { - return $this->userCan('move'); + function userCanMove( $doExpensiveQueries = true ) { + return $this->userCan( 'move', $doExpensiveQueries ); } /**