jenkins-bot has submitted this change and it was merged.
Change subject: Log warnings on on preg_* failures in
MagicWordArray::matchAndRemove()
......................................................................
Log warnings on on preg_* failures in MagicWordArray::matchAndRemove()
Softer version of I3840a56adc0a6e50963b930051892491f8e90245.
Bug: T115514
Change-Id: Idb297a31b17928a0151476879294eedfbec0d744
---
M includes/MagicWord.php
1 file changed, 19 insertions(+), 2 deletions(-)
Approvals:
BryanDavis: Looks good to me, but someone else must approve
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/MagicWord.php b/includes/MagicWord.php
index 2c7ba91..80e60d2 100644
--- a/includes/MagicWord.php
+++ b/includes/MagicWord.php
@@ -23,6 +23,8 @@
* @ingroup Parser
*/
+use MediaWiki\Logger\LoggerFactory;
+
/**
* This class encapsulates "magic words" such as "#redirect", __NOTOC__, etc.
*
@@ -951,13 +953,28 @@
continue;
}
$matches = array();
- if ( preg_match_all( $regex, $text, $matches,
PREG_SET_ORDER ) ) {
+ $res = preg_match_all( $regex, $text, $matches,
PREG_SET_ORDER );
+ if ( $res === false ) {
+ LoggerFactory::getInstance( 'parser'
)->warning( 'preg_match_all returned false', array(
+ 'code' => preg_last_error(),
+ 'regex' => $regex,
+ 'text' => $text,
+ ) );
+ } elseif ( $res ) {
foreach ( $matches as $m ) {
list( $name, $param ) =
$this->parseMatch( $m );
$found[$name] = $param;
}
}
- $text = preg_replace( $regex, '', $text );
+ $res = preg_replace( $regex, '', $text );
+ if ( $res === null ) {
+ LoggerFactory::getInstance( 'parser'
)->warning( 'preg_replace returned null', array(
+ 'code' => preg_last_error(),
+ 'regex' => $regex,
+ 'text' => $text,
+ ) );
+ }
+ $text = $res;
}
return $found;
}
--
To view, visit https://gerrit.wikimedia.org/r/249942
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idb297a31b17928a0151476879294eedfbec0d744
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits