X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=45995646da592ebfe4253701df816d83f4db1cf1;hb=c3f56bd3c3cb599cc0817086763ed9816d6f0a95;hp=0f7d9a7a392369865d0cebe54120d220482da39b;hpb=c65b486b580aaab5d7321b4c0e1d5d1915fca05e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/EditPage.php b/includes/EditPage.php index 0f7d9a7a39..45995646da 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -476,7 +476,15 @@ class EditPage { $this->mArticle = $article; $this->page = $article->getPage(); // model object $this->mTitle = $article->getTitle(); - $this->context = $article->getContext(); + + // Make sure the local context is in sync with other member variables. + // Particularly make sure everything is using the same WikiPage instance. + // This should probably be the case in Article as well, but it's + // particularly important for EditPage, to make use of the in-place caching + // facility in WikiPage::prepareContentForEdit. + $this->context = new DerivativeContext( $article->getContext() ); + $this->context->setWikiPage( $this->page ); + $this->context->setTitle( $this->mTitle ); $this->contentModel = $this->mTitle->getContentModel(); @@ -619,14 +627,23 @@ class EditPage { if ( $permErrors ) { wfDebug( __METHOD__ . ": User can't edit\n" ); - // track block with a cookie if it doesn't exists already - $this->context->getUser()->trackBlockWithCookie(); + if ( $this->context->getUser()->getBlock() ) { + // track block with a cookie if it doesn't exists already + $this->context->getUser()->trackBlockWithCookie(); - // Auto-block user's IP if the account was "hard" blocked - if ( !wfReadOnly() ) { - DeferredUpdates::addCallableUpdate( function () { - $this->context->getUser()->spreadAnyEditBlock(); - } ); + // Auto-block user's IP if the account was "hard" blocked + if ( !wfReadOnly() ) { + DeferredUpdates::addCallableUpdate( function () { + $this->context->getUser()->spreadAnyEditBlock(); + } ); + } + + $config = $this->context->getConfig(); + if ( $config->get( 'EnableBlockNoticeStats' ) ) { + $wiki = $config->get( 'DBname' ); + $statsd = MediaWikiServices::getInstance()->getStatsdDataFactory(); + $statsd->increment( 'BlockNotices.' . $wiki . '.WikitextEditor.shown' ); + } } $this->displayPermissionsError( $permErrors ); @@ -672,7 +689,7 @@ class EditPage { # that edit() already checked just in case someone tries to sneak # in the back door with a hand-edited submission URL. - if ( 'save' == $this->formtype ) { + if ( $this->formtype == 'save' ) { $resultDetails = null; $status = $this->attemptSave( $resultDetails ); if ( !$this->handleStatus( $status, $resultDetails ) ) { @@ -682,7 +699,7 @@ class EditPage { # First time through: get contents, set time for conflict # checking, etc. - if ( 'initial' == $this->formtype || $this->firsttime ) { + if ( $this->formtype == 'initial' || $this->firsttime ) { if ( $this->initialiseForm() === false ) { $out = $this->context->getOutput(); if ( $out->getRedirect() === '' ) { // mcrundo hack redirects, don't override it @@ -1952,7 +1969,7 @@ ERROR; return $status; } - if ( $user->isBlockedFrom( $this->mTitle, false ) ) { + if ( $user->isBlockedFrom( $this->mTitle ) ) { // Auto-block user's IP if the account was "hard" blocked if ( !wfReadOnly() ) { $user->spreadAnyEditBlock(); @@ -2594,8 +2611,13 @@ ERROR; if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist $out->wrapWikiMsg( "
\n$1\n
", [ 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ] ); - } elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) { - # Show log extract if the user is currently blocked + } elseif ( + !is_null( $block ) && + $block->getType() != Block::TYPE_AUTO && + ( $block->isSitewide() || $user->isBlockedFrom( $this->mTitle ) ) + ) { + // Show log extract if the user is sitewide blocked or is partially + // blocked and not allowed to edit their user page or user talk page LogEventsList::showLogExtract( $out, 'block', @@ -2841,7 +2863,7 @@ ERROR; // Put these up at the top to ensure they aren't lost on early form submission $this->showFormBeforeText(); - if ( $this->wasDeletedSinceLastEdit() && 'save' == $this->formtype ) { + if ( $this->wasDeletedSinceLastEdit() && $this->formtype == 'save' ) { $username = $this->lastDelete->user_name; $comment = CommentStore::getStore() ->getComment( 'log_comment', $this->lastDelete )->text; @@ -3123,7 +3145,10 @@ ERROR; if ( !$revision->isCurrent() ) { $this->mArticle->setOldSubtitle( $revision->getId() ); - $out->addWikiMsg( 'editingold' ); + $out->wrapWikiMsg( + Html::warningBox( "\n$1\n" ), + 'editingold' + ); $this->isOldRev = true; } } elseif ( $this->mTitle->exists() ) { @@ -3142,16 +3167,22 @@ ERROR; ); } elseif ( $user->isAnon() ) { if ( $this->formtype != 'preview' ) { + $returntoquery = array_diff_key( + $this->context->getRequest()->getValues(), + [ 'title' => true, 'returnto' => true, 'returntoquery' => true ] + ); $out->wrapWikiMsg( "
\n$1\n
", [ 'anoneditwarning', // Log-in link SpecialPage::getTitleFor( 'Userlogin' )->getFullURL( [ - 'returnto' => $this->getTitle()->getPrefixedDBkey() + 'returnto' => $this->getTitle()->getPrefixedDBkey(), + 'returntoquery' => wfArrayToCgi( $returntoquery ), ] ), // Sign-up link SpecialPage::getTitleFor( 'CreateAccount' )->getFullURL( [ - 'returnto' => $this->getTitle()->getPrefixedDBkey() + 'returnto' => $this->getTitle()->getPrefixedDBkey(), + 'returntoquery' => wfArrayToCgi( $returntoquery ), ] ) ] );