From: umherirrender Date: Wed, 20 Nov 2013 18:56:42 +0000 (+0100) Subject: Truncate protect reason for whole multibyte characters X-Git-Tag: 1.31.0-rc.0~17981^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=5e34e79700c05ed0a318ac2d97857fb8f8bd1b2a;p=lhc%2Fweb%2Fwiklou.git Truncate protect reason for whole multibyte characters This avoids broken characters for long comment. The reason is shown on action=edit for unprivilieged users. Change-Id: Ie8099f50628d55ff880760721169803ccbb3555c --- diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 6c2c6ad881..7b68510249 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -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(); }