Skip to content

[pull] master from CopernicaMarketingSoftware:master #10

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

Merged
merged 5 commits into from
Nov 7, 2023
Merged
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ INSTALL_LIB = ${INSTALL_PREFIX}/lib
# Otherwise only release verions changes. (version is MAJOR.MINOR.RELEASE)
#

SONAME = 2.3
VERSION = 2.3.5
SONAME = 2.4
VERSION = 2.4.0


#
Expand Down
15 changes: 6 additions & 9 deletions include/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@ class PHPCPP_EXPORT File
*/
File(const char *name) : File(name, ::strlen(name)) {}

/**
* Alternative constructor with zend_string filename
* and size of the string
*
* @param name the filename
* @param size size of the filename
*/
File(const _zend_string *name, size_t size);

/**
* Alternative constructor with a string object
* @param name the filename
Expand Down Expand Up @@ -93,6 +84,12 @@ class PHPCPP_EXPORT File
Value execute();

private:
/**
* The original path
* @var struct _zend_string*
*/
struct _zend_string *_original = nullptr;

/**
* The full resolved path name
* @var struct _zend_string*
Expand Down
4 changes: 2 additions & 2 deletions include/throwable.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*
* @author Jasper van Eck <[email protected]>
* @author Emiel Bruijntjes <[email protected]>
* @copyright 2013 - 2019 Copernica BV
* @copyright 2013 - 2023 Copernica BV
*/
#include <exception>
#include <stdexcept>
#include <string>

/**
Expand Down
23 changes: 20 additions & 3 deletions zend/classimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1538,9 +1538,26 @@ zend_class_entry *ClassImpl::initialize(ClassBase *base, const std::string &pref
else std::cerr << "Derived class " << name() << " is initialized before base class " << interface->name() << ": interface is ignored" << std::endl;
}

// we may have to expose the Traversable or Serializable interfaces
if (_base->traversable()) zend_class_implements(_entry, 1, zend_ce_traversable);
if (_base->serializable()) zend_class_implements(_entry, 1, zend_ce_serializable);
// we may have to expose the Traversable
if (_base->traversable())
{
#if PHP_VERSION_ID < 80000
// up to php 7.x we can implement just the Traversable method (strictly speaking, it does not seem
// to be a user-space concern whether a class is traversable because of "iterator" or "iteratoraggregate"
zend_class_implements(_entry, 1, zend_ce_traversable);
#else
// from php 8.0 an error occurs if a class just implements traversable, without being an explicit
// subclass of Iterator or IteratorAggregate -- so we implement the iteraroraggregate instead
zend_class_implements(_entry, 1, zend_ce_aggregate);
#endif
}

// check if the Serializable interface
if (_base->serializable())
{
// add the Seriablable interface
zend_class_implements(_entry, 1, zend_ce_serializable);
}

// instal the right modifier (to make the class an interface, abstract class, etc)
_entry->ce_flags |= uint64_t(_type);
Expand Down
24 changes: 5 additions & 19 deletions zend/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,27 @@ namespace Php {
* @param name the filename
* @param size length of the filename
*/
File::File(const char *name, size_t size)
File::File(const char *name, size_t size) : _original(zend_string_init(name, size, 0))
{
#if PHP_VERSION_ID < 80000
// resolve the path
_path = zend_resolve_path(name, size);
#else
// first convert the path, then read it
zend_string *tmp_str = zend_string_init(name, size, 0);
_path = zend_resolve_path(tmp_str);
_path = zend_resolve_path(_original);
#endif
}

/**
* Constructor based on zend_string
*/
#if PHP_VERSION_ID >= 80000
File::File(const _zend_string *name, size_t size)
{
/**
* Assign `const` zend_string as a non-const variable to resolve typing error.
* error: invalid conversion from ‘const zend_string*’ {aka ‘const _zend_string*’} to ‘zend_string*’ {aka ‘_zend_string*’}
* zend_resolve_path now only accepts the filename argument.
*/
zend_string *tmp_str = zend_string_init_fast(ZSTR_VAL(name), ZSTR_LEN(name));
_path = zend_resolve_path(tmp_str);
}
#endif

/**
* Destructor
*/
File::~File()
{
// clean up path name
if (_path) zend_string_release(_path);

// clean up original path
if (_original) zend_string_release(_original);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion zend/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ void Value::unset(int index)
if (!isArray()) return;

// if this is not a reference variable, we should detach it to implement copy on write
SEPARATE_ZVAL_NOREF(_val);
SEPARATE_ZVAL_IF_NOT_REF(_val);

// remove the index
zend_hash_index_del(Z_ARRVAL_P(_val.dereference()), index);
Expand Down