r49821 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49820‎ | r49821 | r49822 >
Date:17:20, 24 April 2009
Author:simetrical
Status:ok (Comments)
Tags:
Comment:
(bug 16950) Show move log when recreating a page

Showing the move log as well as delete log helps with pages that were
moved with no redirect, or moved and then the redirect deleted with a
confusing message. Previously, such pages would appear to have never
existed to a user trying to create them.

Patch by church of emacs, with trivial modifications by me.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -883,9 +883,9 @@
884884 }
885885 # Fetch content and check for errors
886886 if( !$outputDone ) {
887 - # If the article does not exist and was deleted, show the log
 887+ # If the article does not exist and was deleted/moved, show the log
888888 if( $this->getID() == 0 ) {
889 - $this->showDeletionLog();
 889+ $this->showLogs();
890890 }
891891 $text = $this->getContent();
892892 // For now, check also for ID until getContent actually returns
@@ -1062,14 +1062,14 @@
10631063 wfProfileOut( __METHOD__ );
10641064 }
10651065
1066 - protected function showDeletionLog() {
 1066+ protected function showLogs() {
10671067 global $wgUser, $wgOut;
10681068 $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut );
1069 - $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() );
 1069+ $pager = new LogPager( $loglist, array('move', 'delete'), false, $this->mTitle->getPrefixedText() );
10701070 if( $pager->getNumRows() > 0 ) {
10711071 $pager->mLimit = 10;
10721072 $wgOut->addHTML( '<div class="mw-warning-with-logexcerpt">' );
1073 - $wgOut->addWikiMsg( 'deleted-notice' );
 1073+ $wgOut->addWikiMsg( 'moveddeleted-notice' );
10741074 $wgOut->addHTML(
10751075 $loglist->beginLogEventsList() .
10761076 $pager->getBody() .
@@ -1078,9 +1078,9 @@
10791079 if( $pager->getNumRows() > 10 ) {
10801080 $wgOut->addHTML( $wgUser->getSkin()->link(
10811081 SpecialPage::getTitleFor( 'Log' ),
1082 - wfMsgHtml( 'deletelog-fulllog' ),
 1082+ wfMsgHtml( 'log-fulllog' ),
10831083 array(),
1084 - array( 'type' => 'delete', 'page' => $this->mTitle->getPrefixedText() )
 1084+ array( 'page' => $this->mTitle->getPrefixedText() )
10851085 ) );
10861086 }
10871087 $wgOut->addHTML( '</div>' );
Index: trunk/phase3/includes/EditPage.php
@@ -707,9 +707,9 @@
708708 $wgOut->wrapWikiMsg( '<div class="mw-newarticletextanon">$1</div>', 'newarticletextanon' );
709709 }
710710 }
711 - # Give a notice if the user is editing a deleted page...
 711+ # Give a notice if the user is editing a deleted/moved page...
712712 if ( !$this->mTitle->exists() ) {
713 - $this->showDeletionLog( $wgOut );
 713+ $this->showLogs( $wgOut );
714714 }
715715 }
716716
@@ -2435,20 +2435,20 @@
24362436 }
24372437
24382438 /**
2439 - * If there are rows in the deletion log for this page, show them,
 2439+ * If there are rows in the deletion/move log for this page, show them,
24402440 * along with a nice little note for the user
24412441 *
24422442 * @param OutputPage $out
24432443 */
2444 - protected function showDeletionLog( $out ) {
 2444+ protected function showLogs( $out ) {
24452445 global $wgUser;
24462446 $loglist = new LogEventsList( $wgUser->getSkin(), $out );
2447 - $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() );
 2447+ $pager = new LogPager( $loglist, array('move', 'delete'), false, $this->mTitle->getPrefixedText() );
24482448 $count = $pager->getNumRows();
24492449 if ( $count > 0 ) {
24502450 $pager->mLimit = 10;
24512451 $out->addHTML( '<div class="mw-warning-with-logexcerpt">' );
2452 - $out->addWikiMsg( 'recreate-deleted-warn' );
 2452+ $out->addWikiMsg( 'recreate-moveddeleted-warn' );
24532453 $out->addHTML(
24542454 $loglist->beginLogEventsList() .
24552455 $pager->getBody() .
@@ -2457,11 +2457,9 @@
24582458 if($count > 10){
24592459 $out->addHTML( $wgUser->getSkin()->link(
24602460 SpecialPage::getTitleFor( 'Log' ),
2461 - wfMsgHtml( 'deletelog-fulllog' ),
 2461+ wfMsgHtml( 'log-fulllog' ),
24622462 array(),
2463 - array(
2464 - 'type' => 'delete',
2465 - 'page' => $this->mTitle->getPrefixedText() ) ) );
 2463+ array( 'page' => $this->mTitle->getPrefixedText() ) ) );
24662464 }
24672465 $out->addHTML( '</div>' );
24682466 return true;
Index: trunk/phase3/includes/LogEventsList.php
@@ -541,24 +541,28 @@
542542 /**
543543 * Set the log reader to return only entries of the given type.
544544 * Type restrictions enforced here
545 - * @param $type String: A log type ('upload', 'delete', etc)
 545+ * @param $type String or array: Log types ('upload', 'delete', etc)
546546 */
547 - private function limitType( $type ) {
 547+ private function limitType( $types ) {
548548 global $wgLogRestrictions, $wgUser;
 549+ // If $types is not an array, make it an array
 550+ $types = (array)$types;
549551 // Don't even show header for private logs; don't recognize it...
550 - if( isset($wgLogRestrictions[$type]) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
551 - $type = '';
 552+ foreach ( $types as $type ) {
 553+ if( isset( $wgLogRestrictions[$type] ) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
 554+ $types = array_diff( $types, array( $type ) );
 555+ }
552556 }
553 - // Don't show private logs to unpriviledged users.
 557+ // Don't show private logs to unprivileged users.
554558 // Also, only show them upon specific request to avoid suprises.
555 - $audience = $type ? 'user' : 'public';
 559+ $audience = $types ? 'user' : 'public';
556560 $hideLogs = LogEventsList::getExcludeClause( $this->mDb, $audience );
557561 if( $hideLogs !== false ) {
558562 $this->mConds[] = $hideLogs;
559563 }
560 - if( $type ) {
561 - $this->type = $type;
562 - $this->mConds['log_type'] = $type;
 564+ if( $types ) {
 565+ $this->type = $types;
 566+ $this->mConds['log_type'] = $types;
563567 }
564568 }
565569
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1213,13 +1213,13 @@
12141214 'permissionserrors' => 'Permissions Errors',
12151215 'permissionserrorstext' => 'You do not have permission to do that, for the following {{PLURAL:$1|reason|reasons}}:',
12161216 'permissionserrorstext-withaction' => 'You do not have permission to $2, for the following {{PLURAL:$1|reason|reasons}}:',
1217 -'recreate-deleted-warn' => "'''Warning: You are recreating a page that was previously deleted.'''
 1217+'recreate-moveddeleted-warn' => "'''Warning: You are recreating a page that was previously deleted.'''
12181218
12191219 You should consider whether it is appropriate to continue editing this page.
1220 -The deletion log for this page is provided here for convenience:",
1221 -'deleted-notice' => 'This page has been deleted.
1222 -The deletion log for the page is provided below for reference.',
1223 -'deletelog-fulllog' => 'View full log',
 1220+The deletion and move log for this page are provided here for convenience:",
 1221+'moveddeleted-notice' => 'This page has been deleted.
 1222+The deletion and move log for the page are provided below for reference.',
 1223+'log-fulllog' => 'View full log',
12241224 'edit-hook-aborted' => 'Edit aborted by hook.
12251225 It gave no explanation.',
12261226 'edit-gone-missing' => 'Could not update the page.
Index: trunk/phase3/RELEASE-NOTES
@@ -171,6 +171,7 @@
172172 to Special:Version
173173 * Added $wgExtPGAlteredFields to allow extensions to easily alter the data
174174 type of columns when using the Postgres backend.
 175+* (bug 16950) Show move log when viewing/creating a deleted page
175176
176177
177178 === Bug fixes in 1.15 ===

Follow-up revisions

RevisionCommit summaryAuthorDate
r49823Update messages.inc for r49821...simetrical17:48, 24 April 2009
r51956Show right logs when viewing/creating deleted page...simetrical10:26, 16 June 2009

Comments

#Comment by Siebrand (talk | contribs)   17:36, 24 April 2009

maintenance/language/messages.inc was not updated.

#Comment by Simetrical (talk | contribs)   18:00, 24 April 2009

Fixed in r49823.

#Comment by Brion VIBBER (talk | contribs)   00:11, 28 April 2009

Is this query going to get planned efficiently? It won't be able to use the type+action+page index.

#Comment by Simetrical (talk | contribs)   00:21, 28 April 2009

I believe it will, yes ― I did consider that before committing the patch. I don't see any type+action+page index in the default schema. It will have been using page_time anyway, see lines 643 ff. in LogEventsList.php:

        if( $this->title || $this->pattern || $this->user ) {
            $index = array( 'USE INDEX' => array( 'logging' => array('page_time','user_time') ) );
        } else if( $this->type ) {
            $index = array( 'USE INDEX' => array( 'logging' => 'type_time' ) );
        } else {
            $index = array( 'USE INDEX' => array( 'logging' => 'times' ) );
        }

The first condition will get hit, since $this->title will be set, regardless of the action types. So it will retrieve by page, ordered by timestamp, and just filter out the ones with the wrong action. Adding more actions to include will make this marginally faster, if anything.

#Comment by Brion VIBBER (talk | contribs)   00:24, 28 April 2009
mysql> explain SELECT /* IndexPager::reallyDoQuery (LogPager) WikiSysop */  log_type,log_action,log_user,log_namespace,log_title,log_params,log_comment,log_id,log_deleted,log_timestamp,user_name,user_editcount,ts_tags  FROM `logging` FORCE INDEX (page_time,user_time) INNER JOIN `user` ON ((user_id=log_user)) LEFT JOIN `tag_summary` ON ((ts_log_id=log_id))  WHERE log_type IN ('move','delete')  AND log_namespace = '0' AND log_title = 'George_W._Bush' AND (user_id = log_user)  ORDER BY log_timestamp DESC LIMIT 51;
+-------------+--------+---------------------+-----------+---------+------------------+-------+-------------+
| table       | type   | possible_keys       | key       | key_len | ref              | rows  | Extra       |
+-------------+--------+---------------------+-----------+---------+------------------+-------+-------------+
| logging     | ref    | user_time,page_time | page_time |     259 | const,const      |   267 | Using where |
| user        | eq_ref | PRIMARY             | PRIMARY   |       4 | logging.log_user |     1 |             |
| tag_summary | ref    | ts_log_id           | ts_log_id |       5 | logging.log_id   | 18363 |             |
+-------------+--------+---------------------+-----------+---------+------------------+-------+-------------+

Yeah, looks like it's working fairly sensibly. Wikipedia:George W. Bush matches 41 of 51 log entries; worse cases should be relatively rare.

Status & tagging log