From 122f4fb7134fd4aefde75392bd2bee7da6efd1aa Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 25 Jan 2008 07:43:23 +0000 Subject: [PATCH] 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? --- includes/Parser.php | 8 ++++++++ 1 file changed, 8 insertions(+) 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 { -- 2.20.1