From: Tim Starling Date: Fri, 25 Jan 2008 07:43:23 +0000 (+0000) Subject: Workaround for segfault observed on parse for certain input text. Related to PHP... X-Git-Tag: 1.31.0-rc.0~49785 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=122f4fb7134fd4aefde75392bd2bee7da6efd1aa;p=lhc%2Fweb%2Fwiklou.git Workaround for segfault observed on parse for certain input text. Related to PHP bug 35229, but was observed in call_user_func_array() not call_user_func(). Apparently autoloading is buggy especially when invoked from an unusual context. My workaround is to trigger early autoloading using is_callable(). And if we're going to call is_callable(), we may as well do something sensible if it returns false, right? --- diff --git a/includes/Parser.php b/includes/Parser.php index 5f84062a5f..ae6a5ae6fb 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2835,6 +2835,10 @@ class Parser $allArgs = array_merge( $initialArgs, $funcArgs ); } + # Workaround for PHP bug 35229 and similar + if ( !is_callable( $callback ) ) { + throw new MWException( "Tag hook for $name is not callable\n" ); + } $result = call_user_func_array( $callback, $allArgs ); $found = true; @@ -3239,6 +3243,10 @@ class Parser break; default: if( isset( $this->mTagHooks[$name] ) ) { + # Workaround for PHP bug 35229 and similar + if ( !is_callable( $this->mTagHooks[$name] ) ) { + throw new MWException( "Tag hook for $name is not callable\n" ); + } $output = call_user_func_array( $this->mTagHooks[$name], array( $content, $attributes, $this ) ); } else {