Page MenuHomePhabricator

PHP Notice: Trying to access array offset on value of type null in CategoryViewer.php on line 516
Closed, ResolvedPublic

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 subscribed.

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

Reedy renamed this task from PHP Notice: Trying to access array offset on value of type null in /srv/mediawiki/w/includes/CategoryViewer.php on line 516 to PHP Notice: Trying to access array offset on value of type null in CategoryViewer.php on line 516.Oct 6 2022, 2:48 AM

Change 743168 merged by jenkins-bot:

[mediawiki/core@master] CategoryViewer::getSectionPagingLinks: Fix null array offset warning

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

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

[mediawiki/core@REL1_40] CategoryViewer::getSectionPagingLinks: Fix null array offset warning

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

Change 985039 merged by jenkins-bot:

[mediawiki/core@REL1_40] CategoryViewer::getSectionPagingLinks: Fix null array offset warning

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