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

Context: Fix variable scoping issues for Eval #16

Merged
merged 3 commits into from
Jan 26, 2016

Conversation

deuill
Copy link
Owner

@deuill deuill commented Jan 26, 2016

Previously, Context.Eval relied on Zend's zend_eval_script function for executing arbitrary strings. Unfortunately, the above contains a curious bit of functionality where the string passed is prepended with a return statement depending on whether or not a zval is passed for writing the return value.

This, of course breaks all but the simplest scripts, as we always write the return value to a zval (whether the user calling Context.Eval is to use the return value is another matter entirely).

This commit changes the implementation to a more direct (and therefore more controllable) approach. Some tests have been changed to cover this bug.

Previously, `Context.Eval` relied on Zend's `zend_eval_script` function
for executing arbitrary strings. Unfortunately, the above contains a
curious bit of functionality where the string passed is prepended with
a `return` statement depending on whether or not a zval is passed for
writing the return value.

This, of course breaks all but the simplest scripts, as we always write
the return value to a zval (whether the user calling `Context.Eval` is
to use the return value is another matter entirely).

This commit changes the implementation to a more direct (and therefore
more controllable) approach. Some tests have been changed to cover this
bug.
The `Context.Eval` function invariably creates a `Value` which may
or may not end up being passed to the caller. Keep a reference to
the value and destroy it during `Context.Destroy` at the latest.
@deuill
Copy link
Owner Author

deuill commented Jan 26, 2016

This closes #15.

deuill added a commit that referenced this pull request Jan 26, 2016
 Context: Fix variable scoping issues for `Eval`
@deuill deuill merged commit 088b4b4 into master Jan 26, 2016
@deuill deuill deleted the feature/fix-context-eval-scope branch August 31, 2016 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant