https://www.mediawiki.org/wiki/Special:Code/MediaWiki/109628
Revision: 109628
Author: nikerabbit
Date: 2012-01-20 16:57:46 +0000 (Fri, 20 Jan 2012)
Log Message:
-----------
Reducy query flood in r96546. Allow formatters to provide titles for LinkBatch.
Modified Paths:
--------------
trunk/phase3/includes/logging/LogFormatter.php
trunk/phase3/includes/logging/LogPager.php
Modified: trunk/phase3/includes/logging/LogFormatter.php
===================================================================
--- trunk/phase3/includes/logging/LogFormatter.php 2012-01-20 16:46:15 UTC
(rev 109627)
+++ trunk/phase3/includes/logging/LogFormatter.php 2012-01-20 16:57:46 UTC
(rev 109628)
@@ -153,25 +153,13 @@
}
/**
- * 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 @@
$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 @@
return $element;
}
+ /**
+ * @return Array of titles that should be preloaded with LinkBatch.
+ */
+ public function getPreloadTitles() {
+ return array();
+ }
+
}
/**
@@ -334,6 +353,11 @@
* @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();
Modified: trunk/phase3/includes/logging/LogPager.php
===================================================================
--- trunk/phase3/includes/logging/LogPager.php 2012-01-20 16:46:15 UTC (rev
109627)
+++ trunk/phase3/includes/logging/LogPager.php 2012-01-20 16:57:46 UTC (rev
109628)
@@ -297,6 +297,10 @@
$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 );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs