(bug 17283) Remove double URL escaping in show/hide links for log entries and Revisio...
[lhc/web/wiklou.git] / includes / specials / SpecialRevisiondelete.php
index 2fa91ae..f39f80f 100644 (file)
@@ -9,6 +9,12 @@
 
 function wfSpecialRevisiondelete( $par = null ) {
        global $wgOut, $wgRequest, $wgUser;
+       
+       if ( wfReadOnly() ) {
+               $wgOut->readOnlyPage();
+               return;
+       }
+               
        # Handle our many different possible input types
        $target = $wgRequest->getText( 'target' );
        $oldid = $wgRequest->getArray( 'oldid' );
@@ -27,12 +33,12 @@ function wfSpecialRevisiondelete( $par = null ) {
        # Only one target set at a time please!
        $i = (bool)$file + (bool)$oldid + (bool)$logid + (bool)$artimestamp + (bool)$fileid + (bool)$img;
        if( $i !== 1 ) {
-               $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
+               $wgOut->showErrorPage( 'revdelete-toomanytargets-title', 'revdelete-toomanytargets-text' );
                return;
        }
        # Logs must have a type given
        if( $logid && !strpos($page->getDBKey(),'/') ) {
-               $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
+               $wgOut->showErrorPage( 'revdelete-nologtype-title', 'revdelete-nologtype-text' );
                return;
        }
        # Either submit or create our form
@@ -101,7 +107,7 @@ class RevisionDeleteForm {
                        if( $wgUser->isAllowed('undelete') ) {
                                $undelete = SpecialPage::getTitleFor( 'Undelete' );
                                $links[] = $this->skin->makeKnownLinkObj( $undelete, wfMsgHtml( 'deletedhist' ),
-                                       wfArrayToCGI( array( 'target' => $this->page->getPrefixedUrl() ) ) );
+                                       wfArrayToCGI( array( 'target' => $this->page->getPrefixedDBkey() ) ) );
                        }
                        # Logs themselves don't have histories or archived revisions
                        $wgOut->setSubtitle( '<p>'.implode($links,' / ').'</p>' );
@@ -171,7 +177,7 @@ class RevisionDeleteForm {
                $wgOut->addWikiMsg( 'revdelete-selected', $this->page->getPrefixedText(), $count );
 
                $bitfields = 0;
-               $wgOut->addHtml( "<ul>" );
+               $wgOut->addHTML( "<ul>" );
 
                $where = $revObjs = array();
                $dbr = wfGetDB( DB_SLAVE );
@@ -183,10 +189,11 @@ class RevisionDeleteForm {
                        foreach( $this->revisions as $revid ) {
                                $where[] = intval($revid);
                        }
-                       $whereClause = 'rev_id IN(' . implode(',',$where) . ')';
                        $result = $dbr->select( array('revision','page'), '*',
-                               array( 'rev_page' => $this->page->getArticleID(),
-                                       $whereClause, 'rev_page = page_id' ),
+                               array(
+                                       'rev_page' => $this->page->getArticleID(),
+                                       'rev_id' => $where,
+                                       'rev_page = page_id' ),
                                __METHOD__ );
                        while( $row = $dbr->fetchObject( $result ) ) {
                                $revObjs[$row->rev_id] = new Revision( $row );
@@ -204,7 +211,7 @@ class RevisionDeleteForm {
                                        $UserAllowed = false;
                                }
                                $revisions++;
-                               $wgOut->addHtml( $this->historyLine( $revObjs[$revid] ) );
+                               $wgOut->addHTML( $this->historyLine( $revObjs[$revid] ) );
                                $bitfields |= $revObjs[$revid]->mDeleted;
                        }
                // The archives...
@@ -213,11 +220,11 @@ class RevisionDeleteForm {
                        foreach( $this->archrevs as $timestamp ) {
                                $where[] = $dbr->addQuotes( $timestamp );
                        }
-                       $whereClause = 'ar_timestamp IN(' . implode(',',$where) . ')';
                        $result = $dbr->select( 'archive', '*',
-                               array( 'ar_namespace' => $this->page->getNamespace(),
+                               array(
+                                       'ar_namespace' => $this->page->getNamespace(),
                                        'ar_title' => $this->page->getDBKey(),
-                                               $whereClause ),
+                                       'ar_timestamp' => $where ),
                                __METHOD__ );
                        while( $row = $dbr->fetchObject( $result ) ) {
                                $revObjs[$row->ar_timestamp] = new Revision( array(
@@ -245,7 +252,7 @@ class RevisionDeleteForm {
                                        $UserAllowed = false;
                                }
                                $revisions++;
-                               $wgOut->addHtml( $this->historyLine( $revObjs[$timestamp] ) );
+                               $wgOut->addHTML( $this->historyLine( $revObjs[$timestamp] ) );
                                $bitfields |= $revObjs[$timestamp]->mDeleted;
                        }
                }
@@ -254,7 +261,7 @@ class RevisionDeleteForm {
                        return;
                }
                
-               $wgOut->addHtml( "</ul>" );
+               $wgOut->addHTML( "</ul>" );
 
                $wgOut->addWikiMsg( 'revdelete-text' );
 
@@ -278,7 +285,7 @@ class RevisionDeleteForm {
                                $hidden[] = Xml::hidden( 'artimestamp[]', $rev->getTimestamp() );
                }
                $special = SpecialPage::getTitleFor( 'Revisiondelete' );
-               $wgOut->addHtml(
+               $wgOut->addHTML(
                        Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ), 
                                'id' => 'mw-revdel-form-revisions' ) ) .
                        Xml::openElement( 'fieldset' ) .
@@ -287,15 +294,15 @@ class RevisionDeleteForm {
                // FIXME: all items checked for just one rev are checked, even if not set for the others
                foreach( $this->checks as $item ) {
                        list( $message, $name, $field ) = $item;
-                       $wgOut->addHtml( Xml::tags( 'div', null, Xml::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
+                       $wgOut->addHTML( Xml::tags( 'div', null, Xml::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
                }
                foreach( $items as $item ) {
-                       $wgOut->addHtml( Xml::tags( 'p', null, $item ) );
+                       $wgOut->addHTML( Xml::tags( 'p', null, $item ) );
                }
                foreach( $hidden as $item ) {
-                       $wgOut->addHtml( $item );
+                       $wgOut->addHTML( $item );
                }
-               $wgOut->addHtml(
+               $wgOut->addHTML(
                        Xml::closeElement( 'fieldset' ) .
                        Xml::closeElement( 'form' ) . "\n"
                );
@@ -317,7 +324,7 @@ class RevisionDeleteForm {
                        $wgLang->formatNum($count) );
 
                $bitfields = 0;
-               $wgOut->addHtml( "<ul>" );
+               $wgOut->addHTML( "<ul>" );
 
                $where = $filesObjs = array();
                $dbr = wfGetDB( DB_SLAVE );
@@ -326,12 +333,12 @@ class RevisionDeleteForm {
                if( $this->deleteKey=='oldimage' ) {
                        // Run through and pull all our data in one query
                        foreach( $this->ofiles as $timestamp ) {
-                               $where[] = $dbr->addQuotes( $timestamp.'!'.$this->page->getDbKey() );
+                               $where[] = $dbr->addQuotes( $timestamp.'!'.$this->page->getDBKey() );
                        }
-                       $whereClause = 'oi_archive_name IN(' . implode(',',$where) . ')';
                        $result = $dbr->select( 'oldimage', '*',
-                               array( 'oi_name' => $this->page->getDbKey(),
-                                       $whereClause ),
+                               array(
+                                       'oi_name' => $this->page->getDBKey(),
+                                       'oi_archive_name' => $where ),
                                __METHOD__ );
                        while( $row = $dbr->fetchObject( $result ) ) {
                                $filesObjs[$row->oi_archive_name] = RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row );
@@ -340,7 +347,7 @@ class RevisionDeleteForm {
                        }
                        // Check through our images
                        foreach( $this->ofiles as $timestamp ) {
-                               $archivename = $timestamp.'!'.$this->page->getDbKey();
+                               $archivename = $timestamp.'!'.$this->page->getDBKey();
                                if( !isset($filesObjs[$archivename]) ) {
                                        continue;
                                } else if( !$filesObjs[$archivename]->userCan(File::DELETED_RESTRICTED) ) {
@@ -353,7 +360,7 @@ class RevisionDeleteForm {
                                }
                                $revisions++;
                                // Inject history info
-                               $wgOut->addHtml( $this->fileLine( $filesObjs[$archivename] ) );
+                               $wgOut->addHTML( $this->fileLine( $filesObjs[$archivename] ) );
                                $bitfields |= $filesObjs[$archivename]->deleted;
                        }
                // Archived files...
@@ -362,10 +369,10 @@ class RevisionDeleteForm {
                        foreach( $this->afiles as $id ) {
                                $where[] = intval($id);
                        }
-                       $whereClause = 'fa_id IN(' . implode(',',$where) . ')';
                        $result = $dbr->select( 'filearchive', '*',
-                               array( 'fa_name' => $this->page->getDbKey(),
-                                       $whereClause ),
+                               array(
+                                       'fa_name' => $this->page->getDBKey(),
+                                       'fa_id' => $where ),
                                __METHOD__ );
                        while( $row = $dbr->fetchObject( $result ) ) {
                                $filesObjs[$row->fa_id] = ArchivedFile::newFromRow( $row );
@@ -384,7 +391,7 @@ class RevisionDeleteForm {
                                }
                                $revisions++;
                                // Inject history info
-                               $wgOut->addHtml( $this->archivedfileLine( $filesObjs[$fileid] ) );
+                               $wgOut->addHTML( $this->archivedfileLine( $filesObjs[$fileid] ) );
                                $bitfields |= $filesObjs[$fileid]->deleted;
                        }
                }
@@ -393,7 +400,7 @@ class RevisionDeleteForm {
                        return;
                }
                
-               $wgOut->addHtml( "</ul>" );
+               $wgOut->addHTML( "</ul>" );
 
                $wgOut->addWikiMsg('revdelete-text' );
                //Normal sysops can always see what they did, but can't always change it
@@ -416,7 +423,7 @@ class RevisionDeleteForm {
                                $hidden[] = Xml::hidden( 'fileid[]', $fileid );
                }
                $special = SpecialPage::getTitleFor( 'Revisiondelete' );
-               $wgOut->addHtml(
+               $wgOut->addHTML(
                        Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ), 
                                'id' => 'mw-revdel-form-filerevisions' ) ) .
                        Xml::fieldset( wfMsg( 'revdelete-legend' ) )
@@ -424,16 +431,16 @@ class RevisionDeleteForm {
                // FIXME: all items checked for just one file are checked, even if not set for the others
                foreach( $this->checks as $item ) {
                        list( $message, $name, $field ) = $item;
-                       $wgOut->addHtml( Xml::tags( 'div', null, Xml::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
+                       $wgOut->addHTML( Xml::tags( 'div', null, Xml::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
                }
                foreach( $items as $item ) {
-                       $wgOut->addHtml( "<p>$item</p>" );
+                       $wgOut->addHTML( "<p>$item</p>" );
                }
                foreach( $hidden as $item ) {
-                       $wgOut->addHtml( $item );
+                       $wgOut->addHTML( $item );
                }
 
-               $wgOut->addHtml(
+               $wgOut->addHTML(
                        Xml::closeElement( 'fieldset' ) .
                        Xml::closeElement( 'form' ) . "\n"
                );
@@ -449,7 +456,7 @@ class RevisionDeleteForm {
                $wgOut->addWikiMsg( 'logdelete-selected', $wgLang->formatNum( count($this->events) ) );
 
                $bitfields = 0;
-               $wgOut->addHtml( "<ul>" );
+               $wgOut->addHTML( "<ul>" );
 
                $where = $logRows = array();
                $dbr = wfGetDB( DB_SLAVE );
@@ -459,9 +466,10 @@ class RevisionDeleteForm {
                        $where[] = intval($logid);
                }
                list($log,$logtype) = explode( '/',$this->page->getDBKey(), 2 );
-               $whereClause = "log_type = '$logtype' AND log_id IN(" . implode(',',$where) . ")";
                $result = $dbr->select( 'logging', '*',
-                       array( $whereClause ),
+                       array(
+                               'log_type' => $logtype,
+                               'log_id' => $where ),
                        __METHOD__ );
                while( $row = $dbr->fetchObject( $result ) ) {
                        $logRows[$row->log_id] = $row;
@@ -480,15 +488,15 @@ class RevisionDeleteForm {
                                $UserAllowed = false;
                        }
                        $logItems++;
-                       $wgOut->addHtml( $this->logLine( $logRows[$logid] ) );
+                       $wgOut->addHTML( $this->logLine( $logRows[$logid] ) );
                        $bitfields |= $logRows[$logid]->log_deleted;
                }
                if( !$logItems ) {
-                       $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
+                       $wgOut->showErrorPage( 'revdelete-nologid-title', 'revdelete-nologid-text' );
                        return;
                }
                
-               $wgOut->addHtml( "</ul>" );
+               $wgOut->addHTML( "</ul>" );
 
                $wgOut->addWikiMsg( 'revdelete-text' );
                // Normal sysops can always see what they did, but can't always change it
@@ -506,7 +514,7 @@ class RevisionDeleteForm {
                }
 
                $special = SpecialPage::getTitleFor( 'Revisiondelete' );
-               $wgOut->addHtml(
+               $wgOut->addHTML(
                        Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ), 
                                'id' => 'mw-revdel-form-logs' ) ) .
                        Xml::fieldset( wfMsg( 'revdelete-legend' ) )
@@ -514,16 +522,16 @@ class RevisionDeleteForm {
                // FIXME: all items checked for just on event are checked, even if not set for the others
                foreach( $this->checks as $item ) {
                        list( $message, $name, $field ) = $item;
-                       $wgOut->addHtml( Xml::tags( 'div', null, Xml::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
+                       $wgOut->addHTML( Xml::tags( 'div', null, Xml::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
                }
                foreach( $items as $item ) {
-                       $wgOut->addHtml( "<p>$item</p>" );
+                       $wgOut->addHTML( "<p>$item</p>" );
                }
                foreach( $hidden as $item ) {
-                       $wgOut->addHtml( $item );
+                       $wgOut->addHTML( $item );
                }
 
-               $wgOut->addHtml(
+               $wgOut->addHTML(
                        Xml::closeElement( 'fieldset' ) .
                        Xml::closeElement( 'form' ) . "\n"
                );
@@ -606,7 +614,7 @@ class RevisionDeleteForm {
         * @returns string
         */
        private function archivedfileLine( $file ) {
-               global $wgLang, $wgTitle;
+               global $wgLang;
 
                $target = $this->page->getPrefixedText();
                $date = $wgLang->timeanddate( $file->getTimestamp(), true  );
@@ -812,10 +820,10 @@ class RevisionDeleter {
                foreach( $items as $revid ) {
                        $where[] = intval($revid);
                }
-               $whereClause = 'rev_id IN(' . implode(',',$where) . ')';
                $result = $this->dbw->select( 'revision', '*',
-                       array( 'rev_page' => $title->getArticleID(),
-                               $whereClause ),
+                       array(
+                               'rev_page' => $title->getArticleID(),
+                               'rev_id' => $where ),
                        __METHOD__ );
                while( $row = $this->dbw->fetchObject( $result ) ) {
                        $revObjs[$row->rev_id] = new Revision( $row );
@@ -871,11 +879,11 @@ class RevisionDeleter {
                foreach( $items as $timestamp ) {
                        $where[] = $this->dbw->addQuotes( $timestamp );
                }
-               $whereClause = 'ar_timestamp IN(' . implode(',',$where) . ')';
                $result = $this->dbw->select( 'archive', '*',
-                       array( 'ar_namespace' => $title->getNamespace(),
+                       array(
+                               'ar_namespace' => $title->getNamespace(),
                                'ar_title' => $title->getDBKey(),
-                                       $whereClause ),
+                               'ar_timestamp' => $where ),
                        __METHOD__ );
                while( $row = $this->dbw->fetchObject( $result ) ) {
                        $revObjs[$row->ar_timestamp] = new Revision( array(
@@ -939,12 +947,12 @@ class RevisionDeleter {
                $set = array();
                // Run through and pull all our data in one query
                foreach( $items as $timestamp ) {
-                       $where[] = $this->dbw->addQuotes( $timestamp.'!'.$title->getDbKey() );
+                       $where[] = $this->dbw->addQuotes( $timestamp.'!'.$title->getDBKey() );
                }
-               $whereClause = 'oi_archive_name IN(' . implode(',',$where) . ')';
                $result = $this->dbw->select( 'oldimage', '*',
-                       array( 'oi_name' => $title->getDbKey(),
-                               $whereClause ),
+                       array(
+                               'oi_name' => $title->getDBKey(),
+                               'oi_archive_name' => $where ),
                        __METHOD__ );
                while( $row = $this->dbw->fetchObject( $result ) ) {
                        $filesObjs[$row->oi_archive_name] = RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row );
@@ -953,7 +961,7 @@ class RevisionDeleter {
                }
                // To work!
                foreach( $items as $timestamp ) {
-                       $archivename = $timestamp.'!'.$title->getDbKey();
+                       $archivename = $timestamp.'!'.$title->getDBKey();
                        if( !isset($filesObjs[$archivename]) ) {
                                $success = false;
                                continue; // Must exist
@@ -1034,10 +1042,9 @@ class RevisionDeleter {
                foreach( $items as $id ) {
                        $where[] = intval($id);
                }
-               $whereClause = 'fa_id IN(' . implode(',',$where) . ')';
                $result = $this->dbw->select( 'filearchive', '*',
-                       array( 'fa_name' => $title->getDbKey(),
-                               $whereClause ),
+                       array( 'fa_name' => $title->getDBKey(),
+                               'fa_id' => $where ),
                        __METHOD__ );
                while( $row = $this->dbw->fetchObject( $result ) ) {
                        $filesObjs[$row->fa_id] = ArchivedFile::newFromRow( $row );
@@ -1091,9 +1098,10 @@ class RevisionDeleter {
                        $where[] = intval($logid);
                }
                list($log,$logtype) = explode( '/',$title->getDBKey(), 2 );
-               $whereClause = "log_type ='$logtype' AND log_id IN(" . implode(',',$where) . ")";
                $result = $this->dbw->select( 'logging', '*',
-                       array( $whereClause ),
+                       array(
+                               'log_type' => $logtype,
+                               'log_id' => $where ),
                        __METHOD__ );
                while( $row = $this->dbw->fetchObject( $result ) ) {
                        $logRows[$row->log_id] = $row;