r90610 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90609‎ | r90610 | r90611 >
Date:21:38, 22 June 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added display of error message if a PREG_BACKTRACK_LIMIT_ERROR occurs during a call to preg_match_all()
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormClasses.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormClasses.php
@@ -123,7 +123,7 @@
124124
125125 // First, look for "arraymap" parser function calls
126126 // that map a property onto a list.
127 - if ( preg_match_all( '/{{#arraymap:{{{([^|}]*:?[^|}]*)[^\[]*\[\[([^:]*:?[^:]*)::/mis', $templateText, $matches ) ) {
 127+ if ( $ret = preg_match_all( '/{{#arraymap:{{{([^|}]*:?[^|}]*)[^\[]*\[\[([^:]*:?[^:]*)::/mis', $templateText, $matches ) ) {
128128 foreach ( $matches[1] as $i => $field_name ) {
129129 if ( ! in_array( $field_name, $fieldNamesArray ) ) {
130130 $propertyName = $matches[2][$i];
@@ -131,6 +131,12 @@
132132 $fieldNamesArray[] = $field_name;
133133 }
134134 }
 135+ } elseif ( $ret === false ) {
 136+ // There was an error in the preg_match_all()
 137+ // call - let the user know about it.
 138+ if ( preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR ) {
 139+ print 'Semantic Forms error: backtrace limit exceeded during parsing! Please increase the value of <a href="http://www.php.net/manual/en/pcre.configuration.php#ini.pcre.backtrack-limit">pcre.backtrack-limit</a> in the PHP settings.';
 140+ }
135141 }
136142
137143 // Second, look for normal property calls.