Merge "Follow-up 727454f: Add mediawiki.widgets to jsduck"
[lhc/web/wiklou.git] / includes / EditPage.php
index 8d27eac..e88baaf 100644 (file)
@@ -380,12 +380,14 @@ class EditPage {
 
        public $suppressIntro = false;
 
-       /** @var bool Set to true to allow editing of non-text content types. */
-       public $allowNonTextContent = false;
-
        /** @var bool */
        protected $edit;
 
+       /**
+        * @var bool Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing
+        */
+       private $enableApiEditOverride = false;
+
        /**
         * @param Article $article
         */
@@ -447,8 +449,18 @@ class EditPage {
         * @throws MWException If $modelId has no known handler
         */
        public function isSupportedContentModel( $modelId ) {
-               return $this->allowNonTextContent ||
-                       ContentHandler::getForModelID( $modelId ) instanceof TextContentHandler;
+               return $this->enableApiEditOverride === true ||
+                       ContentHandler::getForModelID( $modelId )->supportsDirectEditing();
+       }
+
+       /**
+        * Allow editing of content that supports API direct editing, but not general
+        * direct editing. Set to false by default.
+        *
+        * @param bool $enableOverride
+        */
+       public function setApiEditOverride( $enableOverride ) {
+               $this->enableApiEditOverride = $enableOverride;
        }
 
        function submit() {
@@ -1946,11 +1958,13 @@ class EditPage {
 
                if ( $this->changeTags && isset( $doEditStatus->value['revision'] ) ) {
                        // If a revision was created, apply any change tags that were requested
-                       ChangeTags::addTags(
-                               $this->changeTags,
-                               isset( $doEditStatus->value['rc'] ) ? $doEditStatus->value['rc']->mAttribs['rc_id'] : null,
-                               $doEditStatus->value['revision']->getId()
-                       );
+                       $addTags = $this->changeTags;
+                       $revId = $doEditStatus->value['revision']->getId();
+                       // Defer this both for performance and so that addTags() sees the rc_id
+                       // since the recentchange entry addition is deferred first (bug T100248)
+                       DeferredUpdates::addCallableUpdate( function() use ( $addTags, $revId ) {
+                               ChangeTags::addTags( $addTags, null, $revId );
+                       } );
                }
 
                return $status;
@@ -3737,7 +3751,7 @@ HTML
                }
 
                $script .= '});';
-               $wgOut->addScript( Html::inlineScript( ResourceLoader::makeLoaderConditionalScript( $script ) ) );
+               $wgOut->addScript( ResourceLoader::makeInlineScript( $script ) );
 
                $toolbar = '<div id="toolbar"></div>';