Merge "Selenium: replace UserLoginPage with BlankPage where possible"
[lhc/web/wiklou.git] / includes / page / Article.php
index 9b5e5a5..aa38d1f 100644 (file)
@@ -19,6 +19,7 @@
  *
  * @file
  */
+use MediaWiki\Block\DatabaseBlock;
 use MediaWiki\MediaWikiServices;
 use MediaWiki\Revision\MutableRevisionRecord;
 use MediaWiki\Revision\RevisionRecord;
@@ -31,7 +32,6 @@ use MediaWiki\Revision\SlotRecord;
  *
  * @todo Move and rewrite code to an Action class
  *
- * See design.txt for an overview.
  * Note: edit user interface and cache support functions have been
  * moved to separate EditPage and HTMLFileCache classes.
  */
@@ -960,7 +960,7 @@ class Article implements Page {
                        } else {
                                $specificTarget = $titleText;
                        }
-                       if ( Block::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block ) {
+                       if ( DatabaseBlock::newFromTarget( $specificTarget, $vagueTarget ) instanceof DatabaseBlock ) {
                                return [
                                        'index' => 'noindex',
                                        'follow' => 'nofollow'
@@ -1132,13 +1132,11 @@ class Article implements Page {
         * [[MediaWiki:Talkpagetext]]. For Article::view().
         */
        public function showNamespaceHeader() {
-               if ( $this->getTitle()->isTalkPage() ) {
-                       if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
-                               $this->getContext()->getOutput()->wrapWikiMsg(
-                                       "<div class=\"mw-talkpageheader\">\n$1\n</div>",
-                                       [ 'talkpageheader' ]
-                               );
-                       }
+               if ( $this->getTitle()->isTalkPage() && !wfMessage( 'talkpageheader' )->isDisabled() ) {
+                       $this->getContext()->getOutput()->wrapWikiMsg(
+                               "<div class=\"mw-talkpageheader\">\n$1\n</div>",
+                               [ 'talkpageheader' ]
+                       );
                }
        }
 
@@ -1355,6 +1353,8 @@ class Article implements Page {
 
                $title = $this->getTitle();
 
+               $services = MediaWikiServices::getInstance();
+
                # Show info in user (talk) namespace. Does the user exist? Is he blocked?
                if ( $title->getNamespace() == NS_USER
                        || $title->getNamespace() == NS_USER_TALK
@@ -1362,14 +1362,14 @@ class Article implements Page {
                        $rootPart = explode( '/', $title->getText() )[0];
                        $user = User::newFromName( $rootPart, false /* allow IP users */ );
                        $ip = User::isIP( $rootPart );
-                       $block = Block::newFromTarget( $user, $user );
+                       $block = DatabaseBlock::newFromTarget( $user, $user );
 
                        if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
                                $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
                                        [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
                        } elseif (
                                !is_null( $block ) &&
-                               $block->getType() != Block::TYPE_AUTO &&
+                               $block->getType() != DatabaseBlock::TYPE_AUTO &&
                                ( $block->isSitewide() || $user->isBlockedFrom( $title ) )
                        ) {
                                // Show log extract if the user is sitewide blocked or is partially
@@ -1377,7 +1377,8 @@ class Article implements Page {
                                LogEventsList::showLogExtract(
                                        $outputPage,
                                        'block',
-                                       MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
+                                       $services->getNamespaceInfo()->getCanonicalName( NS_USER ) . ':' .
+                                               $block->getTarget(),
                                        '',
                                        [
                                                'lim' => 1,
@@ -1399,7 +1400,7 @@ class Article implements Page {
                # Show delete and move logs if there were any such events.
                # The logging query can DOS the site when bots/crawlers cause 404 floods,
                # so be careful showing this. 404 pages must be cheap as they are hard to cache.
-               $cache = MediaWikiServices::getInstance()->getMainObjectStash();
+               $cache = $services->getMainObjectStash();
                $key = $cache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
                $loggedIn = $this->getContext()->getUser()->isLoggedIn();
                $sessionExists = $this->getContext()->getRequest()->getSession()->isPersistent();
@@ -1946,15 +1947,13 @@ class Article implements Page {
 
                // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
                // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
-               // Unicode codepoints (or 255 UTF-8 bytes for old schema).
-               $conf = $this->getContext()->getConfig();
-               $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
+               // Unicode codepoints.
                $fields[] = new OOUI\FieldLayout(
                        new OOUI\TextInputWidget( [
                                'name' => 'wpReason',
                                'inputId' => 'wpReason',
                                'tabIndex' => 2,
-                               'maxLength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT,
+                               'maxLength' => CommentStore::COMMENT_CHARACTER_LIMIT,
                                'infusable' => true,
                                'value' => $reason,
                                'autofocus' => true,
@@ -2736,7 +2735,7 @@ class Article implements Page {
         * @see WikiPage::setTimestamp
         */
        public function setTimestamp( $ts ) {
-               return $this->mPage->setTimestamp( $ts );
+               $this->mPage->setTimestamp( $ts );
        }
 
        /**
@@ -2860,7 +2859,10 @@ class Article implements Page {
         * @return array
         */
        public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user = null ) {
-               $user = is_null( $user ) ? $this->getContext()->getUser() : $user;
+               if ( !$user ) {
+                       $user = $this->getContext()->getUser();
+               }
+
                return $this->mPage->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
        }
 
@@ -2873,7 +2875,10 @@ class Article implements Page {
         * @return array
         */
        public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser = null ) {
-               $guser = is_null( $guser ) ? $this->getContext()->getUser() : $guser;
+               if ( !$guser ) {
+                       $guser = $this->getContext()->getUser();
+               }
+
                return $this->mPage->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
        }