Filip has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/326521 )

Change subject: Replaced "Revision::getText()" depracated in MediaWiki 1.21
......................................................................

Replaced "Revision::getText()" depracated in MediaWiki 1.21

"Revision::getText()" is deprecated in MediaWiki 1.21. Replaced usage

Bug: T151973
Change-Id: Ie50fa94709c46d1f21ab65199a58b0aaa9a049af
---
M SpecialPremoderation.php
1 file changed, 77 insertions(+), 76 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Premoderation 
refs/changes/21/326521/1

diff --git a/SpecialPremoderation.php b/SpecialPremoderation.php
index e334a90..46b5c01 100644
--- a/SpecialPremoderation.php
+++ b/SpecialPremoderation.php
@@ -5,11 +5,11 @@
        protected $mRequest = array();
        protected $mSummary = '';
        public $mAllowedStatus = array( 'new', 'approved', 'declined' );
-       
+
        function __construct() {
                global $wgRequest;
                parent::__construct( 'Premoderation', 'premoderation' );
-               
+
                if( $wgRequest->wasPosted() ) {
                        $this->mPosted = true;
                        $this->mRequest = $wgRequest->getValues();
@@ -22,7 +22,7 @@
 
        public function execute( $subpage ) {
                global $wgUser, $wgOut;
-               
+
                if( !$wgUser->isAllowed( 'premoderation' ) ) {
                        $this->displayRestrictionError();
                        return;
@@ -34,44 +34,44 @@
                if( $wgUser->isBlocked() ) {
                        throw new UserBlockedError( 
$this->getUser()->getBlock() );
                }
-               
+
                $params = array_values( explode( '/', $subpage ) );
                $action = array_shift( $params );
-               
+
                if( $action == '' ) {
                        $action = 'list';
                } elseif( isset( $params ) ) {
                        $this->mParams = Premoderation::formatParams( $params );
                }
-               
+
                switch( $action ) {
                        case 'list':
                                $this->showList();
                                break;
-                               
+
                        case 'status':
                                ( $this->mPosted ) ? $this->performChanges() : 
$this->statusInterface();
                                break;
-                               
+
                        default:
                                $wgOut->setPageTitle( $this->msg( 
'premoderation-manager-invalidaction' ) );
                                $wgOut->addWikiMsg( 
'premoderation-invalidaction' );
                }
        }
-       
+
        protected function showList() {
                global $wgOut, $wgArticlePath;
-               
+
                $wgOut->setPageTitle( $this->msg( 
'premoderation-manager-mainpage' ) );
                $wgOut->addWikiMsg( 'premoderation-list-intro' );
-               
+
                $dbr = wfGetDB( DB_SLAVE );
                $params = $this->mParams;
                $conds = 'pmq_status <> "approved"';
                if( isset( $params['offset'] ) ) {
                        $conds .= ' AND pmq_timestamp < ' . $dbr->addQuotes( 
$params['offset'] );
                }
-               
+
                $res = $dbr->select(
                        'pm_queue',
                        array(
@@ -83,7 +83,7 @@
                        __METHOD__,
                        array( 'ORDER BY' => 'pmq_timestamp DESC', 'LIMIT' => 
101 )
                );
-               
+
                $result = array();
                for( $a = 0; $a < 101; $a++ ) {
                        $row = $dbr->fetchRow( $res );
@@ -97,39 +97,39 @@
                        $status = $row['pmq_status'];
                        $result[$status][] = $row;
                }
-               
+
                if( isset( $offset ) ) {
                        $wgOut->addHtml( Linker::link( $this->getPageTitle( 
"list/offset/$offset" ),
                                $this->msg( 'premoderation-next' )->escaped() ) 
);
                }
-               
+
                if( isset( $result['new'] ) ) {
                        $msg = $this->msg( 'premoderation-list-new-h2' 
)->text();
                        $wgOut->addWikiText( '<h2>' . $msg . '</h2>' );
-                       
+
                        $output = $this->getListTableHeader( 'new' );
                        foreach( $result['new'] as $row ) {
                                $output .= $this->formatListTableRow( $row );
                        }
                        $output .= Xml::closeElement( 'table' );
-                       
+
                        $wgOut->addHTML( $output );
                }
-               
+
                if( isset( $result['declined'] ) ) {
                        $msg = $this->msg( 'premoderation-list-declined-h2' 
)->text();
                        $wgOut->addWikiText( '<h2>' . $msg . '</h2>' );
-                       
+
                        $output = $this->getListTableHeader( 'declined' );
                        foreach( $result['declined'] as $row ) {
                                $output .= $this->formatListTableRow( $row );
                        }
                        $output .= Xml::closeElement( 'table' );
-                       
+
                        $wgOut->addHTML( $output );
-               }               
+               }
        }
-       
+
        protected function getListTableHeader( $type ) {
                return Xml::openElement( 'table', array( 'id' => 'prem-table-' 
. $type,
                        'class' => 'wikitable', 'style' => 'width: 90%' ) ) .
@@ -139,7 +139,7 @@
                        '<th>' . $this->msg( 'premoderation-table-list-summary' 
)->escaped() . '</th>' .
                        '<th>' . $this->msg( 'premoderation-table-list-status' 
)->escaped() . '</th><tr>';
        }
-       
+
        protected function formatListTableRow( $row ) {
                global $wgLang;
 
@@ -152,21 +152,21 @@
                        '</td><td>' . ( $row['pmq_minor'] == 0 ? '' : ' ' . 
$this->msg( 'minoreditletter' )->escaped() ) . '</td>' .
                        '<td>' . $row['pmq_summary'] . '</td><td>' .
                        Linker::link( $this->getPageTitle( "status/id/" . 
$row['pmq_id'] ),
-                       wfMessage( 'premoderation-status-' . $row['pmq_status'] 
. 
+                       wfMessage( 'premoderation-status-' . $row['pmq_status'] 
.
                        ( $row['pmq_updated_user_text'] ? '-changed' : '-added' 
),
                        array( $row['pmq_updated_user_text'] ) )->escaped() ) . 
'</td></tr>';
        }
-       
+
        protected function statusInterface() {
                global $wgOut, $wgUser, $wgPremoderationStrict;
-               
+
                $params = $this->mParams;
                if( !isset( $params['id'] ) ) {
                        $wgOut->setPageTitle( $this->msg( 
'premoderation-manager-invalidaction' ) );
                        $wgOut->addWikiMsg( 'premoderation-invalidaction' );
-                       return;         
+                       return;
                }
-               
+
                $id = intval( $params['id'] );
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select(
@@ -182,66 +182,67 @@
                        $wgOut->addWikiMsg( 'premoderation-notexists-id' );
                        return;
                }
-               
+
                $wgOut->setPageTitle( $this->msg( 
'premoderation-manager-status' ) );
                $wgOut->addWikiMsg( 'premoderation-status-intro' );
-               
+
                $wgOut->addHTML( '<h2>' . $this->msg( 
'premoderation-status-info' )->escaped() . '</h2>' .
                        $this->getListTableHeader( 'status' ) . 
$this->formatListTableRow( $row ) .
                        Xml::closeElement( 'table' ) );
-               
+
                if( $wgUser->isAllowed( 'premoderation-viewip' ) ) {
                        $wgOut->addWikiMsg( 'premoderation-private-ip', 
$row['pmq_ip'] );
                }
-               
+
                $rev = Revision::newFromID( $row['pmq_page_last_id'] );
                $diff = new DifferenceEngine();
                $diff->showDiffStyle();
+               $content = $rev->getContent();
                $formattedDiff = $diff->generateTextDiffBody(
-                       isset( $rev ) ? $rev->getText() : '', $row['pmq_text']
+                       isset( $rev ) ? ContentHandler::getContentText( 
$content ) : '', $row['pmq_text']
                );
-               
+
                $wgOut->addHTML( '<h2>' . $this->msg( 'premoderation-diff-h2' 
)->escaped() . '</h2>' .
                        "<table class='mw-abusefilter-diff-multiline'><col 
class='diff-marker' />" .
                        "<col class='diff-content' /><col class='diff-marker' 
/><col class='diff-content' />" .
                        "<tbody>" . $formattedDiff . "</tbody></table>" );
-               
+
                if( $row['pmq_status'] == 'approved' ) {
                        return;
                }
-               
+
                $externalConflicts = $this->checkExternalConflicts( 
$row['pmq_page_last_id'],
                        $row['pmq_page_ns'], $row['pmq_page_title'] );
                if( $externalConflicts ) {
                        $wgOut->addHTML( '<h2>' . $this->msg( 
'premoderation-external-conflicts-h2' )->escaped() . '</h2>' );
                        if( $wgPremoderationStrict ) {
                                $wgOut->addWikiMsg( 
'premoderation-error-externals' );
-                               return;                 
+                               return;
                        }
                        $wgOut->addWikiMsg( 'premoderation-external-edits' );
                }
-               
+
                $this->checkInternalConflicts( $dbr, $id, $row['pmq_page_ns'], 
$row['pmq_page_title'] );
-               
+
                $final = Xml::fieldset( $this->msg( 
'premoderation-status-fieldset' )->text() ) .
                        Xml::openElement( 'form', array( 'id' => 
'prem-status-form', 'method' => 'post' ) ) .
                        $this->getStatusForm( $row['pmq_status'] ) .
                        '<input type="hidden" name="id" value="' . $id . '" />' 
.
                        Xml::closeElement( 'form' ) . Xml::closeElement( 
'fieldset' );
-                       
+
                $wgOut->addHTML( $final );
        }
-       
+
        protected function checkExternalConflicts( $lastId, $ns, $page ) {
                global $wgOut;
-               
+
                $title = Title::newFromText( $page, $ns );
                return $title->getLatestRevID() > $lastId;
        }
-       
+
        protected function checkInternalConflicts( $db, $id, $ns, $page ) {
                global $wgOut;
-               
+
                $res = $db->select(
                        'pm_queue',
                        '*',
@@ -254,22 +255,22 @@
                        __METHOD__,
                        array( 'ORDER BY' => 'pmq_timestamp DESC', 'LIMIT' => 
20 )
                );
-               
+
                $test = $db->fetchRow( $res );
                if( $test ) {
                        $output = '<h2>' . $this->msg( 
'premoderation-internal-conflicts-h2' )->escaped() . '</h2>' .
                                $this->msg( 
'premoderation-internal-conflicts-intro' )->escaped() . 
$this->getListTableHeader( 'int-conflicts' ) .
                                $this->formatListTableRow( $test );
-                       
+
                        while( $row = $db->fetchRow( $res ) ) {
                                $output .= $this->formatListTableRow( $row );
                        }
                        $output .= Xml::closeElement( 'table' );
-                       
+
                        $wgOut->addHTML( $output );
                }
        }
-       
+
        protected function getStatusForm( $status ) {
                $statusList = ( $status == 'new' ) ? array( 'approved', 
'declined' ) :
                        array( 'new', 'approved' );
@@ -280,7 +281,7 @@
                foreach( $statusList as $item ) {
                        $options .= Xml::option( 
$this->msg("premoderation-status-$item")->text(), $item );
                }
-               
+
                return "<table><tr><td><span style='white-space: nowrap'>" . 
Xml::tags( 'select',
                        array( 'id' => 'prem-status-selector', 'name' => 
'statusselector' ), $options ) .
                        '</span></td></tr><tr><td>' . $this->msg( 'summary' 
)->escaped() . ' ' .
@@ -288,43 +289,43 @@
                        '<td>' . Xml::submitButton( $this->msg( 
'htmlform-submit' )->text(), array( 'id' => 'prem-submit' ) ) .
                        '</td></tr></table>';
        }
-       
+
        protected function performChanges() {
                global $wgOut;
-               
+
                $data = $this->mRequest;
-               
+
                $newstatus = $data['statusselector'];
                $id = intval( $data['id'] );
                $this->mSummary = isset( $data['summary'] ) ? $data['summary'] 
: '';
-               
+
                if( !in_array( $newstatus, $this->mAllowedStatus ) || !$id ) {
                        $wgOut->setPageTitle( $this->msg( 
'premoderation-manager-invalidaction' ) );
                        $wgOut->addWikiMsg( 'premoderation-bad-request' );
                        return;
                }
-               
+
                if( $newstatus == 'approved' ) {
                        $ok = $this->approveRevision( $id );
                        $s = $this->changeStatus( $id, $newstatus );
-                       
+
                        if( $ok && $s ) {
                                $wgOut->setPageTitle( $this->msg( 
'premoderation-success' ) );
                                $wgOut->addWikiMsg( 
'premoderation-success-approved' );
                        }
                } else {
                        $ok = $this->changeStatus( $id, $newstatus );
-                       
+
                        if( $ok && $this->addLogEntry( 'status', array( $id, 
$newstatus ) ) ) {
                                $wgOut->setPageTitle( $this->msg( 
'premoderation-success' ) );
                                $wgOut->addWikiMsg( 
'premoderation-success-changed-text' );
                        }
                }
        }
-       
+
        protected function changeStatus( $id, $status ) {
                global $wgUser;
-               
+
                $dbw = wfGetDB( DB_MASTER );
                $query = array(
                        'pmq_status' => $status,
@@ -333,19 +334,19 @@
                        'pmq_updated_user_text' => $wgUser->getName()
                );
                $ok = $dbw->update( 'pm_queue', $query, array( 'pmq_id' => $id 
), __METHOD__ );
-               
+
                return $ok;
        }
-       
+
        protected function approveRevision( $id ) {
                $dbw = wfGetDB( DB_MASTER );
                $res = $dbw->fetchRow(
                        $dbw->select( 'pm_queue', '*', "pmq_id = '$id'", 
__METHOD__ )
                );
-               
+
                $title = Title::newFromText( $res['pmq_page_title'], 
$res['pmq_page_ns'] );
                $user = User::newFromName( $res['pmq_user_text'] );
-               
+
                $row = array(
                        'page' => 0,
                        'user' => $user->getID(),
@@ -355,20 +356,20 @@
                        'comment' => $res['pmq_summary'],
                        'text' => $res['pmq_text']
                );
-               
+
                $rev = new Revision( $row );
                $revId = $rev->insertOn( $dbw );
-               
+
                $conflict = $this->checkExternalConflicts( 
$res['pmq_page_last_id'],
                        $res['pmq_page_ns'], $res['pmq_page_title'] );
                if( !$conflict ) {
                        $wikipage = WikiPage::factory( $title );
-                       
+
                        if( $res['pmq_page_last_id'] == 0 ) {
                                $pageId = $wikipage->insertOn( $dbw );
                                $cond = array( 'page_id' => $pageId );
                                $actionType = 'create';
-                               
+
                                $dbw->update(
                                        'revision',
                                        array( 'rev_page' => $pageId ),
@@ -379,7 +380,7 @@
                                $wikipage->updateRevisionOn( $dbw, $rev );
                                $cond = array( 'page_latest' => 
$res['pmq_page_last_id'] );
                                $actionType = 'update';
-                               
+
                                $dbw->update(
                                        'revision',
                                        array(
@@ -389,7 +390,7 @@
                                        array( 'rev_id' => $revId ), __METHOD__
                                );
                        }
-                       
+
                        $dbw->update(
                                'page',
                                array( 'page_latest' => $revId, 'page_len' => 
$rev->getSize() ),
@@ -398,15 +399,15 @@
                        );
                } else {
                        $actionType = 'updateold';
-                       
+
                        $latestRevId = intval( $title->getLatestRevID() );
                        $res = $dbw->fetchRow(
                                $dbw->select( 'revision', 'rev_parent_id', 
"rev_id = '$latestRevId'", __METHOD__ )
                        );
-                       
+
                        $dbw->update(
                                'revision',
-                               array( 
+                               array(
                                        'rev_page' => $title->getArticleID(),
                                        'rev_parent_id' => $res['rev_parent_id']
                                ),
@@ -420,19 +421,19 @@
                                __METHOD__
                        );
                }
-               
+
                $dbw->commit( __METHOD__ );
                $ok = $this->addLogEntry( $actionType, array( 
$title->getDBkey(), $revId ), 'public' );
-               
+
                return $revId && $ok;
        }
-       
+
        protected function addLogEntry( $type, $params = array(), $visible = 
'private' ) {
                $log = new LogPage( 'prem-' . $visible );
-               
+
                $self = $this->getPageTitle();
                $ok = $log->addEntry( $type, $self, $this->mSummary, $params );
-               
+
                return $ok;
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/326521
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie50fa94709c46d1f21ab65199a58b0aaa9a049af
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Premoderation
Gerrit-Branch: master
Gerrit-Owner: Filip <r...@protonmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to