$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();
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 );
);
} elseif ( $user->isAnon() ) {
if ( $this->formtype != 'preview' ) {
+ $returntoquery = array_diff_key(
+ $this->context->getRequest()->getValues(),
+ [ 'title' => true, 'returnto' => true, 'returntoquery' => true ]
+ );
$out->wrapWikiMsg(
"<div id='mw-anon-edit-warning' class='warningbox'>\n$1\n</div>",
[ '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 ),
] )
]
);