- URL: https://www.laruence.com/en/2011/03/22/1929.html
- Please include attribution when republishing.
Today a colleague, eddix, told me he'd spotted a PHP warning,
$php --re dummy Warning: Internal error: Cannot find extension function Dummy in global function table in Unknown on line 0
I'd never run into this before and didn't know what it meant.
After digging through the code, I found a bug in the reflection extension:
In a colleague's own extension, the function registered in the function table of the module entry is case-sensitive, with mixed case — similar to "Dummy" in the error message above.
And as we all know, the functions in PHP's function_table are all lowercase (see my earlier article Introspecting PHP Function).
So the following code in the reflection extension throws the error:
if (module->functions && module->functions->fname) {
//abridged
while (func->fname) {
if (zend_hash_find(EG(function_table),
//note here: the function name is not lowercased.
func->fname, strlen(func->fname) + 1, (void**) &fptr) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"Internal error: Cannot find extension function %
in global function table", func->fname);
func++;
continue;
}
//abridged
}
Look closely: when searching in EG(function_table), func->fname is not lowercased, so the lookup fails...
Haha, a small bug, already reported: http://bugs.php.net/bug.php?id=54347
Be First to Comment