11use MediaWiki\Cache\LinkBatchFactory;
31 private LinkBatchFactory $linkBatchFactory;
36 LinkBatchFactory $linkBatchFactory,
41 parent::__construct(
'Listredirects' );
42 $this->linkBatchFactory = $linkBatchFactory;
44 $this->wikiPageFactory = $wikiPageFactory;
45 $this->redirectLookup = $redirectLookup;
66 'tables' => [
'page',
'redirect' ],
67 'fields' => [
'namespace' =>
'page_namespace',
68 'title' =>
'page_title',
74 'conds' => [
'page_is_redirect' => 1 ],
75 'join_conds' => [
'redirect' => [
76 'LEFT JOIN',
'rd_from=page_id' ],
83 return [
'page_namespace',
'page_title' ];
93 if ( !$res->numRows() ) {
97 $batch = $this->linkBatchFactory->newLinkBatch()->setCaller( __METHOD__ );
98 foreach ( $res as $row ) {
99 $batch->add( $row->namespace, $row->title );
101 if ( $redirTarget ) {
102 $batch->addObj( $redirTarget );
112 if ( isset( $row->rd_title ) ) {
121 if ( !$title->canExist() ) {
125 return Title::castFromLinkTarget(
126 $this->redirectLookup->getRedirectTarget( $title )
137 $linkRenderer = $this->getLinkRenderer();
138 # Make a link to the redirect itself
140 $rd_link = $linkRenderer->makeLink(
144 [
'redirect' =>
'no' ]
147 # Find out where the redirect leads
148 $target = $this->getRedirectTarget( $result );
150 # Make a link to the destination page
151 $lang = $this->getLanguage();
152 $arr = $lang->getArrow();
153 $rd_link = Html::rawElement(
'bdi', [
'dir' => $lang->getDir() ], $rd_link );
154 $targetLink = $linkRenderer->makeLink( $target, $target->getFullText() );
155 $targetLink = Html::rawElement(
'bdi', [
'dir' => $lang->getDir() ], $targetLink );
157 return "$rd_link $arr $targetLink";
159 return "<del>$rd_link</del>";
165 $this->addHelpLink(
'Help:Redirects' );
166 parent::execute( $par );
176class_alias( SpecialListRedirects::class,
'SpecialListRedirects' );
if(!defined('MW_SETUP_CALLBACK'))
Service for creating WikiPage objects.
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
setDatabaseProvider(IConnectionProvider $databaseProvider)
Service for resolving a wiki page redirect.