r20570 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20569‎ | r20570 | r20571 >
Date:07:41, 21 March 2007
Author:nickj
Status:old
Tags:
Comment:
Reverting SpecialRevisiondelete.php back to r17880, to fix bug 9336 ( "Special:Revisiondelete broken in SVN head" )
The problem is that includes/SpecialRevisiondelete.php was in an inconsistent state - it was updated in r20446
(merge of rev_deleted branch), and then partially reverted in r20525 (i.e. there was some unintentional cruft left
over, including the change in the constructor params), and as a result stuff like
http://Hostname-Of-Wiki/wiki/index.php?title=Special:Revisiondelete&target=Main_Page&oldid=X would die with fatal
errors. (The diff between the before and after is shown here:
r1=17880&r2=20525">http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/SpecialRevisiondelete.php?r1=17880&r2=20525 ,
or from the command line, try: svn diff --revision 17880:20525 includes/SpecialRevisiondelete.php | less )

I'm unsure whether I should be updating RELEASE-NOTES, but I'm leaning towards 'no', on the basis that no end-user
encountered this (cluster is on r20145), and that (hopefully) there should be are no user-visible changes as
a result of this revert.
Modified paths:
  • /trunk/phase3/includes/SpecialRevisiondelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialRevisiondelete.php
@@ -40,259 +40,52 @@
4141 * @param Title $page
4242 * @param int $oldid
4343 */
44 - function __construct( $request, $oldid, $logid, $arid, $fileid ) {
 44+ function __construct( $request ) {
4545 global $wgUser;
4646
47 - $target = $request->getText( 'target' );
48 - $this->page = Title::newFromUrl( $target, false );
 47+ $target = $request->getVal( 'target' );
 48+ $this->page = Title::newFromUrl( $target );
4949
5050 $this->revisions = $request->getIntArray( 'oldid', array() );
51 - $this->events = $request->getIntArray( 'logid', array() );
52 - $this->archrevs = $request->getIntArray( 'arid', array() );
53 - $this->files = $request->getIntArray( 'fileid', array() );
5451
5552 $this->skin = $wgUser->getSkin();
56 -
57 - // log events don't have text to hide, but hiding the page name is useful
58 - if ( $fileid ) {
59 - $hide_text_name = array( 'revdelete-hide-image', 'wpHideImage', Image::DELETED_FILE );
60 - $this->deletetype='file';
61 - } else if ( $logid ) {
62 - $hide_text_name = array( 'revdelete-hide-name', 'wpHideName', LogViewer::DELETED_ACTION );
63 - $this->deletetype='log';
64 - } else {
65 - $hide_text_name = array( 'revdelete-hide-text', 'wpHideText', Revision::DELETED_TEXT );
66 - if ( $arid ) $this->deletetype='ar';
67 - else $this->deletetype='old';
68 - }
6953 $this->checks = array(
70 - $hide_text_name,
 54+ array( 'revdelete-hide-text', 'wpHideText', Revision::DELETED_TEXT ),
7155 array( 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ),
7256 array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER ),
7357 array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision::DELETED_RESTRICTED ) );
7458 }
7559
7660 /**
77 - * This sets any fields that are true to a bitfield to true on a given bitfield
78 - * @param $bitfield, running bitfield
79 - * @param $nbitfield, new bitfiled
80 - */
81 - function setBitfield( $bitfield, $nbitfield ) {
82 - if ( $nbitfield & Revision::DELETED_TEXT) $bitfield |= Revision::DELETED_TEXT;
83 - if ( $nbitfield & LogViewer::DELETED_ACTION) $bitfield |= LogViewer::DELETED_ACTION;
84 - if ( $nbitfield & Image::DELETED_FILE) $bitfield |= Image::DELETED_FILE;
85 - if ( $nbitfield & Revision::DELETED_COMMENT) $bitfield |= Revision::DELETED_COMMENT;
86 - if ( $nbitfield & Revision::DELETED_USER) $bitfield |= Revision::DELETED_USER;
87 - if ( $nbitfield & Revision::DELETED_RESTRICTED) $bitfield |= Revision::DELETED_RESTRICTED;
88 - return $bitfield;
89 - }
90 -
91 - /**
92 - * This lets a user set restrictions for live and archived revisions
9361 * @param WebRequest $request
9462 */
95 - function showRevs( $request ) {
96 - global $wgOut, $wgUser, $action;
 63+ function show( $request ) {
 64+ global $wgOut, $wgUser;
9765
98 - $UserAllowed = true;
99 - $wgOut->addWikiText( wfMsgExt( 'revdelete-selected', 'parseinline', $this->page->getPrefixedText(), count( $this->revisions) ) );
100 -
101 - $bitfields = 0;
102 - $wgOut->addHtml( "<ul>" );
103 - if ( $this->deletetype=='old') {
104 - foreach( $this->revisions as $revid ) {
105 - $rev = Revision::newFromTitle( $this->page, $revid );
106 - // Hiding top revisison is bad
107 - if( !isset( $rev ) || $rev->isCurrent() ) {
108 - $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
109 - return;
110 - } else if( !$rev->userCan(Revision::DELETED_RESTRICTED) ) {
111 - // If a rev is hidden from sysops
112 - if ( $action != 'submit') {
113 - $wgOut->permissionRequired( 'hiderevision' ); return;
114 - }
115 - $UserAllowed=false;
116 - }
117 - $wgOut->addHtml( $this->historyLine( $rev ) );
118 - $bitfields = $this->setBitfield( $bitfields, $rev->mDeleted );
119 - }
120 - } else if ( $this->deletetype=='ar') {
121 - $archive = new PageArchive( $this->page );
122 - foreach( $this->archrevs as $revid ) {
123 - $rev = $archive->getRevision('', $revid );
124 - if( !isset( $rev ) ) {
125 - $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
126 - return;
127 - } else if( !$rev->userCan(Revision::DELETED_RESTRICTED) ) {
128 - //if a rev is hidden from sysops
129 - if ( $action != 'submit') {
130 - $wgOut->permissionRequired( 'hiderevision' ); return;
131 - }
132 - $UserAllowed=false;
133 - }
134 - $wgOut->addHtml( $this->historyLine( $rev ) );
135 - $bitfields = $this->setBitfield( $bitfields, $rev->mDeleted );
136 - }
137 - }
138 - $wgOut->addHtml( "</ul>" );
 66+ $wgOut->addWikiText( wfMsg( 'revdelete-selected', $this->page->getPrefixedText() ) );
13967
140 - $wgOut->addWikiText( wfMsgHtml( 'revdelete-text' ) );
141 - //Normal sysops can always see what they did, but can't always change it
142 - if ( !$UserAllowed ) return;
143 -
144 - $items = array(
145 - wfInputLabel( wfMsgHtml( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
146 - wfSubmitButton( wfMsgHtml( 'revdelete-submit' ) ) );
147 - $hidden = array(
148 - wfHidden( 'wpEditToken', $wgUser->editToken() ),
149 - wfHidden( 'target', $this->page->getPrefixedText() ),
150 - wfHidden( 'type', $this->deletetype ) );
151 - if( $this->deletetype=='old' ) {
152 - foreach( $this->revisions as $revid ) {
153 - $hidden[] = wfHidden( 'oldid[]', $revid );
154 - }
155 - } else if( $this->deletetype=='ar' ) {
156 - foreach( $this->archrevs as $revid ) {
157 - $hidden[] = wfHidden( 'arid[]', $revid );
158 - }
159 - }
160 - $special = SpecialPage::getTitleFor( 'Revisiondelete' );
161 - $wgOut->addHtml( wfElement( 'form', array(
162 - 'method' => 'post',
163 - 'action' => $special->getLocalUrl( 'action=submit' ) ),
164 - null ) );
165 -
166 - $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'revdelete-legend' ) . '</legend>' );
167 - // FIXME: all items checked for just one rev are checked, even if not set for the others
168 - foreach( $this->checks as $item ) {
169 - list( $message, $name, $field ) = $item;
170 - $wgOut->addHtml( '<div>' .
171 - wfCheckLabel( wfMsgHtml( $message), $name, $name, $bitfields & $field ) .
172 - '</div>' );
173 - }
174 - $wgOut->addHtml( '</fieldset>' );
175 - foreach( $items as $item ) {
176 - $wgOut->addHtml( '<p>' . $item . '</p>' );
177 - }
178 - foreach( $hidden as $item ) {
179 - $wgOut->addHtml( $item );
180 - }
181 -
182 - $wgOut->addHtml( '</form>' );
183 - }
184 -
185 - /**
186 - * This lets a user set restrictions for archived images
187 - * @param WebRequest $request
188 - */
189 - function showImages( $request ) {
190 - global $wgOut, $wgUser, $action;
191 -
192 - $UserAllowed = true;
193 - $wgOut->addWikiText( wfMsgExt( 'revdelete-selected', 'parseline', $this->page->getPrefixedText(), count( $this->files ) ) );
194 -
195 - $bitfields = 0;
19668 $wgOut->addHtml( "<ul>" );
197 - foreach( $this->files as $fileid ) {
198 - $file = new FSarchivedFile( $this->page, $fileid );
199 - if( !isset( $file->mId ) ) {
200 - $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
201 - return;
202 - } else if( !$file->userCan(Revision::DELETED_RESTRICTED) ) {
203 - // If a rev is hidden from sysops
204 - if ( $action != 'submit') {
205 - $wgOut->permissionRequired( 'hiderevision' ); return;
206 - }
207 - $UserAllowed=false;
208 - }
209 - $wgOut->addHtml( $this->uploadLine( $file ) );
210 - $bitfields = $this->setBitfield( $bitfields, $file->mDeleted );
211 - }
212 - $wgOut->addHtml( "</ul>" );
213 -
214 - $wgOut->addWikiText( wfMsgHtml( 'revdelete-text' ) );
215 - //Normal sysops can always see what they did, but can't always change it
216 - if ( !$UserAllowed ) return;
217 -
218 - $items = array(
219 - wfInputLabel( wfMsgHtml( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
220 - wfSubmitButton( wfMsgHtml( 'revdelete-submit' ) ) );
221 - $hidden = array(
222 - wfHidden( 'wpEditToken', $wgUser->editToken() ),
223 - wfHidden( 'target', $this->page->getPrefixedText() ),
224 - wfHidden( 'type', $this->deletetype ) );
225 - foreach( $this->files as $fileid ) {
226 - $hidden[] = wfHidden( 'fileid[]', $fileid );
227 - }
228 - $special = SpecialPage::getTitleFor( 'Revisiondelete' );
229 - $wgOut->addHtml( wfElement( 'form', array(
230 - 'method' => 'post',
231 - 'action' => $special->getLocalUrl( 'action=submit' ) ),
232 - null ) );
233 -
234 - $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'revdelete-legend' ) . '</legend>' );
235 - // FIXME: all items checked for just one file are checked, even if not set for the others
236 - foreach( $this->checks as $item ) {
237 - list( $message, $name, $field ) = $item;
238 - $wgOut->addHtml( '<div>' .
239 - wfCheckLabel( wfMsgHtml( $message), $name, $name, $bitfields & $field ) .
240 - '</div>' );
241 - }
242 - $wgOut->addHtml( '</fieldset>' );
243 - foreach( $items as $item ) {
244 - $wgOut->addHtml( '<p>' . $item . '</p>' );
245 - }
246 - foreach( $hidden as $item ) {
247 - $wgOut->addHtml( $item );
248 - }
249 -
250 - $wgOut->addHtml( '</form>' );
251 - }
252 -
253 - /**
254 - * This lets a user set restrictions for log items
255 - * @param WebRequest $request
256 - */
257 - function showEvents( $request ) {
258 - global $wgOut, $wgUser, $action;
259 -
260 - $UserAllowed = true;
261 - $wgOut->addWikiText( wfMsgExt( 'logdelete-selected', 'parseinline', $this->page->getPrefixedText(), count( $this->events ) ) );
262 -
263 - $bitfields = 0;
264 - $wgOut->addHtml( "<ul>" );
265 - foreach( $this->events as $logid ) {
266 - $log = new LogViewer( $wgRequest );
267 - $event = LogReader::newFromTitle( $this->page, $logid );
268 - // Don't hide from oversight log!!!
269 - if( !isset( $event ) || $event->log_type == 'oversight' ) {
 69+ foreach( $this->revisions as $revid ) {
 70+ $rev = Revision::newFromTitle( $this->page, $revid );
 71+ if( !isset( $rev ) ) {
27072 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
27173 return;
272 - } else if( !$log->userCan($event, Revision::DELETED_RESTRICTED) ) {
273 - // If an event is hidden from sysops
274 - if ( $action != 'submit') {
275 - $wgOut->permissionRequired( 'hiderevision' ); return;
276 - }
277 - $UserAllowed=false;
27874 }
279 - $wgOut->addHtml( $this->logLine( $log, $event ) );
280 - $bitfields = $this->setBitfield( $bitfields, $event->log_deleted );
 75+ $wgOut->addHtml( $this->historyLine( $rev ) );
 76+ $bitfields[] = $rev->mDeleted; // FIXME
28177 }
28278 $wgOut->addHtml( "</ul>" );
283 -
284 - $wgOut->addWikiText( wfMsgHtml( 'revdelete-text' ) );
285 - //Normal sysops can always see what they did, but can't always change it
286 - if ( !$UserAllowed ) return;
 79+
 80+ $wgOut->addWikiText( wfMsg( 'revdelete-text' ) );
28781
28882 $items = array(
289 - wfInputLabel( wfMsgHtml( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
290 - wfSubmitButton( wfMsgHtml( 'revdelete-submit' ) ) );
 83+ wfInputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
 84+ wfSubmitButton( wfMsg( 'revdelete-submit' ) ) );
29185 $hidden = array(
29286 wfHidden( 'wpEditToken', $wgUser->editToken() ),
293 - wfHidden( 'target', $this->page->getPrefixedText() ),
294 - wfHidden( 'type', $this->deletetype ) );
295 - foreach( $this->events as $logid ) {
296 - $hidden[] = wfHidden( 'logid[]', $logid );
 87+ wfHidden( 'target', $this->page->getPrefixedText() ) );
 88+ foreach( $this->revisions as $revid ) {
 89+ $hidden[] = wfHidden( 'oldid[]', $revid );
29790 }
29891
29992 $special = SpecialPage::getTitleFor( 'Revisiondelete' );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r17880Code housekeeping stuff (and barring any stuff-ups on my behalf, there should...nickj08:25, 23 November 2006
r20145Revert of r20085, breaks retrieval with GET and subpage syntax, which breaks ...tstarling17:36, 5 March 2007
r20446*Merge in phase3_rev_deleted/includesaaron15:50, 14 March 2007
r20525For now revert the rev_deleted branch merge; don't want trunk to get too far ...brion16:01, 16 March 2007