* @file
*/
use MediaWiki\MediaWikiServices;
-use MediaWiki\Storage\MutableRevisionRecord;
-use MediaWiki\Storage\RevisionRecord;
-use MediaWiki\Storage\SlotRecord;
+use MediaWiki\Revision\MutableRevisionRecord;
+use MediaWiki\Revision\RevisionRecord;
+use MediaWiki\Revision\SlotRecord;
/**
* Class for viewing MediaWiki article and history.
* here, there doesn't seem to be any other way to stop calling
* OutputPage::enableSectionEditLinks() and still have it work as it did before.
*/
- private $disableSectionEditForRender = false;
+ protected $viewIsRenderAction = false;
/**
* Constructor and clear the article
if ( $outputPage->isPrintable() ) {
$parserOptions->setIsPrintable( true );
$poOptions['enableSectionEditLinks'] = false;
- } elseif ( $this->disableSectionEditForRender
+ } elseif ( $this->viewIsRenderAction
|| !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user )
) {
$poOptions['enableSectionEditLinks'] = false;
$outputPage->setRobotPolicy( 'noindex,nofollow' );
$errortext = $error->getWikiText( false, 'view-pool-error' );
- $outputPage->addWikiText( Html::errorBox( $errortext ) );
+ $outputPage->addWikiTextAsInterface( Html::errorBox( $errortext ) );
}
# Connection or timeout error
return;
$dir = $this->getContext()->getLanguage()->getDir();
$lang = $this->getContext()->getLanguage()->getHtmlCode();
- $outputPage->addWikiText( Xml::openElement( 'div', [
+ $outputPage->addWikiTextAsInterface( Xml::openElement( 'div', [
'class' => "noarticletext mw-content-$dir",
'dir' => $dir,
'lang' => $lang,
public function render() {
$this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
$this->getContext()->getOutput()->setArticleBodyOnly( true );
- $this->disableSectionEditForRender = true;
+ // We later set 'enableSectionEditLinks=false' based on this; also used by ImagePage
+ $this->viewIsRenderAction = true;
$this->view();
}
* Perform a deletion and output success or failure messages
* @param string $reason
* @param bool $suppress
+ * @param bool $immediate false allows deleting over time via the job queue
+ * @throws FatalError
+ * @throws MWException
*/
- public function doDelete( $reason, $suppress = false ) {
+ public function doDelete( $reason, $suppress = false, $immediate = false ) {
$error = '';
$context = $this->getContext();
$outputPage = $context->getOutput();
$user = $context->getUser();
- $status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0, true, $error, $user );
+ $status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0, true, $error, $user,
+ [], 'delete', $immediate );
- if ( $status->isGood() ) {
+ if ( $status->isOK() ) {
$deleted = $this->getTitle()->getPrefixedText();
$outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
$outputPage->setRobotPolicy( 'noindex,nofollow' );
- $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
-
- $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
-
- Hooks::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] );
+ if ( $status->isGood() ) {
+ $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
+ $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
+ Hooks::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] );
+ } else {
+ $outputPage->addWikiMsg( 'delete-scheduled', wfEscapeWikiText( $deleted ) );
+ }
$outputPage->returnToMain( false );
} else {
);
if ( $error == '' ) {
- $outputPage->addWikiText(
+ $outputPage->addWikiTextAsInterface(
"<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
);
$deleteLogPage = new LogPage( 'delete' );
*/
public function doDeleteArticleReal(
$reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User $user = null,
- $tags = []
+ $tags = [], $immediate = false
) {
return $this->mPage->doDeleteArticleReal(
- $reason, $suppress, $u1, $u2, $error, $user, $tags
+ $reason, $suppress, $u1, $u2, $error, $user, $tags, 'delete', $immediate
);
}
* @param int|null $u1 Unused
* @param bool|null $u2 Unused
* @param string &$error
+ * @param bool $immediate false allows deleting over time via the job queue
* @return bool
+ * @throws FatalError
+ * @throws MWException
*/
public function doDeleteArticle(
- $reason, $suppress = false, $u1 = null, $u2 = null, &$error = ''
+ $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', $immediate = false
) {
- return $this->mPage->doDeleteArticle( $reason, $suppress, $u1, $u2, $error );
+ return $this->mPage->doDeleteArticle( $reason, $suppress, $u1, $u2, $error,
+ null, $immediate );
}
/**