Page MenuHomePhabricator

PHP Notice: Trying to access array offset on value of type null in /srv/mediawiki/w/includes/CategoryViewer.php on line 516
Open, Needs TriagePublic

Description

Under php 7.4 I'm getting:

PHP Notice:  Trying to access array offset on value of type null in /srv/mediawiki/w/includes/CategoryViewer.php on line 516

Fix would be to do something like $test['test'] ?? null rather then just $test['test'].

Running MW 1.36.

Event Timeline

Fix would be to do something like $test['test'] ?? null rather then just $test['test'].

Which isn't exactly hepful.

Function is CategoryViewer::getSectionPagingLinks

Line of code is

return $this->pagingLinks( $this->prevPage[$type], $this->until[$type], $type );

But in context, both of the array accesses have already been checked...

	private function getSectionPagingLinks( $type ) {
		if ( isset( $this->until[$type] ) ) {
			// The new value for the until parameter should be pointing to the first
			// result displayed on the page which is the second last result retrieved
			// from the database.The next link should have a from parameter pointing
			// to the until parameter of the current page.
			if ( $this->nextPage[$type] !== null ) {
				return $this->pagingLinks( $this->prevPage[$type], $this->until[$type], $type );
			} else {
				// If the nextPage variable is null, it means that we have reached the first page
				// and therefore the previous link should be disabled.
				return $this->pagingLinks( null, $this->until[$type], $type );
			}
		} elseif ( $this->nextPage[$type] !== null || isset( $this->from[$type] ) ) {
			return $this->pagingLinks( $this->from[$type], $this->nextPage[$type], $type );
		} else {
			return '';
		}
	}

Change 743168 had a related patch set uploaded (by Paladox; author: Paladox):

[mediawiki/core@master] Fix \"PHP Notice: Trying to access array offset on value of type null\"

https://gerrit.wikimedia.org/r/743168

Dereckson added a subscriber: Dereckson.

[ Assigning so it's more clear we've a merge request for that one. ]