TopicSubscriptionsPager: Fix exception when no subscriptions

Bug: T362507
Change-Id: I569fb2ae017edc9d8e49910faff85e8c9301077d
This commit is contained in:
Bartosz Dziewoński 2024-04-15 21:03:55 +02:00
parent c7595b012b
commit cf792094bb

View file

@ -36,7 +36,7 @@ class TopicSubscriptionsPager extends TablePager {
private ThreadItemFormatter $threadItemFormatter; private ThreadItemFormatter $threadItemFormatter;
/** @var array<string,DatabaseThreadItem[]> */ /** @var array<string,DatabaseThreadItem[]> */
private array $threadItemsByName; private array $threadItemsByName = [];
public function __construct( public function __construct(
IContextSource $context, IContextSource $context,
@ -55,6 +55,9 @@ class TopicSubscriptionsPager extends TablePager {
* @inheritDoc * @inheritDoc
*/ */
public function preprocessResults( $result ) { public function preprocessResults( $result ) {
if ( !$result->numRows() ) {
return;
}
$lb = $this->linkBatchFactory->newLinkBatch(); $lb = $this->linkBatchFactory->newLinkBatch();
$itemNames = []; $itemNames = [];
foreach ( $result as $row ) { foreach ( $result as $row ) {
@ -63,7 +66,6 @@ class TopicSubscriptionsPager extends TablePager {
} }
$lb->execute(); $lb->execute();
$this->threadItemsByName = [];
// Increased limit to allow finding and skipping over some bad permalinks // Increased limit to allow finding and skipping over some bad permalinks
$threadItems = $this->threadItemStore->findNewestRevisionsByName( $itemNames, $this->mLimit * 5 ); $threadItems = $this->threadItemStore->findNewestRevisionsByName( $itemNames, $this->mLimit * 5 );
foreach ( $threadItems as $threadItem ) { foreach ( $threadItems as $threadItem ) {