From: Brad Jorsch Date: Wed, 9 Jul 2014 14:16:16 +0000 (-0400) Subject: API: Fix list=deletedrevs with pre-1.5 revisions X-Git-Tag: 1.31.0-rc.0~15006^2 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=e3ba5956e0218a51bb52093ee2742ded6fb64ec3;p=lhc%2Fweb%2Fwiklou.git API: Fix list=deletedrevs with pre-1.5 revisions In pre-1.5, deleted revisions have the text in the ar_text field of the archive table with empty ar_text_id. Adjust the JOIN used for drprop=content to take this situation into account, and the logic for extracting the revision content to match. Bug: 67699 Change-Id: I3672435ac97fa1eff2bdf80b24c470525c93ab27 --- diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index af0d938b56..6994cd4319 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -134,11 +134,17 @@ class ApiQueryDeletedrevs extends ApiQueryBase { } if ( $fld_content ) { + // Modern MediaWiki has the content for deleted revs in the 'text' + // table using fields old_text and old_flags. But revisions deleted + // pre-1.5 store the content in the 'archive' table directly using + // fields ar_text and ar_flags, and no corresponding 'text' row. So + // we have to LEFT JOIN and fetch all four fields, plus ar_text_id + // to be able to tell the difference. $this->addTables( 'text' ); $this->addJoinConds( - array( 'text' => array( 'INNER JOIN', array( 'ar_text_id=old_id' ) ) ) + array( 'text' => array( 'LEFT JOIN', array( 'ar_text_id=old_id' ) ) ) ); - $this->addFields( array( 'ar_text', 'ar_text_id', 'old_text', 'old_flags' ) ); + $this->addFields( array( 'ar_text', 'ar_flags', 'ar_text_id', 'old_text', 'old_flags' ) ); // This also means stricter restrictions if ( !$user->isAllowedAny( 'undelete', 'deletedtext' ) ) { @@ -353,7 +359,12 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $anyHidden = true; } if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_TEXT, $user ) ) { - ApiResult::setContent( $rev, Revision::getRevisionText( $row ) ); + if ( isset( $row->ar_text ) && !$row->ar_text_id ) { + // Pre-1.5 ar_text row (if condition from Revision::newFromArchiveRow) + ApiResult::setContent( $rev, Revision::getRevisionText( $row, 'ar_' ) ); + } else { + ApiResult::setContent( $rev, Revision::getRevisionText( $row ) ); + } } }