r48837 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48836‎ | r48837 | r48838 >
Date:17:52, 25 March 2009
Author:aaron
Status:resolved (Comments)
Tags:
Comment:
Fix url params for multi-item deletion by converting to CVS
Modified paths:
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRevisiondelete.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUndelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LogEventsList.php
@@ -286,12 +286,9 @@
287287 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
288288 // Different revision types use different URL params...
289289 $key = $paramArray[0];
290 - // Link to each hidden object ID, $paramArray[1] is the url param
 290+ // $paramArray[1] is a CVS of the IDs
291291 $Ids = explode( ',', $paramArray[1] );
292 - $revParams = '';
293 - foreach( $Ids as $n => $id ) {
294 - $revParams .= '&' . urlencode($key) . '[]=' . urlencode($id);
295 - }
 292+ $query = urlencode($paramArray[1]);
296293 $revert = array();
297294 // Diff link for single rev deletions
298295 if( $key === 'oldid' && count($Ids) == 1 ) {
@@ -300,22 +297,21 @@
301298 'diff='.intval($Ids[0])."&unhide=1&token=$token" );
302299 }
303300 // View/modify link...
304 - $revert[] = $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'],
305 - 'target=' . $title->getPrefixedUrl() . $revParams );
 301+ $revert[] = $this->skin->makeKnownLinkObj( $revdel,
 302+ $this->message['revdel-restore'], "$key=$query" );
 303+ // Pipe links
306304 $revert = '(' . implode(' | ',$revert) . ')';
307305 }
308306 // Hidden log items, give review link
309307 } else if( self::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
310308 if( count($paramArray) == 1 ) {
311309 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
 310+ // $paramArray[1] is a CVS of the IDs
312311 $Ids = explode( ',', $paramArray[0] );
 312+ $query = urlencode($paramArray[0]);
313313 // Link to each hidden object ID, $paramArray[1] is the url param
314 - $logParams = '';
315 - foreach( $Ids as $n => $id ) {
316 - $logParams .= '&logid[]=' . intval($id);
317 - }
318314 $revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'],
319 - 'target=' . $title->getPrefixedUrl() . $logParams ) . ')';
 315+ 'target='.$title->getPrefixedUrl()."&logid=$query" ) . ')';
320316 }
321317 // Self-created users
322318 } else if( self::typeAction($row,'newusers','create2') ) {
@@ -370,7 +366,7 @@
371367 } else {
372368 $target = SpecialPage::getTitleFor( 'Log', $row->log_type );
373369 $query = array( 'target' => $target->getPrefixedDBkey(),
374 - 'logid[]' => $row->log_id
 370+ 'logid' => $row->log_id
375371 );
376372 $del = $this->skin->revDeleteLink( $query, self::isDeleted( $row, LogPage::DELETED_RESTRICTED ) );
377373 }
Index: trunk/phase3/includes/ImagePage.php
@@ -789,7 +789,7 @@
790790 $q = array();
791791 $q[] = 'action=delete';
792792 if( !$iscur )
793 - $q[] = 'oldimage[]=' . urlencode( $img );
 793+ $q[] = 'oldimage=' . urlencode( $img );
794794 $row .= $this->skin->makeKnownLinkObj(
795795 $this->title,
796796 wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ),
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php
@@ -25,17 +25,18 @@
2626 return;
2727 }
2828 $this->skin =& $wgUser->getSkin();
29 - # Set title and such
3029 $this->setHeaders();
3130 $this->outputHeader();
3231 $this->wasPosted = $wgRequest->wasPosted();
33 - # Handle our many different possible input types
 32+ # Set title and such
3433 $this->target = $wgRequest->getText( 'target' );
35 - $this->oldids = $wgRequest->getArray( 'oldid' );
36 - $this->artimestamps = $wgRequest->getArray( 'artimestamp' );
37 - $this->logids = $wgRequest->getArray( 'logid' );
38 - $this->oldimgs = $wgRequest->getArray( 'oldimage' );
39 - $this->fileids = $wgRequest->getArray( 'fileid' );
 34+ # Handle our many different possible input types.
 35+ # Use CVS, since the cgi handling will break on arrays.
 36+ $this->oldids = array_filter( explode( ',', $wgRequest->getVal('oldid') ) );
 37+ $this->artimestamps = array_filter( explode( ',', $wgRequest->getVal('artimestamp') ) );
 38+ $this->logids = array_filter( explode( ',', $wgRequest->getVal('logid') ) );
 39+ $this->oldimgs = array_filter( explode( ',', $wgRequest->getVal('oldimage') ) );
 40+ $this->fileids = array_filter( explode( ',', $wgRequest->getVal('fileid') ) );
4041 # For reviewing deleted files...
4142 $this->file = $wgRequest->getVal( 'file' );
4243 # Only one target set at a time please!
@@ -112,11 +113,11 @@
113114 } else if( $this->deleteKey == 'logid' ) {
114115 $this->showLogItems();
115116 }
116 - # Show relevant lines from the deletion log. This will show even if said ID
117 - # does not exist...might be helpful
 117+ # Show relevant lines from the deletion log
118118 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
119119 LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText() );
120 - if( $wgUser->isAllowed( 'suppressionlog' ) ){
 120+ # Show relevant lines from the suppression log
 121+ if( $wgUser->isAllowed( 'suppressionlog' ) ) {
121122 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" );
122123 LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText() );
123124 }
@@ -155,7 +156,8 @@
156157 array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER )
157158 );
158159 if( $wgUser->isAllowed('suppressrevision') ) {
159 - $this->checks[] = array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision::DELETED_RESTRICTED );
 160+ $this->checks[] = array( 'revdelete-hide-restricted',
 161+ 'wpHideRestricted', Revision::DELETED_RESTRICTED );
160162 }
161163 }
162164
@@ -292,15 +294,14 @@
293295 Xml::hidden( 'type', $this->deleteKey )
294296 );
295297 if( $this->deleteKey=='oldid' ) {
296 - foreach( $revObjs as $rev )
297 - $hidden[] = Xml::hidden( 'oldid[]', $rev->getId() );
 298+ $hidden[] = Xml::hidden( 'oldid', implode(',',$this->oldids) );
298299 } else {
299 - foreach( $revObjs as $rev )
300 - $hidden[] = Xml::hidden( 'artimestamp[]', $rev->getTimestamp() );
 300+ $hidden[] = Xml::hidden( 'artimestamp', implode(',',$this->artimestamps) );
301301 }
302302 $special = SpecialPage::getTitleFor( 'Revisiondelete' );
303303 $wgOut->addHTML(
304 - Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
 304+ Xml::openElement( 'form', array( 'method' => 'post',
 305+ 'action' => $special->getLocalUrl( 'action=submit' ),
305306 'id' => 'mw-revdel-form-revisions' ) ) .
306307 Xml::openElement( 'fieldset' ) .
307308 xml::element( 'legend', null, wfMsg( 'revdelete-legend' ) )
@@ -423,16 +424,16 @@
424425 Xml::hidden( 'type', $this->deleteKey )
425426 );
426427 if( $this->deleteKey=='oldimage' ) {
427 - foreach( $this->ofiles as $filename )
428 - $hidden[] = Xml::hidden( 'oldimage[]', $filename );
 428+ $hidden[] = Xml::hidden( 'oldimage', implode(',',$this->oldimgs) );
429429 } else {
430 - foreach( $this->afiles as $fileid )
431 - $hidden[] = Xml::hidden( 'fileid[]', $fileid );
 430+ $hidden[] = Xml::hidden( 'fileid', implode(',',$this->fileids) );
432431 }
433432 $special = SpecialPage::getTitleFor( 'Revisiondelete' );
434433 $wgOut->addHTML(
435 - Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
436 - 'id' => 'mw-revdel-form-filerevisions' ) ) .
 434+ Xml::openElement( 'form', array( 'method' => 'post',
 435+ 'action' => $special->getLocalUrl( 'action=submit' ),
 436+ 'id' => 'mw-revdel-form-filerevisions' )
 437+ ) .
437438 Xml::fieldset( wfMsg( 'revdelete-legend' ) )
438439 );
439440
@@ -512,15 +513,14 @@
513514 $hidden = array(
514515 Xml::hidden( 'wpEditToken', $wgUser->editToken() ),
515516 Xml::hidden( 'target', $this->page->getPrefixedText() ),
516 - Xml::hidden( 'type', $this->deleteKey ) );
517 - foreach( $this->events as $logid ) {
518 - $hidden[] = Xml::hidden( 'logid[]', $logid );
519 - }
 517+ Xml::hidden( 'type', $this->deleteKey ),
 518+ Xml::hidden( 'logid', implode(',',$this->logids) )
 519+ );
520520
521521 $special = SpecialPage::getTitleFor( 'Revisiondelete' );
522522 $wgOut->addHTML(
523 - Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
524 - 'id' => 'mw-revdel-form-logs' ) ) .
 523+ Xml::openElement( 'form', array( 'method' => 'post',
 524+ 'action' => $special->getLocalUrl( 'action=submit' ), 'id' => 'mw-revdel-form-logs' ) ) .
525525 Xml::fieldset( wfMsg( 'revdelete-legend' ) )
526526 );
527527
Index: trunk/phase3/includes/specials/SpecialUndelete.php
@@ -1139,10 +1139,11 @@
11401140 if( $wgUser->isAllowed( 'deleterevision' ) ) {
11411141 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
11421142 // If revision was hidden from sysops
1143 - $revdlink = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.wfMsgHtml('rev-delundel').')' );
 1143+ $revdlink = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ),
 1144+ '('.wfMsgHtml('rev-delundel').')' );
11441145 } else {
11451146 $query = array( 'target' => $this->mTargetObj->getPrefixedUrl(),
1146 - 'artimestamp[]' => $ts
 1147+ 'artimestamp' => $ts
11471148 );
11481149 $revdlink = $sk->revDeleteLink( $query, $rev->isDeleted( Revision::DELETED_RESTRICTED ) );
11491150 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r48911Fix r48837: Add target param back, still needed in some placesaaron10:20, 27 March 2009
r55741* Fixed CR r48837. Although using ids[]=x in the query string is wrong and br...tstarling01:59, 2 September 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   23:10, 15 April 2009

This doesn't make any sense.... what's the purpose of breaking existing checkbox-compatible array convention? Recommend revert.

#Comment by Aaron Schulz (talk | contribs)   23:31, 16 April 2009

Because it was broken before :) Only one item of the array gets into query urls due to the cgi code.

#Comment by Splarka (talk | contribs)   08:48, 20 April 2009

I've marked bugzilla:18171 as 'fixed', please reopen if this "fix" gets reverted.

#Comment by Splarka (talk | contribs)   13:22, 20 April 2009
is a big jerk! (testing something)
#Comment by Zzyzx11 (talk | contribs)   03:17, 21 April 2009

Yeah, that dude is one big a-hole :D

#Comment by Zzyzx11 (talk | contribs)   03:22, 21 April 2009

But is still a great contributor... :D

#Comment by Mr.Z-man (talk | contribs)   06:10, 22 April 2009
O
#Comment by Amalthea (talk | contribs)   08:04, 30 April 2009

Testing ... if I'm reading this? :)

#Comment by Tim Starling (talk | contribs)   08:23, 8 May 2009

Flawed (as per my comment on r49408) but better than what's live already so I'm deploying it.

#Comment by Tim Starling (talk | contribs)   02:00, 2 September 2009

Fixed in r55741.

Status & tagging log