Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion include/super.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t N>
Super(int index, const char(&name)[N]) : _index(index), _name(name), _length(N-1) {}

/**
* Destructor
Expand Down Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions zend/super.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down