deuill / go-php

PHP bindings for the Go programming language (Golang)
MIT License
930 stars 105 forks source link

Context: Fix variable scoping issues for `Eval` #16

Closed deuill closed 8 years ago

deuill commented 8 years ago

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.

deuill commented 8 years ago

This closes #15.