r96546 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96545‎ | r96546 | r96547 >
Date:09:09, 8 September 2011
Author:nikerabbit
Status:resolved (Comments)
Tags:tstarling 
Comment:
Enabled MoveLogFormatter
-> This brings better i18n even to existing move log entries
Fixed the class name from r96441, it's Move not Block
Added notes about new naming conventions to DefaultSettings.php
-> didn't bother the remain existing messages now, they will keep working
Didn't remove 1movedto2*, they are still used until I commit the code which actually makes new style log entries.
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/logging/LogFormatter.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -3506,6 +3506,12 @@
35073507 'unwatch' => array(
35083508 'confirm-unwatch-button',
35093509 ),
 3510+ 'logging' => array(
 3511+ 'logentry-move-move',
 3512+ 'logentry-move-move-noredirect',
 3513+ 'logentry-move-move_redir',
 3514+ 'logentry-move-move_redir-noredirect',
 3515+ ),
35103516 );
35113517
35123518 /** Comments for each block */
@@ -3737,4 +3743,5 @@
37383744 'db-error-messages' => 'Database error messages',
37393745 'html-forms' => 'HTML forms',
37403746 'sqlite' => 'SQLite database support',
 3747+ 'logging' => 'New logging system',
37413748 );
Index: trunk/phase3/includes/logging/LogFormatter.php
@@ -56,9 +56,7 @@
5757
5858 // Nonstatic->
5959
60 - /**
61 - * @var LogEntry
62 - */
 60+ /// @var LogEntry
6361 protected $entry;
6462
6563 /// Whether to output user tool links
@@ -323,7 +321,7 @@
324322 * This class formats Block log entries.
325323 * @since 1.19
326324 */
327 -class BlockLogFormatter extends LogFormatter {
 325+class MoveLogFormatter extends LogFormatter {
328326 protected function getMessageKey() {
329327 $key = parent::getMessageKey();
330328 $params = $this->getMessageParameters();
Index: trunk/phase3/includes/DefaultSettings.php
@@ -4909,7 +4909,8 @@
49104910 * an action, which is a specific kind of event that can exist in that
49114911 * log type.
49124912 */
4913 -$wgLogTypes = array( '',
 4913+$wgLogTypes = array(
 4914+ '',
49144915 'block',
49154916 'protect',
49164917 'rights',
@@ -4962,6 +4963,9 @@
49634964 * will be listed in the user interface.
49644965 *
49654966 * Extensions with custom log types may add to this array.
 4967+ *
 4968+ * Since 1.19, if you follow the naming convention log-name-TYPE,
 4969+ * where TYPE is your log type, yoy don't need to use this array.
49664970 */
49674971 $wgLogNames = array(
49684972 '' => 'all-logs-page',
@@ -4982,6 +4986,9 @@
49834987 * top of each log type.
49844988 *
49854989 * Extensions with custom log types may add to this array.
 4990+ *
 4991+ * Since 1.19, if you follow the naming convention log-description-TYPE,
 4992+ * where TYPE is your log type, yoy don't need to use this array.
49864993 */
49874994 $wgLogHeaders = array(
49884995 '' => 'alllogstext',
@@ -5020,8 +5027,6 @@
50215028 'upload/upload' => 'uploadedimage',
50225029 'upload/overwrite' => 'overwroteimage',
50235030 'upload/revert' => 'uploadedimage',
5024 - 'move/move' => '1movedto2',
5025 - 'move/move_redir' => '1movedto2_redir',
50265031 'import/upload' => 'import-logentry-upload',
50275032 'import/interwiki' => 'import-logentry-interwiki',
50285033 'merge/merge' => 'pagemerge-logentry',
@@ -5038,8 +5043,12 @@
50395044 * The same as above, but here values are names of functions,
50405045 * not messages.
50415046 * @see LogPage::actionText
 5047+ * @see LogFormatter
50425048 */
5043 -$wgLogActionsHandlers = array();
 5049+$wgLogActionsHandlers = array(
 5050+ // move, move_redir
 5051+ 'move/*' => 'MoveLogFormatter',
 5052+);
50445053
50455054 /**
50465055 * Maintain a log of newusers at Log/newusers?
Index: trunk/phase3/includes/AutoLoader.php
@@ -539,7 +539,7 @@
540540 'ManualLogEntry' => 'includes/logging/LogEntry.php',
541541 'LogFormatter' => 'includes/logging/LogFormatter.php',
542542 'LegacyLogFormatter' => 'includes/logging/LogFormatter.php',
543 - 'BlockLogFormatter' => 'includes/logging/LogFormatter.php',
 543+ 'MoveLogFormatter' => 'includes/logging/LogFormatter.php',
544544
545545 # includes/media
546546 'BitmapHandler' => 'includes/media/Bitmap.php',
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -4638,4 +4638,10 @@
46394639 'sqlite-has-fts' => '$1 with full-text search support',
46404640 'sqlite-no-fts' => '$1 without full-text search support',
46414641
 4642+# New logging system
 4643+'logentry-move-move' => '$1 {{GENDER:$2|moved}} page $3 to $4',
 4644+'logentry-move-move-noredirect' => '$1 {{GENDER:$2|moved}} page $3 to $4 without leaving a redirect',
 4645+'logentry-move-move_redir' => '$1 {{GENDER:$2|moved}} page $3 to $4 over redirect',
 4646+'logentry-move-move_redir-noredirect' => '$1 {{GENDER:$2|moved}} page $3 to $4 over a redirect without leaving a redirect',
 4647+
46424648 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r109628Reducy query flood in r96546. Allow formatters to provide titles for LinkBatch.nikerabbit16:57, 20 January 2012
r110893In LogFormatter:...aaron23:12, 7 February 2012
r110897r96546: Made FeedUtils::formatDiff() use the new LogFormatter class rather th...aaron23:57, 7 February 2012
r110909* Fix for r96546 etc.: due to a severe performance regression in log lists, r...tstarling03:27, 8 February 2012
r110953Fixes for r96546 (bug 33167):...aaron19:52, 8 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96441Committing my new logging classes for review. Will later commit changes that ...nikerabbit15:32, 7 September 2011

Comments

#Comment by Tim Starling (talk | contribs)   03:21, 25 November 2011

{{GENDER}} is not optimised for this use case. It does three database queries per log row when you use it like this.

#Comment by Nikerabbit (talk | contribs)   08:50, 8 December 2011

What queries? I only see few bugs like User::loadOptions called repeatedly for user which has no options.

#Comment by Duplicatebug (talk | contribs)   23:49, 6 January 2012

This queries are used for each gender parser function:

<!--SELECT  *  FROM `user`  WHERE user_id = '1'  LIMIT 1   (MediaWiki::run/MediaWiki::main/MediaWiki::performRequest/SpecialPageFactory::executePath/SpecialLog::execute/SpecialLog::show/IndexPager::getBody/LogPager::formatRow/LogEventsList::logLine/LogFormatter::getActionText/Message::escaped/Message::toString/Message::transformText/MessageCache::transform/Parser::transformMsg/Parser::preprocess/Parser::replaceVariables/PPFrame_DOM::expand/Parser::braceSubstitution/call_user_func_array/CoreParserFunctions::gender/User::getOption/User::loadOptions/User::load/User::loadFromId/User::loadFromDatabase/DatabaseBase::selectRow/DatabaseBase::select)-->
<!--SELECT  ug_group  FROM `user_groups`  WHERE ug_user = '1'   (MediaWiki::run/MediaWiki::main/MediaWiki::performRequest/SpecialPageFactory::executePath/SpecialLog::execute/SpecialLog::show/IndexPager::getBody/LogPager::formatRow/LogEventsList::logLine/LogFormatter::getActionText/Message::escaped/Message::toString/Message::transformText/MessageCache::transform/Parser::transformMsg/Parser::preprocess/Parser::replaceVariables/PPFrame_DOM::expand/Parser::braceSubstitution/call_user_func_array/CoreParserFunctions::gender/User::getOption/User::loadOptions/User::load/User::loadFromId/User::saveToCache/User::loadGroups/DatabaseBase::select)-->
<!--SELECT  *  FROM `user_properties`  WHERE up_user = '1'   (MediaWiki::run/MediaWiki::main/MediaWiki::performRequest/SpecialPageFactory::executePath/SpecialLog::execute/SpecialLog::show/IndexPager::getBody/LogPager::formatRow/LogEventsList::logLine/LogFormatter::getActionText/Message::escaped/Message::toString/Message::transformText/MessageCache::transform/Parser::transformMsg/Parser::preprocess/Parser::replaceVariables/PPFrame_DOM::expand/Parser::braceSubstitution/call_user_func_array/CoreParserFunctions::gender/User::getOption/User::loadOptions/User::load/User::loadFromId/User::saveToCache/User::loadOptions/DatabaseBase::select)-->

More information: The performer of the logs makes now problems. They are handled by one query (the LinkBatch in LogPager::getStartBody). The problem are links to user pages inside the comments which are not performer (Linker::commentBlock). Than each link result in an own query to get the gender state. But that sounds hard to do at that place.

For block log entries the method Linker::userToolLinks is using the user talk page, which is not inside the LinkBatch and Linker::getTitleLink is calling User::idFromName for each entry.

There is not for every user the need to add usernames of (partial) rev deleted log entries to the linkbatch, but that sounds not so easy to do.

#Comment by Tim Starling (talk | contribs)   01:57, 8 February 2012

Here is the query log for Special:Log/move on my test wiki: http://paste.tstarling.com/p/rQxouc.html

#Comment by Tim Starling (talk | contribs)   03:49, 8 February 2012

Disabled the relevant feature in

#Comment by Tim Starling (talk | contribs)   03:49, 8 February 2012

Disabled the relevant feature in r110909.

#Comment by Tim Starling (talk | contribs)   05:43, 8 February 2012

If you have memcached enabled, you get less queries: one per row for users with default options before r110910, and zero per row after r110910. I think a single DB query would be faster than 50 memcached queries, so that may be the best option, unless BagOStuff were given support for MWMemcached::get_multi() or similar. Loading from the database is tricky because User::newFromResult() doesn't support loading data from user_properties, so the interfaces would have to be changed.

#Comment by Nikerabbit (talk | contribs)   18:42, 8 February 2012

Correct. I have some ideas how to query them at once, but that can probably be done after 1.19 and release 1.19 with your workaround?

#Comment by Tim Starling (talk | contribs)   01:19, 10 February 2012

Yes, but I'm still waiting for the code around line 293 of LogPage.php to be fixed. LogPage::actionText() is a public function, it should do something sensible if it's called for delete/delete or the like. I thought that's what Aaron meant when he complained about the code in his comment below.

#Comment by Aaron Schulz (talk | contribs)   23:06, 2 February 2012

In LogPage we have:

$rv = call_user_func_array( $wgLogActionsHandlers[$key], $args );

But $wgLogActionsHandlers is being set to uses class names as callbacks, not functions. I get things like: Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'DeleteLogFormatter' not found or invalid function name in D:\www\MediaWiki\phase3\includes\logging\LogPage.php on line 296

#Comment by Aaron Schulz (talk | contribs)   19:02, 3 February 2012

Maybe the easiest fix is to have LogPage::addEntry() wrap ManualLogEntry and its insert() function.

#Comment by Tim Starling (talk | contribs)   03:47, 8 February 2012

This broken code is still present, even after r110893. Leaving status as fixme because of that.

#Comment by Aaron Schulz (talk | contribs)   19:57, 8 February 2012

Yeah, I was fixing other breakage first. I just fixes that problem now.

#Comment by Aaron Schulz (talk | contribs)   19:40, 3 February 2012

Anything using LogPage::actionText should use the Formatter and the that function should also be deprecated.

#Comment by Aaron Schulz (talk | contribs)   22:44, 6 February 2012

See bug 33385.

#Comment by Nikerabbit (talk | contribs)   18:49, 7 February 2012

I don't see how that is related.

#Comment by Aaron Schulz (talk | contribs)   18:53, 7 February 2012

Should be bug 33167.

#Comment by Nikerabbit (talk | contribs)   19:04, 7 February 2012

So who should see it? You know I've already seen it.

#Comment by Aaron Schulz (talk | contribs)   19:07, 7 February 2012

It's mostly there for reference (saw the bug # is on CR).

Status & tagging log