Page MenuHomePhabricator

PHP Notice: Undefined index: path
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   PHP Notice: Undefined index: path
exception.trace
from /srv/mediawiki/php-1.43.0-wmf.4/includes/ExternalLinks/LinkFilter.php(451)
#0 /srv/mediawiki/php-1.43.0-wmf.4/includes/ExternalLinks/LinkFilter.php(451): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.43.0-wmf.4/includes/ExternalLinks/LinkFilter.php(352): MediaWiki\ExternalLinks\LinkFilter::makeLikeArray(string, string)
#2 /srv/mediawiki/php-1.43.0-wmf.4/includes/specials/SpecialLinkSearch.php(199): MediaWiki\ExternalLinks\LinkFilter::getQueryConditions(string, array)
#3 /srv/mediawiki/php-1.43.0-wmf.4/includes/specialpage/QueryPage.php(564): MediaWiki\Specials\SpecialLinkSearch->getQueryInfo()
#4 /srv/mediawiki/php-1.43.0-wmf.4/includes/specialpage/QueryPage.php(779): MediaWiki\SpecialPage\QueryPage->reallyDoQuery(integer, integer)
#5 /srv/mediawiki/php-1.43.0-wmf.4/includes/specials/SpecialLinkSearch.php(158): MediaWiki\SpecialPage\QueryPage->execute(string)
#6 /srv/mediawiki/php-1.43.0-wmf.4/includes/specialpage/SpecialPage.php(719): MediaWiki\Specials\SpecialLinkSearch->execute(string)
#7 /srv/mediawiki/php-1.43.0-wmf.4/includes/specialpage/SpecialPageFactory.php(1672): MediaWiki\SpecialPage\SpecialPage->run(string)
#8 /srv/mediawiki/php-1.43.0-wmf.4/includes/actions/ActionEntryPoint.php(502): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, MediaWiki\Context\RequestContext)
#9 /srv/mediawiki/php-1.43.0-wmf.4/includes/actions/ActionEntryPoint.php(145): MediaWiki\Actions\ActionEntryPoint->performRequest()
#10 /srv/mediawiki/php-1.43.0-wmf.4/includes/MediaWikiEntryPoint.php(199): MediaWiki\Actions\ActionEntryPoint->execute()
#11 /srv/mediawiki/php-1.43.0-wmf.4/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#12 /srv/mediawiki/w/index.php(3): require(string)
#13 {main}
Impact
Notes

Note that the link being searched for, news://comp.os.vms, is indeed lacking a path component. (As far as I can tell, searching for https://example.com is not affected, so this might be limited to non-HTTP(s) URL schemes.)

Details

Request URL
https://en.wikipedia.org/wiki/Special:LinkSearch/news://comp.os.vms

Event Timeline

There's a recent discussion about weird behaviors with news: URLs on enwiki: https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)#unwarranted_captcha – may be related?

Ah, the affected code is limited to mailto: and news:

LinkFilter::makeLikeArray()
		// URI RFC identifies the email/server part of mailto or news protocol as 'path',
		// while we want to match the email's domain or news server the same way we are
		// matching hosts for other URLs.
		if ( in_array( $bits['scheme'], [ 'mailto', 'news' ] ) ) {
			$bits['host'] = $bits['path'];
			$bits['path'] = '';
		}

And yet:

> MW::srv()->getUrlUtils()->parse('mailto://example.com')
= [
    "scheme" => "mailto",
    "host" => "example.com",
    "delimiter" => ":",
  ]

> MW::srv()->getUrlUtils()->parse('news://example.com')
= [
    "scheme" => "news",
    "host" => "example.com",
    "delimiter" => ":",
  ]

So I guess the URI behavior that code is trying to work around no longer exists? (Might vary based on PHP version – I’m testing on 8.3.)

Ah, the strange URI behavior still happens if you omit the double slashes.

> MW::srv()->getUrlUtils()->parse('news:example.com')
= [
    "scheme" => "news",
    "path" => "example.com",
    "host" => "",
    "delimiter" => ":",
  ]

> MW::srv()->getUrlUtils()->parse('news://example.com')
= [
    "scheme" => "news",
    "host" => "example.com",
    "delimiter" => ":",
  ]

There's a recent discussion about weird behaviors with news: URLs on enwiki: https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)#unwarranted_captcha – may be related?

Hm, I doubt it – I didn’t see any differences in parse_url() behavior on 3v4l (without slashes, with slashes). That issue sounds like it could be related to T312666 (but that’s just a hunch so far).

Change #1030960 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/core@master] LinkFilter: Fix 'path' access

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

Change #1030960 merged by jenkins-bot:

[mediawiki/core@master] LinkFilter::makeLikeArray: Fix another 'path' access

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

I’ll check next week if it’s fixed (doesn’t seem worth a backport).