helly Thu May 12 17:23:57 2005 EDT Modified files: /php-src/ext/spl php_spl.c Log: - Add ability to fail silently http://cvs.php.net/diff.php/php-src/ext/spl/php_spl.c?r1=1.47&r2=1.48&ty=u Index: php-src/ext/spl/php_spl.c diff -u php-src/ext/spl/php_spl.c:1.47 php-src/ext/spl/php_spl.c:1.48 --- php-src/ext/spl/php_spl.c:1.47 Thu Apr 14 17:02:08 2005 +++ php-src/ext/spl/php_spl.c Thu May 12 17:23:56 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_spl.c,v 1.47 2005/04/14 21:02:08 helly Exp $ */ +/* $Id: php_spl.c,v 1.48 2005/05/12 21:23:56 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -352,15 +352,16 @@ } } /* }}} */ -/* {{{ void spl_autoload_register([string autoload_function = "spl_autoload"]) +/* {{{ void spl_autoload_register([string autoload_function = "spl_autoload" [, throw = true]]) Register given function as __autoload() implementation */ PHP_FUNCTION(spl_autoload_register) { char *func_name, *lc_name; int func_name_len; + zend_bool do_throw = 1; zend_function *spl_func_ptr, *func_ptr, **func_ptr_ptr; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &func_name, &func_name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sb", &func_name, &func_name_len, &do_throw) == FAILURE) { return; } @@ -369,13 +370,17 @@ zend_str_tolower_copy(lc_name, func_name, func_name_len); if (!strcmp(lc_name, "spl_autoload_call")) { - zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Function spl_autoload_call() cannot be registered", func_name); + if (do_throw) { + zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Function spl_autoload_call() cannot be registered", func_name); + } free_alloca(lc_name); return; } if (zend_hash_find(EG(function_table), lc_name, func_name_len+1, (void **) &func_ptr) == FAILURE) { - zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Function '%s' not found", func_name); + if (do_throw) { + zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Function '%s' not found", func_name); + } free_alloca(lc_name); return; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php