Fixup some rc_* fields if empty for STRICT mode in RecentChange
[lhc/web/wiklou.git] / includes / EditPage.php
index 9b862b9..b98c908 100644 (file)
@@ -401,6 +401,11 @@ class EditPage {
         */
        private $enableApiEditOverride = false;
 
+       /**
+        * @var IContextSource
+        */
+       protected $context;
+
        /**
         * @param Article $article
         */
@@ -408,6 +413,7 @@ class EditPage {
                $this->mArticle = $article;
                $this->page = $article->getPage(); // model object
                $this->mTitle = $article->getTitle();
+               $this->context = $article->getContext();
 
                $this->contentModel = $this->mTitle->getContentModel();
 
@@ -422,6 +428,14 @@ class EditPage {
                return $this->mArticle;
        }
 
+       /**
+        * @since 1.28
+        * @return IContextSource
+        */
+       public function getContext() {
+               return $this->context;
+       }
+
        /**
         * @since 1.19
         * @return Title
@@ -1410,7 +1424,7 @@ class EditPage {
 
        /**
         * Attempt submission
-        * @param array $resultDetails See docs for $result in internalAttemptSave
+        * @param array|bool $resultDetails See docs for $result in internalAttemptSave
         * @throws UserBlockedError|ReadOnlyError|ThrottledError|PermissionsError
         * @return Status The resulting status object.
         */
@@ -2477,8 +2491,7 @@ class EditPage {
                }
 
                if ( !$this->isSupportedContentModel( $content->getModel() ) ) {
-                       throw new MWException( 'This content model is not supported: '
-                               . ContentHandler::getLocalizedName( $content->getModel() ) );
+                       throw new MWException( 'This content model is not supported: ' . $content->getModel() );
                }
 
                return $content->serialize( $this->contentFormat );
@@ -2493,7 +2506,7 @@ class EditPage {
         * content.
         *
         * @param string|null|bool $text Text to unserialize
-        * @return Content The content object created from $text. If $text was false
+        * @return Content|bool|null The content object created from $text. If $text was false
         *   or null, false resp. null will be  returned instead.
         *
         * @throws MWException If unserializing the text results in a Content
@@ -2509,8 +2522,7 @@ class EditPage {
                        $this->contentModel, $this->contentFormat );
 
                if ( !$this->isSupportedContentModel( $content->getModel() ) ) {
-                       throw new MWException( 'This content model is not supported: '
-                               . ContentHandler::getLocalizedName( $content->getModel() ) );
+                       throw new MWException( 'This content model is not supported: ' . $content->getModel() );
                }
 
                return $content;
@@ -2914,6 +2926,9 @@ class EditPage {
                                        );
                                }
                                if ( $this->getTitle()->isSubpageOf( $wgUser->getUserPage() ) ) {
+                                       $wgOut->wrapWikiMsg( '<div class="mw-usercssjspublic">$1</div>',
+                                               $this->isCssSubpage ? 'usercssispublic' : 'userjsispublic'
+                                       );
                                        if ( $this->formtype !== 'preview' ) {
                                                if ( $this->isCssSubpage && $wgAllowUserCss ) {
                                                        $wgOut->wrapWikiMsg(
@@ -3598,7 +3613,7 @@ HTML
         * @return bool|stdClass
         */
        protected function getLastDelete() {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
                $data = $dbr->selectRow(
                        [ 'logging', 'user' ],
                        [
@@ -3795,8 +3810,8 @@ HTML
         * Parse the page for a preview. Subclasses may override this class, in order
         * to parse with different options, or to otherwise modify the preview HTML.
         *
-        * @param Content @content The page content
-        * @return Associative array with keys:
+        * @param Content $content The page content
+        * @return array with keys:
         *   - parserOutput: The ParserOutput object
         *   - html: The HTML to be displayed
         */
@@ -4047,13 +4062,22 @@ HTML
        public function getEditButtons( &$tabindex ) {
                $buttons = [];
 
+               $labelAsPublish =
+                       $this->mArticle->getContext()->getConfig()->get( 'EditSubmitButtonLabelPublish' );
+
+               // Can't use $this->isNew as that's also true if we're adding a new section to an extant page
+               if ( $labelAsPublish ) {
+                       $buttonLabelKey = !$this->mTitle->exists() ? 'publishpage' : 'publishchanges';
+               } else {
+                       $buttonLabelKey = !$this->mTitle->exists() ? 'savearticle' : 'savechanges';
+               }
+               $buttonLabel = wfMessage( $buttonLabelKey )->text();
                $attribs = [
                        'id' => 'wpSave',
                        'name' => 'wpSave',
                        'tabindex' => ++$tabindex,
                ] + Linker::tooltipAndAccesskeyAttribs( 'save' );
-               $buttons['save'] = Html::submitButton( wfMessage( 'savearticle' )->text(),
-                       $attribs, [ 'mw-ui-constructive' ] );
+               $buttons['save'] = Html::submitButton( $buttonLabel, $attribs, [ 'mw-ui-constructive' ] );
 
                ++$tabindex; // use the same for preview and live preview
                $attribs = [