diff --git a/include/super.h b/include/super.h index d12d3764..701ea795 100644 --- a/include/super.h +++ b/include/super.h @@ -28,7 +28,8 @@ class PHPCPP_EXPORT Super * @param index index number * @param name name of the variable in PHP */ - Super(int index, const char *name) : _index(index), _name(name) {} + template + Super(int index, const char(&name)[N]) : _index(index), _name(name), _length(N-1) {} /** * Destructor @@ -102,6 +103,12 @@ class PHPCPP_EXPORT Super */ const char *_name; + /** + * Length of the variable in PHP + * @var name + */ + size_t _length; + /** * Turn the object into a value object * @return Value diff --git a/zend/super.cpp b/zend/super.cpp index 2f88d474..435ac414 100644 --- a/zend/super.cpp +++ b/zend/super.cpp @@ -29,14 +29,8 @@ Super REQUEST (TRACK_VARS_REQUEST, "_REQUEST"); */ Value Super::value() { - // call zend_is_auto_global to ensure that the just-in-time globals are loaded - if (_name) { - // make the variable an auto global - zend_is_auto_global(String{ _name }); - - // reset because we only need to do this once - _name = nullptr; - } + // make the variable an auto global + zend_is_auto_global_str((char*)_name, _length); // create a value object that wraps around the actual zval return &PG(http_globals)[_index];