Merge "Perform a permission check on the title when changing the page language"
[lhc/web/wiklou.git] / includes / specials / SpecialPageLanguage.php
index 2943fd4..78a453e 100644 (file)
@@ -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->getFullUrlForRedirect(
                        $title->isRedirect() ? [ 'redirect' => 'no' ] : []