From: mainframe98 Date: Fri, 17 Mar 2017 20:39:55 +0000 (+0000) Subject: Perform a permission check on the title when changing the page language X-Git-Tag: 1.31.0-rc.0~2391^2 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=95d108845fe6545ebb52c8cc274ac76c444dde19;p=lhc%2Fweb%2Fwiklou.git Perform a permission check on the title when changing the page language Performing this check will prevent users without the edituserjs/css to change the page language for protected user js/css subpages, similar to Special:Editcontentmodel. Bug: T160783 Bug: T74965 Change-Id: I2b106861ea0a488308cda92baf7ebf697844ffd7 --- diff --git a/includes/specials/SpecialPageLanguage.php b/includes/specials/SpecialPageLanguage.php index db05ebe587..ef034fb4d4 100644 --- a/includes/specials/SpecialPageLanguage.php +++ b/includes/specials/SpecialPageLanguage.php @@ -135,6 +135,16 @@ class SpecialPageLanguage extends FormSpecialPage { return Status::newFatal( $ex->getMessageObject() ); } + // Check permissions and make sure the user has permission to edit the page + $errors = $title->getUserPermissionsErrors( 'edit', $this->getUser() ); + + if ( $errors ) { + $out = $this->getOutput(); + $wikitext = $out->formatPermissionsErrorMessage( $errors ); + // Hack to get our wikitext parsed + return Status::newFatal( new RawMessage( '$1', [ $wikitext ] ) ); + } + // Url to redirect to after the operation $this->goToUrl = $title->getFullURL( $title->isRedirect() ? [ 'redirect' => 'no' ] : []