EditPage: Don't show create label for the button on new sections
authorJforrester <jforrester@wikimedia.org>
Wed, 24 Aug 2016 23:19:36 +0000 (23:19 +0000)
committerJforrester <jforrester@wikimedia.org>
Wed, 24 Aug 2016 23:25:30 +0000 (23:25 +0000)
It turns out that the helpful $this->isNew is true on new section edits,
whether or not the page exists, so instead we have to fall back on the
$this->mTitle->exists() call that partially populates isNew anyway.

Change-Id: I7d7cdecda51c6ab4b05496f0b1420cb0264fcccb

includes/EditPage.php

index 738eaec..0da7e6e 100644 (file)
@@ -4070,10 +4070,11 @@ HTML
                $buttons = [];
 
                $labelAsPublish = $this->mArticle->getContext()->getConfig()->get( 'EditButtonPublishNotSave' );
+               // 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->isNew ? 'publishpage' : 'publishchanges';
+                       $buttonLabelKey = !$this->mTitle->exists() ? 'publishpage' : 'publishchanges';
                } else {
-                       $buttonLabelKey = $this->isNew ? 'savearticle' : 'savechanges';
+                       $buttonLabelKey = !$this->mTitle->exists() ? 'savearticle' : 'savechanges';
                }
                $buttonLabel = wfMessage( $buttonLabelKey )->text();
                $attribs = [