Merge "Handle missing namespace prefix in XML dumps more gracefully"
[lhc/web/wiklou.git] / includes / EditPage.php
index 34062c0..c22125a 100644 (file)
@@ -363,8 +363,8 @@ class EditPage {
        /** @var bool */
        public $bot = true;
 
-       /** @var null|string */
-       public $contentModel = null;
+       /** @var string */
+       public $contentModel;
 
        /** @var null|string */
        public $contentFormat = null;
@@ -993,7 +993,7 @@ class EditPage {
                        $this->recreate = false;
 
                        // When creating a new section, we can preload a section title by passing it as the
-                       // preloadtitle parameter in the URL (Bug 13100)
+                       // preloadtitle parameter in the URL (T15100)
                        if ( $this->section == 'new' && $request->getVal( 'preloadtitle' ) ) {
                                $this->sectiontitle = $request->getVal( 'preloadtitle' );
                                // Once wpSummary isn't being use for setting section titles, we should delete this.
@@ -1255,11 +1255,7 @@ class EditPage {
                }
                $revision = $this->mArticle->getRevisionFetched();
                if ( $revision === null ) {
-                       if ( !$this->contentModel ) {
-                               $this->contentModel = $this->getTitle()->getContentModel();
-                       }
                        $handler = ContentHandler::getForModelID( $this->contentModel );
-
                        return $handler->makeEmptyContent();
                }
                $content = $revision->getContent( Revision::FOR_THIS_USER, $user );
@@ -1299,11 +1295,7 @@ class EditPage {
                $content = $rev ? $rev->getContent( Revision::RAW ) : null;
 
                if ( $content === false || $content === null ) {
-                       if ( !$this->contentModel ) {
-                               $this->contentModel = $this->getTitle()->getContentModel();
-                       }
                        $handler = ContentHandler::getForModelID( $this->contentModel );
-
                        return $handler->makeEmptyContent();
                } elseif ( !$this->undidRev ) {
                        // Content models should always be the same since we error
@@ -1911,7 +1903,7 @@ class EditPage {
 
                        // Don't save a new page if it's blank or if it's a MediaWiki:
                        // message with content equivalent to default (allow empty pages
-                       // in this case to disable messages, see bug 50124)
+                       // in this case to disable messages, see T52124)
                        $defaultMessageText = $this->mTitle->getDefaultMessageText();
                        if ( $this->mTitle->getNamespace() === NS_MEDIAWIKI && $defaultMessageText !== false ) {
                                $defaultText = $defaultMessageText;
@@ -2483,11 +2475,13 @@ class EditPage {
                }
                # Give a notice if the user is editing a deleted/moved page...
                if ( !$this->mTitle->exists() ) {
+                       $dbr = wfGetDB( DB_REPLICA );
+
                        LogEventsList::showLogExtract( $wgOut, [ 'delete', 'move' ], $this->mTitle,
                                '',
                                [
                                        'lim' => 10,
-                                       'conds' => [ "log_action != 'revision'" ],
+                                       'conds' => [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ],
                                        'showIfEmpty' => false,
                                        'msgKey' => [ 'recreate-moveddeleted-warn' ]
                                ]
@@ -2616,7 +2610,7 @@ class EditPage {
                        return;
                }
 
-               $this->showHeader();
+               $this->showHeader();
 
                $wgOut->addHTML( $this->editFormPageTop );
 
@@ -2729,7 +2723,7 @@ class EditPage {
                if ( $this->hasPresetSummary ) {
                        // If a summary has been preset using &summary= we don't want to prompt for
                        // a different summary. Only prompt for a summary if the summary is blanked.
-                       // (Bug 17416)
+                       // (T19416)
                        $this->autoSumm = md5( '' );
                }
 
@@ -3563,7 +3557,7 @@ HTML
                }
        }
 
-       private function incrementConflictStats() {
+       protected function incrementConflictStats() {
                $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
                $stats->increment( 'edit.failures.conflict' );
                // Only include 'standard' namespaces to avoid creating unknown numbers of statsd metrics