WikiPage::prepareTextForEdit() was removed
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index ae92839..51d9c6a 100644 (file)
@@ -938,8 +938,8 @@ class WikiPage implements Page, IDBAccessObject {
                $dbw->startAtomic( __METHOD__ );
 
                if ( !$oldLatest || $oldLatest == $this->lockAndGetLatest() ) {
-                       $dbw->replace( 'redirect',
-                               [ 'rd_from' ],
+                       $dbw->upsert(
+                               'redirect',
                                [
                                        'rd_from' => $this->getId(),
                                        'rd_namespace' => $rt->getNamespace(),
@@ -947,6 +947,13 @@ class WikiPage implements Page, IDBAccessObject {
                                        'rd_fragment' => $rt->getFragment(),
                                        'rd_interwiki' => $rt->getInterwiki(),
                                ],
+                               [ 'rd_from' ],
+                               [
+                                       'rd_namespace' => $rt->getNamespace(),
+                                       'rd_title' => $rt->getDBkey(),
+                                       'rd_fragment' => $rt->getFragment(),
+                                       'rd_interwiki' => $rt->getInterwiki(),
+                               ],
                                __METHOD__
                        );
                }
@@ -1166,8 +1173,22 @@ class WikiPage implements Page, IDBAccessObject {
                }
 
                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
-                       $messageCache = MessageCache::singleton();
-                       $messageCache->updateMessageOverride( $this->mTitle, $this->getContent() );
+                       // @todo move this logic to MessageCache
+                       if ( $this->exists() ) {
+                               // NOTE: use transclusion text for messages.
+                               //       This is consistent with  MessageCache::getMsgFromNamespace()
+
+                               $content = $this->getContent();
+                               $text = $content === null ? null : $content->getWikitextForTransclusion();
+
+                               if ( $text === null ) {
+                                       $text = false;
+                               }
+                       } else {
+                               $text = false;
+                       }
+
+                       MessageCache::singleton()->replace( $this->mTitle->getDBkey(), $text );
                }
 
                return true;
@@ -2055,22 +2076,6 @@ class WikiPage implements Page, IDBAccessObject {
                return $options;
        }
 
-       /**
-        * Prepare text which is about to be saved.
-        * Returns a stdClass with source, pst and output members
-        *
-        * @param string $text
-        * @param int|null $revid
-        * @param User|null $user
-        * @deprecated since 1.21: use prepareContentForEdit instead.
-        * @return object
-        */
-       public function prepareTextForEdit( $text, $revid = null, User $user = null ) {
-               wfDeprecated( __METHOD__, '1.21' );
-               $content = ContentHandler::makeContent( $text, $this->getTitle() );
-               return $this->prepareContentForEdit( $content, $revid, $user );
-       }
-
        /**
         * Prepare content which is about to be saved.
         * Returns a stdClass with source, pst and output members
@@ -2229,7 +2234,7 @@ class WikiPage implements Page, IDBAccessObject {
         *   - 'no-change': don't update the article count, ever
         */
        public function doEditUpdates( Revision $revision, User $user, array $options = [] ) {
-               global $wgRCWatchCategoryMembership;
+               global $wgRCWatchCategoryMembership, $wgContLang;
 
                $options += [
                        'changed' => true,
@@ -2367,7 +2372,17 @@ class WikiPage implements Page, IDBAccessObject {
                }
 
                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
-                       MessageCache::singleton()->updateMessageOverride( $this->mTitle, $content );
+                       // XXX: could skip pseudo-messages like js/css here, based on content model.
+                       $msgtext = $content ? $content->getWikitextForTransclusion() : null;
+                       if ( $msgtext === false || $msgtext === null ) {
+                               $msgtext = '';
+                       }
+
+                       MessageCache::singleton()->replace( $shortTitle, $msgtext );
+
+                       if ( $wgContLang->hasVariants() ) {
+                               $wgContLang->updateConversionTable( $this->mTitle );
+                       }
                }
 
                if ( $options['created'] ) {
@@ -2837,7 +2852,7 @@ class WikiPage implements Page, IDBAccessObject {
         */
        public function doDeleteArticleReal(
                $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User $user = null,
-               $tags = []
+               $tags = [], $logsubtype = 'delete'
        ) {
                global $wgUser, $wgContentHandlerUseDB;
 
@@ -2968,7 +2983,7 @@ class WikiPage implements Page, IDBAccessObject {
                // Log the deletion, if the page was suppressed, put it in the suppression log instead
                $logtype = $suppress ? 'suppress' : 'delete';
 
-               $logEntry = new ManualLogEntry( $logtype, 'delete' );
+               $logEntry = new ManualLogEntry( $logtype, $logsubtype );
                $logEntry->setPerformer( $user );
                $logEntry->setTarget( $logTitle );
                $logEntry->setComment( $reason );
@@ -3365,6 +3380,8 @@ class WikiPage implements Page, IDBAccessObject {
         * @param Title $title
         */
        public static function onArticleDelete( Title $title ) {
+               global $wgContLang;
+
                // Update existence markers on article/talk tabs...
                $other = $title->getOtherPage();
 
@@ -3381,7 +3398,11 @@ class WikiPage implements Page, IDBAccessObject {
 
                // Messages
                if ( $title->getNamespace() == NS_MEDIAWIKI ) {
-                       MessageCache::singleton()->updateMessageOverride( $title, null );
+                       MessageCache::singleton()->replace( $title->getDBkey(), false );
+
+                       if ( $wgContLang->hasVariants() ) {
+                               $wgContLang->updateConversionTable( $title );
+                       }
                }
 
                // Images
@@ -3482,28 +3503,6 @@ class WikiPage implements Page, IDBAccessObject {
                return $result;
        }
 
-       /**
-        * Return an applicable autosummary if one exists for the given edit.
-        * @param string|null $oldtext The previous text of the page.
-        * @param string|null $newtext The submitted text of the page.
-        * @param int $flags Bitmask: a bitmask of flags submitted for the edit.
-        * @return string An appropriate autosummary, or an empty string.
-        *
-        * @deprecated since 1.21, use ContentHandler::getAutosummary() instead
-        */
-       public static function getAutosummary( $oldtext, $newtext, $flags ) {
-               // NOTE: stub for backwards-compatibility. assumes the given text is
-               // wikitext. will break horribly if it isn't.
-
-               wfDeprecated( __METHOD__, '1.21' );
-
-               $handler = ContentHandler::getForModelID( CONTENT_MODEL_WIKITEXT );
-               $oldContent = is_null( $oldtext ) ? null : $handler->unserializeContent( $oldtext );
-               $newContent = is_null( $newtext ) ? null : $handler->unserializeContent( $newtext );
-
-               return $handler->getAutosummary( $oldContent, $newContent, $flags );
-       }
-
        /**
         * Auto-generates a deletion reason
         *
@@ -3712,4 +3711,30 @@ class WikiPage implements Page, IDBAccessObject {
        public function isLocal() {
                return true;
        }
+
+       /**
+        * The display name for the site this content
+        * come from. If a subclass overrides isLocal(),
+        * this could return something other than the
+        * current site name
+        *
+        * @since 1.28
+        * @return string
+        */
+       public function getWikiDisplayName() {
+               global $wgSitename;
+               return $wgSitename;
+       }
+
+       /**
+        * Get the source URL for the content on this page,
+        * typically the canonical URL, but may be a remote
+        * link if the content comes from another site
+        *
+        * @since 1.28
+        * @return string
+        */
+       public function getSourceURL() {
+               return $this->getTitle()->getCanonicalURL();
+       }
 }