Merge "resourceloader: Add ResourceLoaderModule::shouldEmbedModule and use it"
[lhc/web/wiklou.git] / includes / EditPage.php
index 20250d5..973327b 100644 (file)
@@ -422,8 +422,6 @@ class EditPage {
         * @param Article $article
         */
        public function __construct( Article $article ) {
-               global $wgOOUIEditPage;
-
                $this->mArticle = $article;
                $this->page = $article->getPage(); // model object
                $this->mTitle = $article->getTitle();
@@ -434,7 +432,7 @@ class EditPage {
                $handler = ContentHandler::getForModelID( $this->contentModel );
                $this->contentFormat = $handler->getDefaultFormat();
 
-               $this->oouiEnabled = $wgOOUIEditPage;
+               $this->oouiEnabled = $this->context->getConfig()->get( 'OOUIEditPage' );
        }
 
        /**
@@ -1493,6 +1491,20 @@ class EditPage {
                return $status;
        }
 
+       /**
+        * Log when a page was successfully saved after the edit conflict view
+        */
+       private function incrementResolvedConflicts() {
+               global $wgRequest;
+
+               if ( $wgRequest->getText( 'mode' ) !== 'conflict' ) {
+                       return;
+               }
+
+               $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
+               $stats->increment( 'edit.failures.conflict.resolved' );
+       }
+
        /**
         * Handle status, such as after attempt save
         *
@@ -1512,6 +1524,8 @@ class EditPage {
                if ( $status->value == self::AS_SUCCESS_UPDATE
                        || $status->value == self::AS_SUCCESS_NEW_ARTICLE
                ) {
+                       $this->incrementResolvedConflicts();
+
                        $this->didSave = true;
                        if ( !$resultDetails['nullEdit'] ) {
                                $this->setPostEditCookie( $status->value );
@@ -3059,7 +3073,7 @@ class EditPage {
                        'id' => 'wpSummary',
                        'name' => 'wpSummary',
                        'maxlength' => '200',
-                       'tabindex' => '1',
+                       'tabindex' => 1,
                        'size' => 60,
                        'spellcheck' => 'true',
                ] + Linker::tooltipAndAccesskeyAttribs( 'summary' );
@@ -4335,8 +4349,6 @@ HTML
                $buttonLabel = $this->context->msg( $this->getSaveButtonLabel() )->text();
 
                $attribs = [
-                       'id' => 'wpSaveWidget',
-                       'inputId' => 'wpSave',
                        'name' => 'wpSave',
                        'tabindex' => ++$tabindex,
                ] + Linker::tooltipAndAccesskeyAttribs( 'save' );
@@ -4344,6 +4356,8 @@ HTML
                if ( $this->oouiEnabled ) {
                        $saveConfig = OOUI\Element::configFromHtmlAttributes( $attribs );
                        $buttons['save'] = new OOUI\ButtonInputWidget( [
+                               'id' => 'wpSaveWidget',
+                               'inputId' => 'wpSave',
                                // Support: IE 6 – Use <input>, otherwise it can't distinguish which button was clicked
                                'useInputTag' => true,
                                'flags' => [ 'constructive', 'primary' ],
@@ -4354,20 +4368,20 @@ HTML
                } else {
                        $buttons['save'] = Html::submitButton(
                                $buttonLabel,
-                               $attribs,
+                               $attribs + [ 'id' => 'wpSave' ],
                                [ 'mw-ui-progressive' ]
                        );
                }
 
                $attribs = [
-                       'id' => 'wpPreviewWidget',
-                       'inputId' => 'wpPreview',
                        'name' => 'wpPreview',
                        'tabindex' => ++$tabindex,
                ] + Linker::tooltipAndAccesskeyAttribs( 'preview' );
                if ( $this->oouiEnabled ) {
                        $previewConfig = OOUI\Element::configFromHtmlAttributes( $attribs );
                        $buttons['preview'] = new OOUI\ButtonInputWidget( [
+                               'id' => 'wpPreviewWidget',
+                               'inputId' => 'wpPreview',
                                // Support: IE 6 – Use <input>, otherwise it can't distinguish which button was clicked
                                'useInputTag' => true,
                                'label' => $this->context->msg( 'showpreview' )->text(),
@@ -4377,18 +4391,18 @@ HTML
                } else {
                        $buttons['preview'] = Html::submitButton(
                                $this->context->msg( 'showpreview' )->text(),
-                               $attribs
+                               $attribs + [ 'id' => 'wpPreview' ]
                        );
                }
                $attribs = [
-                       'id' => 'wpDiffWidget',
-                       'inputId' => 'wpDiff',
                        'name' => 'wpDiff',
                        'tabindex' => ++$tabindex,
                ] + Linker::tooltipAndAccesskeyAttribs( 'diff' );
                if ( $this->oouiEnabled ) {
                        $diffConfig = OOUI\Element::configFromHtmlAttributes( $attribs );
                        $buttons['diff'] = new OOUI\ButtonInputWidget( [
+                               'id' => 'wpDiffWidget',
+                               'inputId' => 'wpDiff',
                                // Support: IE 6 – Use <input>, otherwise it can't distinguish which button was clicked
                                'useInputTag' => true,
                                'label' => $this->context->msg( 'showdiff' )->text(),
@@ -4398,7 +4412,7 @@ HTML
                } else {
                        $buttons['diff'] = Html::submitButton(
                                $this->context->msg( 'showdiff' )->text(),
-                               $attribs
+                               $attribs + [ 'id' => 'wpDiff' ]
                        );
                }