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
require statement breaks local variable scope #1621
Comments
I've added workaround for |
@zacek Could you please explain a bit more. Is there any code example? |
This defect affects the Phalcon volt template engine - variables assigned in the template, e.g.
overwrite local As this defect seems to be quite difficult to fix I've published my workaround in the related defect for those who need the fix ASAP. The fix is just to move the problematic code (method |
the code of the extended class is in my last comment to this defect: phalcon/cphalcon#12176 |
As I know @AlexNDRmac tries to sort out in these days. |
@AlexNDRmac any progress ? |
Yes... I have some little progress. Now I trying to implement symbol table. |
This comment was marked as abuse.
This comment was marked as abuse.
Fixed here:
Thank you for the report, and for helping us make Zephir better. |
There is some problem in the code zephir generates for requirement statement in PHP 7. Local variable values overwrite global variables when require statement is used (the required file can be empty).
Minimalistic example is attached. The render method in the example extension class is inspired by Phalcon\Mvc\View\Engine::render(). Thus, this bug causes problems with volt template rendering in Phalcon.
Components versions
How to reproduce:
zephir init mira
) and copy thismira.zep
file in it:build it (
zephir build
), installmira.so
, createmira.ini
and enable it (phpenmod mira
).and an empty file
mira2.php
php mira.php
The result displayed is 'a=2' which means that the
$a
variable has been overwritten in theEngine::render()
call.Note: If you comment out the line with the require statement in the Engine extension the variable
$a
is not affected.All the example files can be found in the attached demo.zip.
Refs
The text was updated successfully, but these errors were encountered: