r87804 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87803‎ | r87804 | r87805 >
Date:01:11, 10 May 2011
Author:brion
Status:resolved (Comments)
Tags:
Comment:
* (bug 21279) Special:RevisionDelete now uses revision ID for deleted-page revisions when ar_rev_id is available.

- saved Special:RevisionDelete links from before page deletion still work as-is after deletion
- old log entries for rev-delete adjustments no longer magically switch to linking to Special:RevisionDelete with archive & ar_timestamp (they remain the same, as the links continue to work)

If you call Special:RevisionDelete using the older-style &type=archive links (using ar_timestamp as id) it will still save the same form to log for now; this may be fixed later for cases where the ar_rev_id is available.

Requires FakeResultWrapper fixes from r87803.
Modified paths:
  • /trunk/phase3/includes/revisiondelete/RevisionDelete.php (modified) (history)
  • /trunk/phase3/includes/revisiondelete/RevisionDeleteAbstracts.php (modified) (history)
  • /trunk/phase3/includes/revisiondelete/RevisionDeleter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/revisiondelete/RevisionDelete.php
@@ -1,6 +1,12 @@
22 <?php
33 /**
44 * List for revision table items
 5+ *
 6+ * This will check both the 'revision' table for live revisions and the
 7+ * 'archive' table for traditionally-deleted revisions that have an
 8+ * ar_rev_id saved.
 9+ *
 10+ * See RevDel_RevisionItem and RevDel_ArchivedRevisionItem for items.
511 */
612 class RevDel_RevisionList extends RevDel_List {
713 var $currentRevId;
@@ -16,7 +22,7 @@
1723 */
1824 public function doQuery( $db ) {
1925 $ids = array_map( 'intval', $this->ids );
20 - return $db->select( array('revision','page'), '*',
 26+ $live = $db->select( array('revision','page'), '*',
2127 array(
2228 'rev_page' => $this->title->getArticleID(),
2329 'rev_id' => $ids,
@@ -25,10 +31,49 @@
2632 __METHOD__,
2733 array( 'ORDER BY' => 'rev_id DESC' )
2834 );
 35+
 36+ if ( $live->numRows() >= count( $ids ) ) {
 37+ // All requested revisions are live, keeps things simple!
 38+ return $live;
 39+ }
 40+
 41+ // Check if any requested revisions are available fully deleted.
 42+ $archived = $db->select( array( 'archive' ), '*',
 43+ array(
 44+ 'ar_rev_id' => $ids
 45+ ),
 46+ __METHOD__,
 47+ array( 'ORDER BY' => 'ar_rev_id DESC' )
 48+ );
 49+
 50+ if ( $archived->numRows() == 0 ) {
 51+ return $live;
 52+ } else if ( $live->numRows() == 0 ) {
 53+ return $archived;
 54+ } else {
 55+ // Combine the two! Whee
 56+ $rows = array();
 57+ while ( $row = $live->fetchObject() ) {
 58+ $rows[$row->rev_id] = $row;
 59+ }
 60+ while ( $row = $archived->fetchObject() ) {
 61+ $rows[$row->ar_rev_id] = $row;
 62+ }
 63+ krsort( $rows );
 64+ return new FakeResultWrapper( array_values( $rows ) );
 65+ }
2966 }
3067
3168 public function newItem( $row ) {
32 - return new RevDel_RevisionItem( $this, $row );
 69+ if ( isset( $row->rev_id ) ) {
 70+ return new RevDel_RevisionItem( $this, $row );
 71+ } elseif ( isset( $row->ar_rev_id ) ) {
 72+ return new RevDel_ArchivedRevisionItem( $this, $row );
 73+ } else {
 74+ // This shouldn't happen. :)
 75+ var_dump( $row );
 76+ throw new MWException( 'Invalid row type in RevDel_RevisionList' );
 77+ }
3378 }
3479
3580 public function getCurrent() {
@@ -58,7 +103,7 @@
59104 }
60105
61106 /**
62 - * Item class for a revision table row
 107+ * Item class for a live revision table row
63108 */
64109 class RevDel_RevisionItem extends RevDel_Item {
65110 var $revision;
@@ -281,7 +326,36 @@
282327 }
283328 }
284329
 330+
285331 /**
 332+ * Item class for a archive table row by ar_rev_id -- actually
 333+ * used via RevDel_RevisionList.
 334+ */
 335+class RevDel_ArchivedRevisionItem extends RevDel_ArchiveItem {
 336+ public function __construct( $list, $row ) {
 337+ RevDel_Item::__construct( $list, $row );
 338+
 339+ $this->revision = Revision::newFromArchiveRow( $row,
 340+ array( 'page' => $this->list->title->getArticleId() ) );
 341+ }
 342+
 343+ public function getId() {
 344+ return $this->revision->getId();
 345+ }
 346+
 347+ public function setBits( $bits ) {
 348+ $dbw = wfGetDB( DB_MASTER );
 349+ $dbw->update( 'archive',
 350+ array( 'ar_deleted' => $bits ),
 351+ array( 'ar_rev_id' => $this->row->ar_rev_id,
 352+ 'ar_deleted' => $this->getBits()
 353+ ),
 354+ __METHOD__ );
 355+ return (bool)$dbw->affectedRows();
 356+ }
 357+}
 358+
 359+/**
286360 * List for oldimage table items
287361 */
288362 class RevDel_FileList extends RevDel_List {
Index: trunk/phase3/includes/revisiondelete/RevisionDeleter.php
@@ -178,24 +178,7 @@
179179 // This is not going to work if some revs are deleted and some
180180 // aren't.
181181 if ($key == 'revision') {
182 - foreach( $Ids as $k => $id ) {
183 - $existResult =
184 - self::checkRevisionExistence( $title, $id );
185 -
186 - if ($existResult !== true) {
187 - $key = 'archive';
188 - $Ids[$k] = $existResult;
189 - } else {
190 - // Undeleted revision amidst deleted ones
191 - unset($Ids[$k]);
192 - $undeletedRevisions[] = $id;
193 - }
194 - }
195 -
196 - if ( $key == $originalKey ) {
197 - $Ids = $undeletedRevisions;
198 - $undeletedRevisions = array();
199 - }
 182+ // Nothing to do; deleted revisions can still be looked up by ID.
200183 }
201184
202185 // Diff link for single rev deletions
Index: trunk/phase3/includes/revisiondelete/RevisionDeleteAbstracts.php
@@ -1,7 +1,10 @@
22 <?php
33
44 /**
5 - * Abstract base class for a list of deletable items
 5+ * Abstract base class for a list of deletable items. The list class
 6+ * needs to be able to make a query from a set of identifiers to pull
 7+ * relevant rows, to return RevDel_Item subclasses wrapping them, and
 8+ * to wrap bulk update operations.
69 */
710 abstract class RevDel_List {
811

Follow-up revisions

RevisionCommit summaryAuthorDate
r87805* (bug 21279) Special:Undelete's 'change visibility' links now use forward-co...brion01:13, 10 May 2011
r87806* (bug 21279, bug 28820) Workaround for standard diff links to deleted revs; ...brion01:17, 10 May 2011
r88470Even it shouldn't happen, let's remove the var_dump() from the code....platonides18:01, 20 May 2011
r91344* Added generic Rev_List revision listing class and refactored RevDelete_List...aaron09:04, 2 July 2011
r91346Removed dead $undeletedRevisions code (useless since r87804)aaron09:08, 2 July 2011
r93860* Refactored SpecialUndelete::revDeleteLink into a Linker::getRevDeleteLink f...aaron22:37, 3 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r66793Ugly temporary fix for bug 21279:...werdna14:19, 23 May 2010
r87803Fixes for FakeResultWrapper iteration -- the rewind/next/current stuff used i...brion01:04, 10 May 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   05:22, 22 June 2011

Why is the $undeletedRevisions still there in RevisionDeleter.php?

Status & tagging log