EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/177249
Change subject: Prevent undefined index warnings
......................................................................
Prevent undefined index warnings
In some languages the \w+ does not match the chracters used
when translating UTC and the regular expression attempting to
match the timezone fails. Testing in prod wiki's where this fails
such as ne.wikipedia.org shows it still works, it just generates
a more generic regular expression.
Since the overall process still works acceptibly on the wiki's outputting
warnings this patch just adds a guard to prevent the warning and does
not attempt to fix the underlying issue.
Change-Id: If8e1ddd2d642b042cc24c51d5ba5aa8b34bc9552
---
M includes/DiscussionParser.php
1 file changed, 6 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/49/177249/1
diff --git a/includes/DiscussionParser.php b/includes/DiscussionParser.php
index 99a610e..bb227d1 100644
--- a/includes/DiscussionParser.php
+++ b/includes/DiscussionParser.php
@@ -864,13 +864,16 @@
$output = $exemplarTimestamp;
$tzRegex = '/\s*\(\w+\)\s*$/';
$tzMatches = array();
- preg_match( $tzRegex, $output, $tzMatches );
- $output = preg_replace( $tzRegex, '', $output );
+ if ( 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] );
+ if ( $tzMatches ) {
+ $output .= preg_quote( $tzMatches[0] );
+ }
if ( !preg_match( "/$output/u", $exemplarTimestamp ) ) {
throw new MWException( "Timestamp regex does not match
exemplar" );
--
To view, visit https://gerrit.wikimedia.org/r/177249
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If8e1ddd2d642b042cc24c51d5ba5aa8b34bc9552
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits