Page MenuHomePhabricator

Mediawiki:prev-page and next-page displayed unnecessarily.
Open, LowPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Go to a large category with >200 pages in it.
  • Look at the first page of the category.
  • Scroll through the category to the last page of the category.

What happens?:

  • [[Mediawiki:Prev-page]] is displayed at the start of the category, even though there is no possible previous page, and it doesn't link to anything.
  • [[Mediawiki:Next-page]] is displayed on the last page of the category, even though there is no possible next page, and it doesn't link to anything.

What should have happened instead?:

  • [[Mediawiki:Prev-page]] shouldn't have been displayed on the first page.
  • [[Mediawiki:Next-page]] shouldn't've been displayed on the last page.

Software version: 1.35

Other information (browser name/version, screenshots, etc.):
I added screenshots to: https://teflpedia.com/User:Duncan/bugs#Next.2Fprevious_page_bug

Event Timeline

OK, so in includes/category/CategoryViewer.php there are these lines, which might mean something to some people:

	private function pagingLinks( $first, $last, $type = '' ) {
		$prevLink = $this->msg( 'prev-page' )->escaped();

		$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
		if ( $first != '' ) {
			$prevQuery = $this->query;
			$prevQuery["{$type}until"] = $first;
			unset( $prevQuery["{$type}from"] );
			$prevLink = $linkRenderer->makeKnownLink(
				$this->addFragmentToTitle( $this->page, $type ),
				new HtmlArmor( $prevLink ),
				[],
				$prevQuery
			);
		}

		$nextLink = $this->msg( 'next-page' )->escaped();

		if ( $last != '' ) {
			$lastQuery = $this->query;
			$lastQuery["{$type}from"] = $last;
			unset( $lastQuery["{$type}until"] );
			$nextLink = $linkRenderer->makeKnownLink(
				$this->addFragmentToTitle( $this->page, $type ),
				new HtmlArmor( $nextLink ),
				[],
				$lastQuery
			);
		}