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

[BUG] PHP 5.5 crashes when trying to extend the Volt compiller with function or filter #2269

Closed
ghost opened this issue Mar 31, 2014 · 5 comments
Labels
bug A bug report status: medium Medium

Comments

@ghost
Copy link

ghost commented Mar 31, 2014

Hi Phalcon Team,

When I'm trying to register a Function or Filter to the Volt compiler under PHP 5.5 - it crashes with a blank screen (this appeared since version 1.2.6 I think and is still present in 1.3.0 and 1.3.1).

Here are some examples that are working under PHP 5.4 but not under PHP 5.5, for the last tests I used the Vocuro app, where the Volt compiler functions/filter are added in the services.php and it became to looks:

$di->set('view', function() use ($config) {

    $view = new View();

    $view->setViewsDir($config->application->viewsDir);

    $view->registerEngines(array(
        '.volt' => function($view, $di) use ($config) {

            $volt = new VoltEngine($view, $di);
            $compiler = $volt->getCompiler();
            $compiler->addFunction('shuffle', 'str_shuffle');// it's OK
            $compiler->addFilter('shuffle', 'str_shuffle');// it's OK

            $compiler->addFilter('int', function($resolvedArgs, $exprArgs) {
                return 'intval(' . $resolvedArgs . ')';
            });// not working

            $compiler->addFunction('int', function($resolvedArgs, $exprArgs) {
                return 'intval(' . $resolvedArgs . ')';
            });// not working

            $compiler->addFunction('someFunction', function($resolvedArgs, $exprArgs) {
                return 'Widgets::someFunction(' . $resolvedArgs . ')';
            });// not working

            $compiler->addFilter('someFilter', function($resolvedArgs, $exprArgs) {
                return 'Widgets::someFilter(' . $resolvedArgs . ')';
            });// not working

            $volt->setOptions(array(
                'compiledPath' => $config->application->cacheDir . 'volt/',
                'compiledSeparator' => '_'
            ));

            return $volt;
        }
    ));

    return $view;
}, true);

// here is also the Widgets class
class Widgets {
    public static function someFunction() {
        return 'I\'m a working Function';
    }

    public static function someFilter() {
        return 'I\'m a working Filter';
    }
}

Now in the main layout - app/views/index.volt after the {{ content() }} I put:

{{ 'test'|shuffle }} OK for both PHP 5.4/5.5
{{ shuffle('test') }} OK for both PHP 5.4/5.5

{{ '10ab'|int }} NOT OK under PHP 5.5
{{ int('10ab')}} NOT OK under PHP 5.5
{{ someFunction('test') }} NOT OK under PHP 5.5
{{ 'test'|someFilter }} NOT OK under PHP 5.5

This is under Windows, so I can't build it in debug mode.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@ghost ghost changed the title PHP 5.5 crashes when trying to extend the Volt compiller with function or filter [BUG] PHP 5.5 crashes when trying to extend the Volt compiller with function or filter Apr 1, 2014
@ghost
Copy link
Author

ghost commented Apr 3, 2014

Hi, Like in #2198 when I stopped the xdebug extension, the closure filters/functions started to work as expected. So where/how we should address this issue?

@oh-ren
Copy link

oh-ren commented May 1, 2014

I also ran into this issue.. Forum thread: http://forum.phalconphp.com/discussion/2204/xdebug-empty-reply-from-server

@phalcon
Copy link
Collaborator

phalcon commented Sep 2, 2014

Added a pull request on xdebug to fix the problem: xdebug/xdebug#120

@oh-ren
Copy link

oh-ren commented Sep 3, 2014

Awesome, much appreciated!

@oh-ren
Copy link

oh-ren commented Oct 28, 2014

Update: the author of Xdebug believes he's got a fix, which, according to the related Mantis issues, will ship with v2.2.6

xdebug/xdebug#120 (comment)

@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

3 participants