From ef7760a50d8a5c09e10a4f0f74ff943171f6c94f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Thu, 29 Oct 2015 13:49:11 -0700 Subject: [PATCH] Include preg_last_error() in error message when preg_* fails Bug: T115514 Bug: T117066 Change-Id: I1d13f8542a4cf11c8e87cd4f6a983fa852dfdf1e --- includes/MagicWord.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 424735e51b..17c7cd4914 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -954,7 +954,8 @@ class MagicWordArray { $matches = array(); $matched = preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ); if ( $matched === false ) { - throw new Exception( __METHOD__ . ': preg_match_all returned false' ); + throw new Exception( __METHOD__ . ': preg_match_all returned false with error code ' + . preg_last_error() ); } if ( $matched ) { foreach ( $matches as $m ) { @@ -966,7 +967,8 @@ class MagicWordArray { if ( $replaced !== null ) { $text = $replaced; } else { - throw new Exception( __METHOD__ . ': preg_replace returned null' ); + throw new Exception( __METHOD__ . ': preg_replace returned null with error code ' + . preg_last_error() ); } } return $found; -- 2.20.1