[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * This program is free software; you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation; either version 2 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License along 14 * with this program; if not, write to the Free Software Foundation, Inc., 15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 * http://www.gnu.org/copyleft/gpl.html 17 * 18 * @file 19 * @ingroup RevisionDelete 20 */ 21 22 /** 23 * List for revision table items 24 * 25 * This will check both the 'revision' table for live revisions and the 26 * 'archive' table for traditionally-deleted revisions that have an 27 * ar_rev_id saved. 28 * 29 * See RevDelRevisionItem and RevDelArchivedRevisionItem for items. 30 */ 31 class RevDelRevisionList extends RevDelList { 32 /** @var int */ 33 public $currentRevId; 34 35 public function getType() { 36 return 'revision'; 37 } 38 39 public static function getRelationType() { 40 return 'rev_id'; 41 } 42 43 public static function getRestriction() { 44 return 'deleterevision'; 45 } 46 47 public static function getRevdelConstant() { 48 return Revision::DELETED_TEXT; 49 } 50 51 public static function suggestTarget( $target, array $ids ) { 52 $rev = Revision::newFromId( $ids[0] ); 53 return $rev ? $rev->getTitle() : $target; 54 } 55 56 /** 57 * @param DatabaseBase $db 58 * @return mixed 59 */ 60 public function doQuery( $db ) { 61 $ids = array_map( 'intval', $this->ids ); 62 $live = $db->select( 63 array( 'revision', 'page', 'user' ), 64 array_merge( Revision::selectFields(), Revision::selectUserFields() ), 65 array( 66 'rev_page' => $this->title->getArticleID(), 67 'rev_id' => $ids, 68 ), 69 __METHOD__, 70 array( 'ORDER BY' => 'rev_id DESC' ), 71 array( 72 'page' => Revision::pageJoinCond(), 73 'user' => Revision::userJoinCond() ) 74 ); 75 76 if ( $live->numRows() >= count( $ids ) ) { 77 // All requested revisions are live, keeps things simple! 78 return $live; 79 } 80 81 // Check if any requested revisions are available fully deleted. 82 $archived = $db->select( array( 'archive' ), Revision::selectArchiveFields(), 83 array( 84 'ar_rev_id' => $ids 85 ), 86 __METHOD__, 87 array( 'ORDER BY' => 'ar_rev_id DESC' ) 88 ); 89 90 if ( $archived->numRows() == 0 ) { 91 return $live; 92 } elseif ( $live->numRows() == 0 ) { 93 return $archived; 94 } else { 95 // Combine the two! Whee 96 $rows = array(); 97 foreach ( $live as $row ) { 98 $rows[$row->rev_id] = $row; 99 } 100 foreach ( $archived as $row ) { 101 $rows[$row->ar_rev_id] = $row; 102 } 103 krsort( $rows ); 104 return new FakeResultWrapper( array_values( $rows ) ); 105 } 106 } 107 108 public function newItem( $row ) { 109 if ( isset( $row->rev_id ) ) { 110 return new RevDelRevisionItem( $this, $row ); 111 } elseif ( isset( $row->ar_rev_id ) ) { 112 return new RevDelArchivedRevisionItem( $this, $row ); 113 } else { 114 // This shouldn't happen. :) 115 throw new MWException( 'Invalid row type in RevDelRevisionList' ); 116 } 117 } 118 119 public function getCurrent() { 120 if ( is_null( $this->currentRevId ) ) { 121 $dbw = wfGetDB( DB_MASTER ); 122 $this->currentRevId = $dbw->selectField( 123 'page', 'page_latest', $this->title->pageCond(), __METHOD__ ); 124 } 125 return $this->currentRevId; 126 } 127 128 public function getSuppressBit() { 129 return Revision::DELETED_RESTRICTED; 130 } 131 132 public function doPreCommitUpdates() { 133 $this->title->invalidateCache(); 134 return Status::newGood(); 135 } 136 137 public function doPostCommitUpdates() { 138 $this->title->purgeSquid(); 139 // Extensions that require referencing previous revisions may need this 140 wfRunHooks( 'ArticleRevisionVisibilitySet', array( &$this->title ) ); 141 return Status::newGood(); 142 } 143 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |