Page MenuHomePhabricator

Undefined index: 0 in /srv/mediawiki/php-master/extensions/Echo/includes/DiscussionParser.php on line 873
Closed, ResolvedPublic

Description

From beta hhvm logs:

Notice: Undefined index: 0 in /srv/mediawiki/php-master/extensions/Echo/includes/DiscussionParser.php on line 873

The code

		// Step 2: Generalise it
		// Trim off the timezone to replace at the end
		$output = $exemplarTimestamp;
		$tzRegex = '/\s*\(\w+\)\s*$/';
		$tzMatches = array();
		preg_match( $tzRegex, $output, $tzMatches );
		$output = preg_replace( $tzRegex, '', $output );
		$output = preg_quote( $output, '/' );
		$output = preg_replace( '/[^\d\W]+/u', '[^\d\W]+', $output );
		$output = preg_replace( '/\d+/u', '\d+', $output );
		$output .= preg_quote( $tzMatches[0] );

never checks to see if $tzRegex actually matched anything.

Event Timeline

bd808 raised the priority of this task from to Needs Triage.
bd808 updated the task description. (Show Details)
bd808 added a project: Notifications.
bd808 changed Security from none to None.
bd808 subscribed.

Do we know what language this error condition occurs under, or at least which wiki was running when the error occurs?

occurs on the following wikis:

arwikibooks
arwikinews
arwikiquote
arwikisource
arwikiversity
arwiktionary
arzwiki
bdwikimedia
bnwiki
bnwikibooks
bnwikisource
bnwiktionary
bpywiki
diqwiki
newiki
newikibooks
newiktionary
siwiki
siwikibooks
siwiktionary
urwiki
arwiki

A sampling of the output of the preSaveTransform:

arzwiki
string(90) "[[خاص:مساهمات/127.0.0.1|127.0.0.1]] 04:12، 3 ديسمبر 2014 (يو تى سى)"

bdwikimedia
string(131) "[[বিশেষ:Contributions/127.0.0.1|127.0.0.1]] ০৪:১২, ৩ ডিসেম্বর ২০১৪ (ইউটিসি)"

newiki
string(173) "[[Special:Contributions/127.0.0.1|127.0.0.1]] ([[User talk:127.0.0.1|वार्ता]]) ०४:१२, ३ डिसेम्बर २०१४ (युटिसी(UTC))"

siwiki
string(124) "[[විශේෂ:දායකත්ව/127.0.0.1|127.0.0.1]] 04:12, 3 දෙසැම්බර් 2014 (යූටීසී)"

urwiki
string(89) "[[خاص:شراکتیں/127.0.0.1|127.0.0.1]] 04:12, 3 دسمبر 2014 ([[UTC|م ع و]])"

It appears that the \w+ is not matching the characters used in the UTC translation in some languages. not sure yet on proper fix(although we could bubblegum patch the index error to make a proper warning call).

I tested on ne.wikipedia.org, mention notifications which require this function to work still operate. Basically the regex generated here just ends up being more generic in some languages. Perhaps thats acceptable and we just throw a guard on the preg_match ?

If we wanted to do it more rigorously, we could look at http://php.net/manual/en/regexp.reference.unicode.php . But if it still works in a different way, probably better to just avoid the warning.

Change 177249 had a related patch set uploaded (by EBernhardson):
Prevent undefined index warnings

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

Patch-For-Review

Change 177249 merged by jenkins-bot:
Prevent undefined index warnings

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