aboutsummaryrefslogtreecommitdiffstats
path: root/includes/page
diff options
context:
space:
mode:
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>2025-02-26 06:34:04 +0000
committerGerrit Code Review <gerrit@wikimedia.org>2025-02-26 06:34:04 +0000
commit4e6c15edd320d5f8377eb3c2bbac8eac06ba9ad2 (patch)
treef2184003a53b4a1c0e64f8cfdcf1bd83b005cdb5 /includes/page
parentea0429ba34d3ce32d8619e855c95aab378138c31 (diff)
parent73e35a6dd867d16ccbe6df37f21bb733d2171709 (diff)
downloadmediawikicore-4e6c15edd320d5f8377eb3c2bbac8eac06ba9ad2.tar.gz
mediawikicore-4e6c15edd320d5f8377eb3c2bbac8eac06ba9ad2.zip
Merge "Factor out block log boxes and add block list link"
Diffstat (limited to 'includes/page')
-rw-r--r--includes/page/Article.php47
1 files changed, 10 insertions, 37 deletions
diff --git a/includes/page/Article.php b/includes/page/Article.php
index b33315ba3397..cec77c0ced73 100644
--- a/includes/page/Article.php
+++ b/includes/page/Article.php
@@ -18,7 +18,6 @@
* @file
*/
-use MediaWiki\Block\Block;
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Block\DatabaseBlockStore;
use MediaWiki\CommentFormatter\CommentFormatter;
@@ -1551,42 +1550,16 @@ class Article implements Page {
} else {
$validUserPage = !$title->isSubpage();
- // TODO: factor out nearly identical code in IntroMessageBuilder::addUserWarnings
- $blocks = $this->blockStore->newListFromTarget( $user, $user );
- $numBlocks = 0;
- $appliesToTitle = false;
- $logTargetPage = '';
- foreach ( $blocks as $block ) {
- if ( $block->getType() !== Block::TYPE_AUTO ) {
- $numBlocks++;
- if ( $block->appliesToTitle( $title ) ) {
- $appliesToTitle = true;
- }
- $logTargetPage = $services->getNamespaceInfo()->getCanonicalName( NS_USER ) .
- ':' . $block->getTargetName();
- }
- }
-
- // 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
- if ( $numBlocks && $appliesToTitle ) {
- $msgKey = $numBlocks === 1
- ? 'blocked-notice-logextract' : 'blocked-notice-logextract-multi';
- LogEventsList::showLogExtract(
- $outputPage,
- 'block',
- $logTargetPage,
- '',
- [
- 'lim' => 1,
- 'showIfEmpty' => false,
- 'msgKey' => [
- $msgKey,
- $user->getName(), # Support GENDER in notice
- $numBlocks
- ],
- ]
- );
+ $blockLogBox = LogEventsList::getBlockLogWarningBox(
+ $this->blockStore,
+ $services->getNamespaceInfo(),
+ $this->getContext(),
+ $this->linkRenderer,
+ $user,
+ $title
+ );
+ if ( $blockLogBox !== null ) {
+ $outputPage->addHTML( $blockLogBox );
}
}
}