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

[2.1.x] Dispatcher doesn't forward when handling exception in PHP5.6 #11819

Closed
virgofx opened this Issue May 23, 2016 · 5 comments

Comments

Projects
None yet
4 participants
@virgofx
Member

virgofx commented May 23, 2016

Code works in 2.0.x. It may have to do with the creation of the new _dispatch() method in 2.1.x and multiple levels of try/catch which do not work well in zephir.

Pseudo code:

bootstrap

$di = new \Phalcon\Di\FactoryDefault();

$eventsManager = new \Phalcon\Events\Manager();
$eventsManager->attach('dispatch:beforeException', function($event, $dispatcher, $exception) {
    $dispatcher->forward([
        'controller' => 'test',
        'action' => 'second'
    ]);
    // Prevent the exception from bubbling
    return false;
});

$dispatcher = new \Phalcon\Mvc\Dispatcher();
$dispatcher->setEventsManager($eventsManager);

$di->setShared('dispatcher', $dispatcher);

$application = new \Phalcon\Mvc\Application();
$application->setEventsManager(new \Phalcon\Events\Manager());
$application->setDI($di);

echo $application->handle()->getContent();

TestController.php

class TestController extends \Phalcon\Mvc\Controller
{
    public function indexAction()
    {
        throw new \Exception('whups bad controller');
    }

    public function secondAction() 
    {
        echo 'I should be displayed';
        exit;
    }
}

@sergeyklay sergeyklay added this to the 2.1.0 milestone Jun 16, 2016

@andresgutierrez andresgutierrez modified the milestones: 2.1.1, 2.1.0 Jun 27, 2016

@sergeyklay sergeyklay modified the milestones: 3.0.1, 3.0.2 Aug 10, 2016

@virgofx virgofx changed the title from [2.1.x] Dispatcher doesn't forward when handling exception to [2.1.x] Dispatcher doesn't forward when handling exception in PHP5.6 Aug 26, 2016

virgofx added a commit to virgofx/cphalcon that referenced this issue Sep 9, 2016

Fixed segfault in PHP5.6 dispatching, prevented double dispatch
exceptions, and improved documentation/test-suite for dispatcher
components [#12154](phalcon#12154),
[#11819](phalcon#11819)
@temuri416

This comment has been minimized.

Show comment
Hide comment
@temuri416

temuri416 Nov 22, 2016

Contributor

Hi @virgofx, is there any progress on this issue?

Thanks!

Contributor

temuri416 commented Nov 22, 2016

Hi @virgofx, is there any progress on this issue?

Thanks!

@virgofx

This comment has been minimized.

Show comment
Hide comment
@virgofx

virgofx Nov 22, 2016

Member

@temuri416 We have it fixed; however, still waiting on a core bug in Zephir land which causes a segfault in the updated tests that would allow this to pass and get things merged in. So still in a holding pattern. Anxiously waiting help from @andresgutierrez to help with phalcon/zephir#1325. Perhaps if you want to add another ping in that thread -- might help. In the meantime, I've had to override the dispatcher manually which fixes this in our production boxes - If you need this snippet email me directly and I can share with you.

Member

virgofx commented Nov 22, 2016

@temuri416 We have it fixed; however, still waiting on a core bug in Zephir land which causes a segfault in the updated tests that would allow this to pass and get things merged in. So still in a holding pattern. Anxiously waiting help from @andresgutierrez to help with phalcon/zephir#1325. Perhaps if you want to add another ping in that thread -- might help. In the meantime, I've had to override the dispatcher manually which fixes this in our production boxes - If you need this snippet email me directly and I can share with you.

@temuri416

This comment has been minimized.

Show comment
Hide comment
@temuri416

temuri416 Nov 22, 2016

Contributor

@andresgutierrez Can we please have your attention? We need your help to get the issue fixed. Thank you!

Contributor

temuri416 commented Nov 22, 2016

@andresgutierrez Can we please have your attention? We need your help to get the issue fixed. Thank you!

@sergeyklay sergeyklay modified the milestones: 3.0.2, 3.0.3 Nov 26, 2016

@sergeyklay sergeyklay modified the milestones: 3.0.3, 3.0.4 Dec 23, 2016

@sergeyklay sergeyklay modified the milestones: 3.0.4, 3.1.0 Feb 12, 2017

@sergeyklay sergeyklay modified the milestones: 3.0.4, 3.1.0, 3.1.x Feb 12, 2017

sergeyklay added a commit that referenced this issue Apr 8, 2017

@sergeyklay

This comment has been minimized.

Show comment
Hide comment
@sergeyklay

sergeyklay Apr 8, 2017

Member

Fixed in the 3.2.x branch.

Member

sergeyklay commented Apr 8, 2017

Fixed in the 3.2.x branch.

@sergeyklay sergeyklay closed this Apr 8, 2017

@sergeyklay sergeyklay modified the milestones: 3.2.x, 3.2.0 Apr 8, 2017

@temuri416

This comment has been minimized.

Show comment
Hide comment
@temuri416

temuri416 Apr 10, 2017

Contributor

Verified, working as expected! This is an enormous improvement, thanks a lot.

Contributor

temuri416 commented Apr 10, 2017

Verified, working as expected! This is an enormous improvement, thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment