Page MenuHomePhorge

No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None
diff --git a/includes/specials/SpecialBrokenRedirects.php b/includes/specials/SpecialBrokenRedirects.php
index eb062828073..8e00f91f95b 100644
--- a/includes/specials/SpecialBrokenRedirects.php
+++ b/includes/specials/SpecialBrokenRedirects.php
@@ -26,6 +26,7 @@ use MediaWiki\Page\RedirectLookup;
use MediaWiki\Skin\Skin;
use MediaWiki\SpecialPage\QueryPage;
use MediaWiki\Title\Title;
+use stdClass;
use Wikimedia\Rdbms\IConnectionProvider;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\IResultWrapper;
@@ -139,23 +140,51 @@ class SpecialBrokenRedirects extends QueryPage {
}
/**
- * @param Skin $skin
- * @param \stdClass $result Result row
- * @return string
+ * Preload LinkRenderer for source and destination
+ *
+ * @param IDatabase $db
+ * @param IResultWrapper $res
*/
- public function formatResult( $skin, $result ) {
- $fromObj = Title::makeTitle( $result->namespace, $result->title );
+ public function preprocessResults( $db, $res ) {
+ $this->executeLBFromResultWrapper( $res );
+
+ // Preload LinkRenderer data for destination links
+ $batch = $this->getLinkBatchFactory()->newLinkBatch()->setCaller( __METHOD__ );
+ foreach ( $res as $result ) {
+ // TODO: Batch RedirectLookup calls
+ $toObj = $this->getRedirectTarget( $result );
+ if ( $toObj ) {
+ $batch->addObj( $toObj );
+ }
+ }
+ $batch->execute();
+ // Rewind for display
+ $res->seek( 0 );
+ }
+
+ protected function getRedirectTarget( stdClass $result ): ?Title {
if ( isset( $result->rd_title ) ) {
- $toObj = Title::makeTitle(
+ return Title::makeTitle(
$result->rd_namespace,
$result->rd_title,
$result->rd_fragment
);
} else {
- $toObj = Title::castFromLinkTarget(
+ $fromObj = Title::makeTitle( $result->namespace, $result->title );
+ return Title::castFromLinkTarget(
$this->redirectLookup->getRedirectTarget( $fromObj )
);
}
+ }
+
+ /**
+ * @param Skin $skin
+ * @param \stdClass $result Result row
+ * @return string
+ */
+ public function formatResult( $skin, $result ) {
+ $fromObj = Title::makeTitle( $result->namespace, $result->title );
+ $toObj = $this->getRedirectTarget( $result );
$linkRenderer = $this->getLinkRenderer();
@@ -218,36 +247,6 @@ class SpecialBrokenRedirects extends QueryPage {
parent::execute( $par );
}
- /**
- * Preload LinkRenderer for source and destination
- *
- * @param IDatabase $db
- * @param IResultWrapper $res
- */
- public function preprocessResults( $db, $res ) {
- $this->executeLBFromResultWrapper( $res );
-
- // Preload LinkRenderer data for destination links
- $batch = $this->getLinkBatchFactory()->newLinkBatch()->setCaller( __METHOD__ );
- foreach ( $res as $result ) {
- if ( isset( $result->rd_title ) ) {
- $batch->add( $result->rd_namespace, $result->rd_title );
- } else {
- $fromObj = Title::makeTitle( $result->namespace, $result->title );
- // TODO: Batch redirect lookups
- $toObj = Title::castFromLinkTarget(
- $this->redirectLookup->getRedirectTarget( $fromObj )
- );
- if ( $toObj ) {
- $batch->addObj( $toObj );
- }
- }
- }
- $batch->execute();
- // Rewind for display
- $res->seek( 0 );
- }
-
protected function getGroupName() {
return 'maintenance';
}
diff --git a/includes/specials/SpecialListRedirects.php b/includes/specials/SpecialListRedirects.php
index fcaeef6185c..fb10a018152 100644
--- a/includes/specials/SpecialListRedirects.php
+++ b/includes/specials/SpecialListRedirects.php
@@ -117,11 +117,7 @@ class SpecialListRedirects extends QueryPage {
$res->seek( 0 );
}
- /**
- * @param stdClass $row
- * @return Title|null
- */
- protected function getRedirectTarget( $row ) {
+ protected function getRedirectTarget( stdClass $row ): ?Title {
if ( isset( $row->rd_title ) ) {
return Title::makeTitle(
$row->rd_namespace,

File Metadata

Mime Type
text/x-diff
Expires
Sat, Jul 5, 5:33 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
227827
Default Alt Text
(3 KB)

Event Timeline