X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fpage%2FArticle.php;h=af4f293ef1bc2117cdc68cdaffad15150d52b092;hb=05412a88982627f475e29b2dfb64cc8976730d07;hp=6a42d58c287bfd890796e490a663a0352a0f70d7;hpb=59e694408b9dbc6a377a0f5104cd682eaa376633;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/Article.php b/includes/page/Article.php index 6a42d58c28..af4f293ef1 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -20,8 +20,9 @@ * @file */ use MediaWiki\MediaWikiServices; -use MediaWiki\Storage\MutableRevisionRecord; -use MediaWiki\Storage\RevisionRecord; +use MediaWiki\Revision\MutableRevisionRecord; +use MediaWiki\Revision\RevisionRecord; +use MediaWiki\Revision\SlotRecord; /** * Class for viewing MediaWiki article and history. @@ -119,7 +120,7 @@ class Article implements Page { * 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 @@ -524,7 +525,7 @@ class Article implements Page { private function applyContentOverride( Content $override ) { // Construct a fake revision $rev = new MutableRevisionRecord( $this->getTitle() ); - $rev->setContent( 'main', $override ); + $rev->setContent( SlotRecord::MAIN, $override ); $this->mRevision = new Revision( $rev ); @@ -632,7 +633,7 @@ class Article implements Page { 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; @@ -766,7 +767,9 @@ class Article implements Page { $parserOptions, $this->getRevIdFetched(), $useParserCache, - $rev + $rev, + // permission checking was done earlier via showDeletedRevisionHeader() + RevisionRecord::RAW ); $ok = $poolArticleView->execute(); $error = $poolArticleView->getError(); @@ -789,7 +792,7 @@ class Article implements Page { $outputPage->setRobotPolicy( 'noindex,nofollow' ); $errortext = $error->getWikiText( false, 'view-pool-error' ); - $outputPage->addWikiText( Html::errorBox( $errortext ) ); + $outputPage->wrapWikiTextAsInterface( 'errorbox', $errortext ); } # Connection or timeout error return; @@ -819,7 +822,7 @@ class Article implements Page { $pOutput = ( $outputDone instanceof ParserOutput ) // phpcs:ignore MediaWiki.Usage.NestedInlineTernary.UnparenthesizedTernary -- FIXME T203805 ? $outputDone // object fetched by hook - : $this->mParserOutput ?: null; // ParserOutput or null, avoid false + : ( $this->mParserOutput ?: null ); // ParserOutput or null, avoid false # Adjust title for main page & pages with displaytitle if ( $pOutput ) { @@ -870,7 +873,7 @@ class Article implements Page { // TODO: find a *good* place for the code that determines the redirect target for // a given revision! // NOTE: Use main slot content. Compare code in DerivedPageDataUpdater::revisionIsRedirect. - $content = $revision->getContent( 'main' ); + $content = $revision->getContent( SlotRecord::MAIN ); return $content ? $content->getRedirectTarget() : null; } @@ -1458,7 +1461,7 @@ class Article implements Page { $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, @@ -1732,7 +1735,8 @@ class Article implements Page { 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(); } @@ -2050,25 +2054,31 @@ class Article implements Page { * 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 { @@ -2078,8 +2088,9 @@ class Article implements Page { ); if ( $error == '' ) { - $outputPage->addWikiText( - "
\n" . $status->getWikiText() . "\n
" + $outputPage->wrapWikiTextAsInterface( + 'error mw-error-cannotdelete', + $status->getWikiText() ); $deleteLogPage = new LogPage( 'delete' ); $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) ); @@ -2294,10 +2305,10 @@ class Article implements Page { */ 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 ); } @@ -2823,12 +2834,16 @@ class Article implements Page { * @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 ); } /**