Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can Yaf_Dispatcher::setErrorHandler supports closure? #6

Closed
suin opened this issue Aug 25, 2012 · 11 comments
Closed

Can Yaf_Dispatcher::setErrorHandler supports closure? #6

suin opened this issue Aug 25, 2012 · 11 comments
Labels

Comments

@suin
Copy link

suin commented Aug 25, 2012

I noticed Yaf_Dispatcher::setErrorHandler can't receive closure as a callback.

This code works:

<?php

function myErrorHandler($errorCode, $errorMessage, $file, $line)
{
    throw new ErrorException($errorMessage, 0, $errorCode, $file, $line);
}

class Bootstrap extends Yaf_Bootstrap_Abstract
{
    protected function _initErrorHandler(Yaf_Dispatcher $dispatcher)
    {
        $dispatcher->setErrorHandler("myErrorHandler");
    }
}

However, this code doesn't work

<?php

class Bootstrap extends Yaf_Bootstrap_Abstract
{
    protected function _initErrorHandler(Yaf_Dispatcher $dispatcher)
    {
        $dispatcher->setErrorHandler(function($errorCode, $errorMessage, $file, $line) {
            throw new ErrorException($errorMessage, 0, $errorCode, $file, $line);
        });
    }
}
$ php -v
PHP 5.4.5 (cli) (built: Aug 12 2012 18:49:16) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.0, Copyright (c) 2002-2012, by Derick Rethans

My yaf version is 2.1.18.

$ php -i | grep yaf
yaf
yaf support => enabled
Supports => http://pecl.php.net/package/yaf
yaf.action_prefer => Off => Off
yaf.cache_config => Off => Off
yaf.environ => devel => devel
yaf.forward_limit => 5 => 5
yaf.library => no value => no value
yaf.lowcase_path => Off => Off
yaf.name_separator => no value => no value
yaf.name_suffix => On => On
yaf.st_compatible => Off => Off
yaf.use_namespace => Off => Off
yaf.use_spl_autoload => Off => Off
@laruence
Copy link
Owner

thanks, I will implement it . :)

@laruence
Copy link
Owner

hmm, after a quick look, it should works already.... let me check later..

@laruence
Copy link
Owner

I can confirm it works. what do you mean it doesn't works? :)

@suin
Copy link
Author

suin commented Aug 25, 2012

Thanks a lot.

I reinstalled with github master branch.
This is the installation log: https://gist.github.com/3466910

I restarted apache and tried again closure code.
But I still get the same trouble.

I checked apache error log.
Apache reports Segmentation fault.

[Sun Aug 26 00:05:39 2012] [notice] child pid 56585 exit signal Segmentation fault (11)

@laruence
Copy link
Owner

suin, maybe you can generator a backtrace ? that will be very helpful to find out what's going wrong :)

@suin
Copy link
Author

suin commented Aug 25, 2012

OK, so how can I trace Segmentation fault?

@laruence
Copy link
Owner

https://bugs.php.net/bugs-generating-backtrace.php here is some instructions :)

@suin
Copy link
Author

suin commented Aug 26, 2012

Thanks. I tried gdb. https://gist.github.com/3479460
Does this information help you?

@laruence
Copy link
Owner

thanks very much , fixed in trunk

@suin
Copy link
Author

suin commented Aug 26, 2012

Thank you very much! Now closure works well.

@fotografi
Copy link

No description provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants