Merge "Truncate protect reason for whole multibyte characters"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 21 Nov 2013 12:58:21 +0000 (12:58 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 21 Nov 2013 12:58:21 +0000 (12:58 +0000)
includes/WikiPage.php

index a59b795..9507e5f 100644 (file)
@@ -2247,7 +2247,7 @@ class WikiPage implements Page, IDBAccessObject {
         * @return Status
         */
        public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user ) {
-               global $wgCascadingRestrictionLevels;
+               global $wgCascadingRestrictionLevels, $wgContLang;
 
                if ( wfReadOnly() ) {
                        return Status::newFatal( 'readonlytext', wfReadOnlyReason() );
@@ -2320,6 +2320,9 @@ class WikiPage implements Page, IDBAccessObject {
                        $logAction = 'protect';
                }
 
+               // Truncate for whole multibyte characters
+               $reason = $wgContLang->truncate( $reason, 255 );
+
                if ( $id ) { // Protection of existing page
                        if ( !wfRunHooks( 'ArticleProtect', array( &$this, &$user, $limit, $reason ) ) ) {
                                return Status::newGood();
@@ -2421,7 +2424,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                // Update the protection log
                $log = new LogPage( 'protect' );
-               $log->addEntry( $logAction, $this->mTitle, trim( $reason ), $params, $user );
+               $log->addEntry( $logAction, $this->mTitle, $reason, $params, $user );
 
                return Status::newGood();
        }