From: Niklas Laxström Date: Fri, 20 Jan 2012 16:57:46 +0000 (+0000) Subject: Reducy query flood in r96546. Allow formatters to provide titles for LinkBatch. X-Git-Tag: 1.31.0-rc.0~25163 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/categories/modifier.php?a=commitdiff_plain;h=35301bc19cd1e1177b54b9c26688df8cd52b80a1;p=lhc%2Fweb%2Fwiklou.git Reducy query flood in r96546. Allow formatters to provide titles for LinkBatch. --- diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index 441c22bfdb..00c194b041 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -153,25 +153,13 @@ class LogFormatter { } /** - * Extract parameters intented for action message from - * array of all parameters. There are three hardcoded - * parameters (array zero-indexed, this list not): - * - 1: user name with premade link - * - 2: usable for gender magic function - * - 3: target page with premade link + * Extracts the optional extra parameters for use in action messages. + * The array indexes start from number 3. * @return array */ - protected function getMessageParameters() { - if ( isset( $this->parsedParameters ) ) { - return $this->parsedParameters; - } - + protected function extractParameters() { $entry = $this->entry; - $params = array(); - $params[0] = Message::rawParam( $this->getPerformerElement() ); - $params[1] = $entry->getPerformer()->getName(); - $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) ); if ( $entry->isLegacy() ) { foreach ( $entry->getParameters() as $index => $value ) { @@ -196,7 +184,31 @@ class LogFormatter { $params[$i] = ''; } } + return $params; + } + + /** + * Formats parameters intented for action message from + * array of all parameters. There are three hardcoded + * parameters (array is zero-indexed, this list not): + * - 1: user name with premade link + * - 2: usable for gender magic function + * - 3: target page with premade link + * @return array + */ + protected function getMessageParameters() { + if ( isset( $this->parsedParameters ) ) { + return $this->parsedParameters; + } + $entry = $this->entry; + $params = $this->extractParameters(); + $params[0] = Message::rawParam( $this->getPerformerElement() ); + $params[1] = $entry->getPerformer()->getName(); + $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) ); + + // Bad things happens if the numbers are not in correct order + ksort( $params ); return $this->parsedParameters = $params; } @@ -300,6 +312,13 @@ class LogFormatter { return $element; } + /** + * @return Array of titles that should be preloaded with LinkBatch. + */ + public function getPreloadTitles() { + return array(); + } + } /** @@ -334,6 +353,11 @@ class LegacyLogFormatter extends LogFormatter { * @since 1.19 */ class MoveLogFormatter extends LogFormatter { + public function getPreloadTitles() { + $params = $this->extractParameters(); + return array( Title::newFromText( $params[3] ) ); + } + protected function getMessageKey() { $key = parent::getMessageKey(); $params = $this->getMessageParameters(); diff --git a/includes/logging/LogPager.php b/includes/logging/LogPager.php index 7a616e004a..16781a6ef8 100644 --- a/includes/logging/LogPager.php +++ b/includes/logging/LogPager.php @@ -297,6 +297,10 @@ class LogPager extends ReverseChronologicalPager { $lb->add( $row->log_namespace, $row->log_title ); $lb->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) ); $lb->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) ); + $formatter = LogFormatter::newFromRow( $row ); + foreach ( $formatter->getPreloadTitles() as $title ) { + $lb->addObj( $title ); + } } $lb->execute(); $this->mResult->seek( 0 );