resourceloader: Also clear store in debug mode to simplify mw.loader.store.init()
[lhc/web/wiklou.git] / includes / EditPage.php
index 47a8b5b..f288327 100644 (file)
  * @file
  */
 
+use MediaWiki\Block\DatabaseBlock;
 use MediaWiki\EditPage\TextboxBuilder;
 use MediaWiki\EditPage\TextConflictHelper;
 use MediaWiki\Logger\LoggerFactory;
 use MediaWiki\MediaWikiServices;
+use MediaWiki\Storage\RevisionRecord;
 use Wikimedia\ScopedCallback;
 
 /**
@@ -565,14 +567,6 @@ class EditPage {
                $this->enableApiEditOverride = $enableOverride;
        }
 
-       /**
-        * @deprecated since 1.29, call edit directly
-        */
-       public function submit() {
-               wfDeprecated( __METHOD__, '1.29' );
-               $this->edit();
-       }
-
        /**
         * This is the function that gets called for "action=edit". It
         * sets up various member variables, then passes execution to
@@ -629,7 +623,8 @@ class EditPage {
 
                        if ( $this->context->getUser()->getBlock() ) {
                                // track block with a cookie if it doesn't exists already
-                               $this->context->getUser()->trackBlockWithCookie();
+                               MediaWikiServices::getInstance()->getBlockManager()
+                                       ->trackBlockWithCookie( $this->context->getUser() );
 
                                // Auto-block user's IP if the account was "hard" blocked
                                if ( !wfReadOnly() ) {
@@ -1228,8 +1223,8 @@ class EditPage {
                                # the revisions exist and they were not deleted.
                                # Otherwise, $content will be left as-is.
                                if ( !is_null( $undorev ) && !is_null( $oldrev ) &&
-                                       !$undorev->isDeleted( Revision::DELETED_TEXT ) &&
-                                       !$oldrev->isDeleted( Revision::DELETED_TEXT )
+                                       !$undorev->isDeleted( RevisionRecord::DELETED_TEXT ) &&
+                                       !$oldrev->isDeleted( RevisionRecord::DELETED_TEXT )
                                ) {
                                        if ( WikiPage::hasDifferencesOutsideMainSlot( $undorev, $oldrev )
                                                || !$this->isSupportedContentModel( $oldrev->getContentModel() )
@@ -1251,7 +1246,7 @@ class EditPage {
                                        }
 
                                        if ( $undoMsg === null ) {
-                                               $oldContent = $this->page->getContent( Revision::RAW );
+                                               $oldContent = $this->page->getContent( RevisionRecord::RAW );
                                                $popts = ParserOptions::newFromUserAndLang(
                                                        $user, MediaWikiServices::getInstance()->getContentLanguage() );
                                                $newContent = $content->preSaveTransform( $this->mTitle, $user, $popts );
@@ -1377,7 +1372,7 @@ class EditPage {
                        $handler = ContentHandler::getForModelID( $this->contentModel );
                        return $handler->makeEmptyContent();
                }
-               $content = $revision->getContent( Revision::FOR_THIS_USER, $user );
+               $content = $revision->getContent( RevisionRecord::FOR_THIS_USER, $user );
                return $content;
        }
 
@@ -1411,7 +1406,7 @@ class EditPage {
         */
        protected function getCurrentContent() {
                $rev = $this->page->getRevision();
-               $content = $rev ? $rev->getContent( Revision::RAW ) : null;
+               $content = $rev ? $rev->getContent( RevisionRecord::RAW ) : null;
 
                if ( $content === false || $content === null ) {
                        $handler = ContentHandler::getForModelID( $this->contentModel );
@@ -1502,7 +1497,7 @@ class EditPage {
                }
 
                $parserOptions = ParserOptions::newFromUser( $user );
-               $content = $page->getContent( Revision::RAW );
+               $content = $page->getContent( RevisionRecord::RAW );
 
                if ( !$content ) {
                        // TODO: somehow show a warning to the user!
@@ -2598,7 +2593,7 @@ ERROR;
                        }
                } elseif ( $namespace == NS_FILE ) {
                        # Show a hint to shared repo
-                       $file = wfFindFile( $this->mTitle );
+                       $file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $this->mTitle );
                        if ( $file && !$file->isLocal() ) {
                                $descUrl = $file->getDescriptionUrl();
                                # there must be a description url to show a hint to shared repo
@@ -2622,13 +2617,13 @@ ERROR;
                        $username = explode( '/', $this->mTitle->getText(), 2 )[0];
                        $user = User::newFromName( $username, false /* allow IP users */ );
                        $ip = User::isIP( $username );
-                       $block = Block::newFromTarget( $user, $user );
+                       $block = DatabaseBlock::newFromTarget( $user, $user );
                        if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
                                $out->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
                                        [ 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ] );
                        } elseif (
                                !is_null( $block ) &&
-                               $block->getType() != Block::TYPE_AUTO &&
+                               $block->getType() != DatabaseBlock::TYPE_AUTO &&
                                ( $block->isSitewide() || $user->isBlockedFrom( $this->mTitle ) )
                        ) {
                                // Show log extract if the user is sitewide blocked or is partially
@@ -3145,12 +3140,12 @@ ERROR;
                                if ( $revision ) {
                                        // Let sysop know that this will make private content public if saved
 
-                                       if ( !$revision->userCan( Revision::DELETED_TEXT, $user ) ) {
+                                       if ( !$revision->userCan( RevisionRecord::DELETED_TEXT, $user ) ) {
                                                $out->wrapWikiMsg(
                                                        "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
                                                        'rev-deleted-text-permission'
                                                );
-                                       } elseif ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
+                                       } elseif ( $revision->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
                                                $out->wrapWikiMsg(
                                                        "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
                                                        'rev-deleted-text-view'
@@ -4136,7 +4131,7 @@ ERROR;
 
                if ( !Hooks::run( 'EditPageBeforeEditToolbar', [ &$toolbar ] ) ) {
                        return null;
-               };
+               }
                // Don't add a pointless `<div>` to the page unless a hook caller populated it
                return ( $toolbar === $startingToolbar ) ? null : $toolbar;
        }