Improve BrokenRedirects display
- Don't strike all entries in Miser Mode
- This does a query for each entry, however other pages like
Special:DoubleRedirects already do that so it shouldn't cause
performance problems.
- If the redirect is no longer broken because its target now exists then
strike the entire entry rather than displaying a red link to a page
that actually exists
Bug: T351055
Change-Id: I9189b1ba537f0ca590b41a3db76621f11df2a224
This commit is contained in:
parent
7e2f1706a1
commit
9ac90f7816
2 changed files with 10 additions and 4 deletions
|
|
@ -215,6 +215,7 @@ class SpecialPageFactory {
|
|||
'ContentHandlerFactory',
|
||||
'ConnectionProvider',
|
||||
'LinkBatchFactory',
|
||||
'RedirectLookup'
|
||||
]
|
||||
],
|
||||
'Deadendpages' => [
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ namespace MediaWiki\Specials;
|
|||
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\Content\IContentHandlerFactory;
|
||||
use MediaWiki\Page\RedirectLookup;
|
||||
use MediaWiki\SpecialPage\QueryPage;
|
||||
use MediaWiki\Title\Title;
|
||||
use Skin;
|
||||
|
|
@ -40,6 +41,7 @@ use Wikimedia\Rdbms\IResultWrapper;
|
|||
class SpecialBrokenRedirects extends QueryPage {
|
||||
|
||||
private IContentHandlerFactory $contentHandlerFactory;
|
||||
private RedirectLookup $redirectLookup;
|
||||
|
||||
/**
|
||||
* @param IContentHandlerFactory $contentHandlerFactory
|
||||
|
|
@ -49,12 +51,14 @@ class SpecialBrokenRedirects extends QueryPage {
|
|||
public function __construct(
|
||||
IContentHandlerFactory $contentHandlerFactory,
|
||||
IConnectionProvider $dbProvider,
|
||||
LinkBatchFactory $linkBatchFactory
|
||||
LinkBatchFactory $linkBatchFactory,
|
||||
RedirectLookup $redirectLookup
|
||||
) {
|
||||
parent::__construct( 'BrokenRedirects' );
|
||||
$this->contentHandlerFactory = $contentHandlerFactory;
|
||||
$this->setDatabaseProvider( $dbProvider );
|
||||
$this->setLinkBatchFactory( $linkBatchFactory );
|
||||
$this->redirectLookup = $redirectLookup;
|
||||
}
|
||||
|
||||
public function isExpensive() {
|
||||
|
|
@ -129,13 +133,14 @@ class SpecialBrokenRedirects extends QueryPage {
|
|||
$result->rd_fragment
|
||||
);
|
||||
} else {
|
||||
$toObj = false;
|
||||
$toObj = Title::castFromLinkTarget(
|
||||
$this->redirectLookup->getRedirectTarget( $fromObj )
|
||||
);
|
||||
}
|
||||
|
||||
$linkRenderer = $this->getLinkRenderer();
|
||||
|
||||
// $toObj may very easily be false if the $result list is cached
|
||||
if ( !is_object( $toObj ) ) {
|
||||
if ( !is_object( $toObj ) || $toObj->exists() ) {
|
||||
return '<del>' . $linkRenderer->makeLink( $fromObj ) . '</del>';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue