[MediaWiki-commits] [Gerrit] mediawiki/core[master]: EditPage: Stop using globals for configuration in non-static...
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/379462 ) Change subject: EditPage: Stop using globals for configuration in non-static functions .. EditPage: Stop using globals for configuration in non-static functions Bug: T144366 Change-Id: Ie884527b64f86b6a989117a45c6ffa6d1893d2b7 --- M includes/EditPage.php 1 file changed, 19 insertions(+), 26 deletions(-) Approvals: jenkins-bot: Verified Jforrester: Looks good to me, approved diff --git a/includes/EditPage.php b/includes/EditPage.php index bd58c81..1588f82 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -821,7 +821,7 @@ * @return bool */ protected function previewOnOpen() { - global $wgPreviewOnOpenNamespaces; + $previewOnOpenNamespaces = $this->context->getConfig()->get( 'PreviewOnOpenNamespaces' ); $request = $this->context->getRequest(); if ( $request->getVal( 'preview' ) == 'yes' ) { // Explicit override from request @@ -838,8 +838,8 @@ // Standard preference behavior return true; } elseif ( !$this->mTitle->exists() - && isset( $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] ) - && $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] + && isset( $previewOnOpenNamespaces[$this->mTitle->getNamespace()] ) + && $previewOnOpenNamespaces[$this->mTitle->getNamespace()] ) { // Categories are special return true; @@ -1769,9 +1769,6 @@ * time. */ public function internalAttemptSave( &$result, $bot = false ) { - global $wgMaxArticleSize; - global $wgContentHandlerUseDB; - $status = Status::newGood(); $user = $this->context->getUser(); @@ -1883,7 +1880,9 @@ } $this->contentLength = strlen( $this->textbox1 ); - if ( $this->contentLength > $wgMaxArticleSize * 1024 ) { + $config = $this->context->getConfig(); + $maxArticleSize = $config->get( 'MaxArticleSize' ); + if ( $this->contentLength > $maxArticleSize * 1024 ) { // Error will be displayed by showEditForm() $this->tooBig = true; $status->setResult( false, self::AS_CONTENT_TOO_BIG ); @@ -1903,7 +1902,7 @@ $changingContentModel = false; if ( $this->contentModel !== $this->mTitle->getContentModel() ) { - if ( !$wgContentHandlerUseDB ) { + if ( !$config->get( 'ContentHandlerUseDB' ) ) { $status->fatal( 'editpage-cannot-use-custom-model' ); $status->value = self::AS_CANNOT_USE_CUSTOM_MODEL; return $status; @@ -2182,7 +2181,7 @@ // Check for length errors again now that the section is merged in $this->contentLength = strlen( $this->toEditText( $content ) ); - if ( $this->contentLength > $wgMaxArticleSize * 1024 ) { + if ( $this->contentLength > $maxArticleSize * 1024 ) { $this->tooBig = true; $status->setResult( false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED ); return $status; @@ -2383,8 +2382,6 @@ } public function setHeaders() { - global $wgAjaxEditStash; - $out = $this->context->getOutput(); $out->addModules( 'mediawiki.action.edit' ); @@ -2436,7 +2433,7 @@ # Keep Resources.php/mediawiki.action.edit.preview in sync with the possible keys $out->addJsConfigVars( [ 'wgEditMessage' => $msg, - 'wgAjaxEditStash' => $wgAjaxEditStash, + 'wgAjaxEditStash' => $this->context->getConfig()->get( 'AjaxEditStash' ), ] ); } @@ -2938,8 +2935,6 @@ } protected function showHeader() { - global $wgAllowUserCss, $wgAllowUserJs; - $out = $this->context->getOutput(); $user = $this->context->getUser(); if ( $this->isConflict ) { @@ -3064,14 +3059,15 @@ $isCssSubpage ? 'usercssispublic' : 'userjsispublic' ); if ( $this->formtype !== 'preview' ) { - if ( $isCssSubpage && $wgAllowUserCss ) { + $config =
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: EditPage: Stop using globals for configuration in non-static...
Legoktm has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/379462 ) Change subject: EditPage: Stop using globals for configuration in non-static functions .. EditPage: Stop using globals for configuration in non-static functions Change-Id: Ie884527b64f86b6a989117a45c6ffa6d1893d2b7 --- M includes/EditPage.php 1 file changed, 19 insertions(+), 26 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/62/379462/1 diff --git a/includes/EditPage.php b/includes/EditPage.php index bd58c81..1588f82 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -821,7 +821,7 @@ * @return bool */ protected function previewOnOpen() { - global $wgPreviewOnOpenNamespaces; + $previewOnOpenNamespaces = $this->context->getConfig()->get( 'PreviewOnOpenNamespaces' ); $request = $this->context->getRequest(); if ( $request->getVal( 'preview' ) == 'yes' ) { // Explicit override from request @@ -838,8 +838,8 @@ // Standard preference behavior return true; } elseif ( !$this->mTitle->exists() - && isset( $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] ) - && $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] + && isset( $previewOnOpenNamespaces[$this->mTitle->getNamespace()] ) + && $previewOnOpenNamespaces[$this->mTitle->getNamespace()] ) { // Categories are special return true; @@ -1769,9 +1769,6 @@ * time. */ public function internalAttemptSave( &$result, $bot = false ) { - global $wgMaxArticleSize; - global $wgContentHandlerUseDB; - $status = Status::newGood(); $user = $this->context->getUser(); @@ -1883,7 +1880,9 @@ } $this->contentLength = strlen( $this->textbox1 ); - if ( $this->contentLength > $wgMaxArticleSize * 1024 ) { + $config = $this->context->getConfig(); + $maxArticleSize = $config->get( 'MaxArticleSize' ); + if ( $this->contentLength > $maxArticleSize * 1024 ) { // Error will be displayed by showEditForm() $this->tooBig = true; $status->setResult( false, self::AS_CONTENT_TOO_BIG ); @@ -1903,7 +1902,7 @@ $changingContentModel = false; if ( $this->contentModel !== $this->mTitle->getContentModel() ) { - if ( !$wgContentHandlerUseDB ) { + if ( !$config->get( 'ContentHandlerUseDB' ) ) { $status->fatal( 'editpage-cannot-use-custom-model' ); $status->value = self::AS_CANNOT_USE_CUSTOM_MODEL; return $status; @@ -2182,7 +2181,7 @@ // Check for length errors again now that the section is merged in $this->contentLength = strlen( $this->toEditText( $content ) ); - if ( $this->contentLength > $wgMaxArticleSize * 1024 ) { + if ( $this->contentLength > $maxArticleSize * 1024 ) { $this->tooBig = true; $status->setResult( false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED ); return $status; @@ -2383,8 +2382,6 @@ } public function setHeaders() { - global $wgAjaxEditStash; - $out = $this->context->getOutput(); $out->addModules( 'mediawiki.action.edit' ); @@ -2436,7 +2433,7 @@ # Keep Resources.php/mediawiki.action.edit.preview in sync with the possible keys $out->addJsConfigVars( [ 'wgEditMessage' => $msg, - 'wgAjaxEditStash' => $wgAjaxEditStash, + 'wgAjaxEditStash' => $this->context->getConfig()->get( 'AjaxEditStash' ), ] ); } @@ -2938,8 +2935,6 @@ } protected function showHeader() { - global $wgAllowUserCss, $wgAllowUserJs; - $out = $this->context->getOutput(); $user = $this->context->getUser(); if ( $this->isConflict ) { @@ -3064,14 +3059,15 @@ $isCssSubpage ? 'usercssispublic' : 'userjsispublic' ); if ( $this->formtype !== 'preview' ) { - if ( $isCssSubpage && $wgAllowUserCss ) { + $config = $this->context->getConfig(); +