http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90610

Revision: 90610
Author:   yaron
Date:     2011-06-22 21:38:32 +0000 (Wed, 22 Jun 2011)
Log Message:
-----------
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: trunk/extensions/SemanticForms/includes/SF_FormClasses.php
===================================================================
--- trunk/extensions/SemanticForms/includes/SF_FormClasses.php  2011-06-22 
21:38:02 UTC (rev 90609)
+++ trunk/extensions/SemanticForms/includes/SF_FormClasses.php  2011-06-22 
21:38:32 UTC (rev 90610)
@@ -123,7 +123,7 @@
        
                        // First, look for "arraymap" parser function calls
                        // that map a property onto a list.
-                       if ( preg_match_all( 
'/{{#arraymap:{{{([^|}]*:?[^|}]*)[^\[]*\[\[([^:]*:?[^:]*)::/mis', 
$templateText, $matches ) ) {
+                       if ( $ret = preg_match_all( 
'/{{#arraymap:{{{([^|}]*:?[^|}]*)[^\[]*\[\[([^:]*:?[^:]*)::/mis', 
$templateText, $matches ) ) {
                                foreach ( $matches[1] as $i => $field_name ) {
                                        if ( ! in_array( $field_name, 
$fieldNamesArray ) ) {
                                                $propertyName = $matches[2][$i];
@@ -131,6 +131,12 @@
                                                $fieldNamesArray[] = 
$field_name;
                                        }
                                }
+                       } elseif ( $ret === false ) {
+                               // There was an error in the preg_match_all()
+                               // call - let the user know about it.
+                               if ( preg_last_error() == 
PREG_BACKTRACK_LIMIT_ERROR ) {
+                                       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.';
+                               }
                        }
        
                        // Second, look for normal property calls.


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to