Sunday 15 April 2012

PHP finally block aborts on autoload -



PHP finally block aborts on autoload -

i have problem finally blocks , autoload. using php 5.5.9. here minimal example:

<?php function loadmyclass($class){ include_once $class . '.php'; } spl_autoload_register("loadmyclass"); seek { seek { // test::printit("before "); <--- (1) commented throw new exception(); } { echo "finally1 " test::printit("finally2 "); } } grab (exception $e) { test::printit("catch "); }

test.php:

<?php class test { public static function printit($i) { echo $i; } }

as see, thrown exception, , want finally , catch block run. test::printit simple method calls echo on parameter. class test loaded via registered autoload function. running programme prints finally1 catch instead of finally1 finally2 catch, phone call test::printit(1); seems abort block. problem seems autoload in finally block. if uncomment line (1), test loaded in block. in case before finally1 finally2 catch echoed correctly.

what problem here? bug in php? if yes, in version fixed? or fault because autoloading supposed fail in blocks?

this exact php version output php -v:

php 5.5.9-1ubuntu4 (cli) (built: apr 9 2014 17:11:57) copyright (c) 1997-2014 php grouping zend engine v2.5.0, copyright (c) 1998-2014 zend technologies zend opcache v7.0.3, copyright (c) 1999-2014, zend technologies

this appears bug in php, according this bug report apr 2014 , this bug report (with links fix) jan 2014.

a comment person assigned:

as talked, knew issue, should fixed in 5.6+, due abi break, can not bring prepare 5.5...

php autoload try-catch-finally spl-autoload-register

No comments:

Post a Comment