From: Rob Church Date: Fri, 6 Jul 2007 03:55:36 +0000 (+0000) Subject: Document and clean up wfQueriesMustScale(); less verbose comments inside the function... X-Git-Tag: 1.31.0-rc.0~52259 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=fe74d822da59c2efea5f22da884349dc9aca3d62;p=lhc%2Fweb%2Fwiklou.git Document and clean up wfQueriesMustScale(); less verbose comments inside the function, more function documentation, please -- and don't use an if statement when it's not needed --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 6f671c3897..b86bd8475b 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2258,24 +2258,25 @@ function wfLocalFile( $title ) { return RepoGroup::singleton()->getLocalRepo()->newFile( $title ); } +/** + * Should low-performance queries be disabled? + * + * @return bool + */ function wfQueriesMustScale() { global $wgMiserMode; - // If $wgMiserMode is true, all queries must be efficient + // Unconditional performance requirement if( $wgMiserMode ) return true; - // Try to roughly guess how large this wiki is. - // Useful for figuring out if a query that doesn't scale should be avoided - // or if job queue should be used + // Make a rough estimate $dbr = wfGetDB( DB_SLAVE ); - $stats = $dbr->selectRow('site_stats', - array('ss_total_pages AS pages','ss_total_edits as edits','ss_users AS users'), + $stats = $dbr->selectRow( + 'site_stats', + array( 'ss_total_pages AS pages', 'ss_total_edits AS edits', 'ss_users AS users' ), array(), - __METHOD__); - if( $stats->pages > 100000 && $stats->edits > 1000000 && $stats->users > 10000 ) { - return true; - } else { - return false; - } + __METHOD__ + ); + return $stats->pages > 100000 && $stats->edits > 1000000 && $stats->users > 10000; } /**