r30144 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r30143‎ | r30144 | r30145 >
Date:07:43, 25 January 2008
Author:tstarling
Status:old
Tags:
Comment:
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?
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -2835,6 +2835,10 @@
28362836 $allArgs = array_merge( $initialArgs, $funcArgs );
28372837 }
28382838
 2839+ # Workaround for PHP bug 35229 and similar
 2840+ if ( !is_callable( $callback ) ) {
 2841+ throw new MWException( "Tag hook for $name is not callable\n" );
 2842+ }
28392843 $result = call_user_func_array( $callback, $allArgs );
28402844 $found = true;
28412845
@@ -3239,6 +3243,10 @@
32403244 break;
32413245 default:
32423246 if( isset( $this->mTagHooks[$name] ) ) {
 3247+ # Workaround for PHP bug 35229 and similar
 3248+ if ( !is_callable( $this->mTagHooks[$name] ) ) {
 3249+ throw new MWException( "Tag hook for $name is not callable\n" );
 3250+ }
32433251 $output = call_user_func_array( $this->mTagHooks[$name],
32443252 array( $content, $attributes, $this ) );
32453253 } else {

Status & tagging log