+ // 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' ] : []
+ );
+
+ return self::changePageLanguage(
+ $this->getContext(),
+ $title,
+ $newLanguage,
+ $data['reason'] === null ? '' : $data['reason']
+ );
+ }
+
+ /**
+ * @param IContextSource $context
+ * @param Title $title
+ * @param string $newLanguage Language code
+ * @param string $reason Reason for the change
+ * @param array $tags Change tags to apply to the log entry
+ * @return Status
+ */
+ public static function changePageLanguage( IContextSource $context, Title $title,
+ $newLanguage, $reason, array $tags = [] ) {