Merge "HTMLTitleTextField: Remove incorrect check for unsubmitted GET forms"
[lhc/web/wiklou.git] / includes / specials / SpecialChangeContentModel.php
index a36b414..46fa17e 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use MediaWiki\MediaWikiServices;
+
 class SpecialChangeContentModel extends FormSpecialPage {
 
        public function __construct() {
@@ -101,11 +103,18 @@ class SpecialChangeContentModel extends FormSpecialPage {
                                throw new ErrorPageError(
                                        'changecontentmodel-emptymodels-title',
                                        'changecontentmodel-emptymodels-text',
-                                       $this->title->getPrefixedText()
+                                       [ $this->title->getPrefixedText() ]
                                );
                        }
                        $fields['pagetitle']['readonly'] = true;
                        $fields += [
+                               'currentmodel' => [
+                                       'type' => 'text',
+                                       'name' => 'currentcontentmodel',
+                                       'default' => $this->title->getContentModel(),
+                                       'label-message' => 'changecontentmodel-current-label',
+                                       'readonly' => true
+                               ],
                                'model' => [
                                        'type' => 'select',
                                        'name' => 'model',
@@ -115,7 +124,7 @@ class SpecialChangeContentModel extends FormSpecialPage {
                                'reason' => [
                                        'type' => 'text',
                                        'name' => 'reason',
-                                       'validation-callback' => function( $reason ) {
+                                       'validation-callback' => function ( $reason ) {
                                                $match = EditPage::matchSummarySpamRegex( $reason );
                                                if ( $match ) {
                                                        return $this->msg( 'spamprotectionmatch', $match )->parse();
@@ -154,8 +163,6 @@ class SpecialChangeContentModel extends FormSpecialPage {
        }
 
        public function onSubmit( array $data ) {
-               global $wgContLang;
-
                if ( $data['pagetitle'] === '' ) {
                        // Initial form view of special page, pass
                        return false;
@@ -198,7 +205,7 @@ class SpecialChangeContentModel extends FormSpecialPage {
                        $oldContent = $this->oldRevision->getContent();
                        try {
                                $newContent = ContentHandler::makeContent(
-                                       $oldContent->getNativeData(), $this->title, $data['model']
+                                       $oldContent->serialize(), $this->title, $data['model']
                                );
                        } catch ( MWException $e ) {
                                return Status::newFatal(
@@ -221,7 +228,10 @@ class SpecialChangeContentModel extends FormSpecialPage {
 
                $flags = $this->oldRevision ? EDIT_UPDATE : EDIT_NEW;
                $flags |= EDIT_INTERNAL;
-               if ( $user->isAllowed( 'bot' ) ) {
+               if ( MediaWikiServices::getInstance()
+                               ->getPermissionManager()
+                               ->userHasRight( $user, 'bot' )
+               ) {
                        $flags |= EDIT_FORCE_BOT;
                }
 
@@ -240,8 +250,6 @@ class SpecialChangeContentModel extends FormSpecialPage {
                if ( $data['reason'] !== '' ) {
                        $reason .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $data['reason'];
                }
-               # Truncate for whole multibyte characters.
-               $reason = $wgContLang->truncate( $reason, 255 );
 
                // Run edit filters
                $derivativeContext = new DerivativeContext( $this->getContext() );