From: Gergő Tisza Date: Thu, 29 Oct 2015 20:49:11 +0000 (-0700) Subject: Include preg_last_error() in error message when preg_* fails X-Git-Tag: 1.31.0-rc.0~9175^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=ef7760a50d8a5c09e10a4f0f74ff943171f6c94f;p=lhc%2Fweb%2Fwiklou.git Include preg_last_error() in error message when preg_* fails Bug: T115514 Bug: T117066 Change-Id: I1d13f8542a4cf11c8e87cd4f6a983fa852dfdf1e --- 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;