Skip to content
This repository was archived by the owner on Jul 7, 2018. It is now read-only.

Commit 80ce2e2

Browse files
authored
Merge pull request #19 from pinepain/drop_php_7.0.2_support
Drop php 7.0.2 support
2 parents bbb7616 + c41aa65 commit 80ce2e2

File tree

7 files changed

+25
-142
lines changed

7 files changed

+25
-142
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ This extension adds [Soft Reference](https://en.wikipedia.org/wiki/Soft_referenc
99
data structures that require advanced referencing model.
1010

1111

12+
**PHP >= 7.0.3 required**
13+
1214
## Usage
1315

1416
```php

appveyor.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ platform:
44

55
environment:
66
matrix:
7-
- PHP_VERSION: 7.0.11
7+
- PHP_VERSION: 7.0.15
88
THREAD_SAFE: true
9-
- PHP_VERSION: 7.0.0
9+
- PHP_VERSION: 7.0.15
1010
THREAD_SAFE: false
11+
- PHP_VERSION: 7.1.1
12+
THREAD_SAFE: true
13+
- PHP_VERSION: 7.1.1
14+
THREAD_SAFE: false
15+
1116

1217
PHP_SDK: c:\projects\php-sdk
1318

config.m4

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ dnl Make sure that the comment is aligned:
77

88
if test "$PHP_REF" != "no"; then
99

10+
AC_MSG_CHECKING([Check for supported PHP versions])
11+
PHP_REF_FOUND_VERSION=`${PHP_CONFIG} --version`
12+
PHP_REF_FOUND_VERNUM=`echo "${PHP_REF_FOUND_VERSION}" | $AWK 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 100 + [$]2) * 100 + [$]3;}'`
13+
14+
if test "$PHP_REF_FOUND_VERNUM" -lt "70003"; then
15+
AC_MSG_ERROR([not supported. Need a PHP version >= 7.0.3 (found $PHP_REF_FOUND_VERSION)])
16+
else
17+
AC_MSG_RESULT([supported ($PHP_REF_FOUND_VERSION)])
18+
fi
19+
20+
echo "$PHP_VERSION_ID"
21+
1022
if test -z "$TRAVIS" ; then
1123
type git &>/dev/null
1224

package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
<dependencies>
156156
<required>
157157
<php>
158-
<min>7.0</min>
158+
<min>7.0.3</min>
159159
</php>
160160
<pearinstaller>
161161
<min>1.4.0</min>

php_ref.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ extern zend_module_entry php_ref_module_entry;
2626
#define PHP_REF_REVISION "dev"
2727
#endif
2828

29-
#if PHP_VERSION_ID <= 70002
30-
#define PHP_REF_PATCH_SPL_OBJECT_HASH
29+
#if PHP_VERSION_ID < 70003
30+
// should never get her, but just in case
31+
#error PHP >= 7.0.3 required
3132
#endif
3233

3334
#define PHP_REF_NS "Ref"
@@ -46,9 +47,6 @@ extern zend_module_entry php_ref_module_entry;
4647

4748
ZEND_BEGIN_MODULE_GLOBALS(ref)
4849
HashTable *referents;
49-
#ifdef PHP_REF_PATCH_SPL_OBJECT_HASH
50-
zend_bool spl_hash_replaced;
51-
#endif
5250
ZEND_END_MODULE_GLOBALS(ref)
5351

5452
ZEND_EXTERN_MODULE_GLOBALS(ref);

php_ref_reference.c

-116
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
#include "zend_exceptions.h"
1717
#include "zend_interfaces.h"
1818

19-
#ifdef PHP_REF_PATCH_SPL_OBJECT_HASH
20-
#include "ext/spl/spl_observer.h"
21-
#endif
22-
2319
zend_class_entry *php_ref_abstract_reference_class_entry;
2420
zend_class_entry *php_ref_soft_reference_class_entry;
2521
zend_class_entry *php_ref_weak_reference_class_entry;
@@ -28,10 +24,6 @@ zend_class_entry *php_ref_weak_reference_class_entry;
2824

2925
zend_object_handlers php_ref_reference_object_handlers;
3026

31-
#ifdef PHP_REF_PATCH_SPL_OBJECT_HASH
32-
static zend_object_get_debug_info_t spl_object_storage_get_debug_info_orig_handler;
33-
#endif
34-
3527
php_ref_reference_t *php_ref_reference_init(zval *this_ptr, zval *referent_zv, zval *notifier_zv);
3628

3729
static inline void php_ref_store_exceptions(zval *exceptions, zval *tmp);
@@ -52,110 +44,6 @@ php_ref_referent_t *php_ref_referent_find_ptr(zend_ulong h) /* {{{ */
5244
return (php_ref_referent_t *) zend_hash_index_find_ptr(PHP_REF_G(referents), h);
5345
} /* }}} */
5446

55-
#ifdef PHP_REF_PATCH_SPL_OBJECT_HASH
56-
static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp) /* {{{ */
57-
{
58-
HashTable* debug_info;
59-
zend_string *md5str;
60-
zend_string *zname;
61-
zval *val;
62-
zval *val_obj;
63-
64-
zval tmp_storage;
65-
66-
zname = zend_mangle_property_name(ZSTR_VAL(spl_ce_SplObjectStorage->name), ZSTR_LEN(spl_ce_SplObjectStorage->name), "storage", sizeof("storage")-1, 0);
67-
68-
debug_info = spl_object_storage_get_debug_info_orig_handler(obj, is_temp);
69-
70-
zval *storage = zend_hash_find(debug_info, zname);
71-
72-
assert(NULL != storage);
73-
array_init(&tmp_storage);
74-
75-
ZEND_HASH_FOREACH_VAL(Z_ARR_P(storage), val) {
76-
val_obj = zend_hash_str_find(Z_ARR_P(val), "obj", sizeof("obj") - 1);
77-
assert(NULL != val_obj);
78-
79-
php_ref_referent_t *referent = php_ref_referent_find_ptr((zend_ulong)Z_OBJ_HANDLE_P(val_obj));
80-
81-
if (NULL != referent) {
82-
Z_OBJ_P(val_obj)->handlers = referent->original_handlers;
83-
md5str = php_spl_object_hash(val_obj);
84-
Z_OBJ_P(val_obj)->handlers = &referent->custom_handlers;
85-
} else {
86-
md5str = php_spl_object_hash(val_obj);
87-
}
88-
89-
zend_hash_update(Z_ARRVAL(tmp_storage), md5str, val);
90-
zval_add_ref(val);
91-
zend_string_release(md5str);
92-
} ZEND_HASH_FOREACH_END();
93-
94-
zend_symtable_update(debug_info, zname, &tmp_storage);
95-
zend_string_release(zname);
96-
97-
return debug_info;
98-
} /* }}} */
99-
#endif
100-
101-
#ifdef PHP_REF_PATCH_SPL_OBJECT_HASH
102-
static PHP_FUNCTION(spl_object_hash_patched)
103-
{
104-
zval *obj;
105-
zend_string *hash = NULL;
106-
107-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &obj) == FAILURE) {
108-
return;
109-
}
110-
111-
php_ref_referent_t *referent = php_ref_referent_find_ptr((zend_ulong)Z_OBJ_HANDLE_P(obj));
112-
113-
if (NULL != referent) {
114-
Z_OBJ_P(obj)->handlers = referent->original_handlers;
115-
hash = php_spl_object_hash(obj);
116-
Z_OBJ_P(obj)->handlers = &referent->custom_handlers;
117-
}
118-
119-
if (NULL == hash) {
120-
hash = php_spl_object_hash(obj);
121-
}
122-
123-
RETURN_NEW_STR(hash);
124-
} /* }}} */
125-
#endif
126-
127-
#ifdef PHP_REF_PATCH_SPL_OBJECT_HASH
128-
static void php_ref_patch_spl_hash() /* {{{ */
129-
{
130-
if (PHP_REF_G(spl_hash_replaced)) {
131-
return;
132-
}
133-
134-
/* Replace spl_object_hash() */
135-
zend_function *spl_object_hash = zend_hash_str_find_ptr(EG(function_table), "spl_object_hash", sizeof("spl_object_hash")-1);
136-
assert(NULL != spl_object_hash);
137-
spl_object_hash->internal_function.handler = zif_spl_object_hash_patched;
138-
139-
/* Replace SplObjectStorage::getHash() */
140-
141-
zend_function *spl_object_storage_getHash = zend_hash_str_find_ptr(&spl_ce_SplObjectStorage->function_table, "gethash", sizeof("gethash") - 1);
142-
assert(NULL != spl_object_storage_getHash);
143-
spl_object_storage_getHash->internal_function.handler = zif_spl_object_hash_patched;
144-
145-
/* Replace SplObjectStorage get_debug_info object handler */
146-
zval tmp;
147-
object_init_ex(&tmp, spl_ce_SplObjectStorage);
148-
149-
spl_object_storage_get_debug_info_orig_handler = Z_OBJ(tmp)->handlers->get_debug_info;
150-
/* Casting const to non-const type is undefined behavior by C standard, but it should works in our case */
151-
((zend_object_handlers *) Z_OBJ(tmp)->handlers)->get_debug_info = spl_object_storage_debug_info;
152-
153-
zval_ptr_dtor(&tmp);
154-
155-
PHP_REF_G(spl_hash_replaced) = 1;
156-
} /* }}} */
157-
#endif
158-
15947
void php_ref_reference_call_notifier(zval *reference, zval *notifier) /* {{{ */
16048
{
16149
zval args;
@@ -337,10 +225,6 @@ php_ref_referent_t *php_ref_referent_get_or_create(zval *referent_zv) /* {{{ */
337225
return referent;
338226
}
339227

340-
#ifdef PHP_REF_PATCH_SPL_OBJECT_HASH
341-
php_ref_patch_spl_hash();
342-
#endif
343-
344228
referent = (php_ref_referent_t *) ecalloc(1, sizeof(php_ref_referent_t));
345229

346230
zend_hash_init(&referent->soft_references, 0, NULL, NULL, 0);

ref.c

-18
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,10 @@ PHP_MINFO_FUNCTION(ref) /* {{{ */
7373
static PHP_GINIT_FUNCTION(ref) /* {{{ */
7474
{
7575
ref_globals->referents = NULL;
76-
#ifdef PHP_REF_PATCH_SPL_OBJECT_HASH
77-
ref_globals->spl_hash_replaced = 0;
78-
#endif
79-
8076
} /* }}} */
8177

82-
#ifdef PHP_REF_PATCH_SPL_OBJECT_HASH
83-
static const zend_module_dep php_ref_deps[] = {
84-
ZEND_MOD_REQUIRED("spl")
85-
ZEND_MOD_CONFLICTS("weakref")
86-
ZEND_MOD_END
87-
};
88-
#endif
89-
9078
zend_module_entry php_ref_module_entry = { /* {{{ */
91-
#ifdef PHP_REF_PATCH_SPL_OBJECT_HASH
92-
STANDARD_MODULE_HEADER_EX, /* size, zend_api, zend_debug, zts*/
93-
NULL, /* ini_entry */
94-
php_ref_deps, /* deps */
95-
#else
9679
STANDARD_MODULE_HEADER,
97-
#endif
9880
"ref",
9981
php_ref_functions,
10082
PHP_MINIT(ref),

0 commit comments

Comments
 (0)