@@ -7,6 +7,14 @@ UPGRADE NOTES - PHP X.Y
7
7
b. return_value_ptr now always available, RETVAL_ZVAL_FAST macros
8
8
c. POST data handling
9
9
d. Arginfo changes
10
+ e. tsrm_virtual_cwd.h moved to zend_virtual_cwd.h
11
+ f. empty strings are interned
12
+ g. Additional str_* APIs
13
+ h. Addition of zend_hash_reindex
14
+ i. Addition of zend_hash_splice
15
+ j. An additional parameter is sent to Countable::count()
16
+ k. Unserialization of manipulated object strings
17
+ l. Removal of IS_CONSTANT_ARRAY and IS_CONSTANT_INDEX hack
10
18
11
19
2. Build system changes
12
20
a. Unix build system changes
@@ -17,11 +25,209 @@ UPGRADE NOTES - PHP X.Y
17
25
1. Internal API changes
18
26
========================
19
27
20
- a. zend_set_memory_limit() now takes the TSRMLS_CC macro as its last argument
28
+ a. Addition of do_operation and compare object handlers
29
+
30
+ Two new object handlers have been added:
31
+
32
+ do_operation:
33
+ typedef int (*zend_object_do_operation_t)(
34
+ zend_uchar opcode, zval *result, zval *op1, zval *op2 TSRMLS_DC
35
+ );
36
+
37
+ compare:
38
+ typedef int (*zend_object_compare_zvals_t)(
39
+ zval *result, zval *op1, zval *op2 TSRMLS_DC
40
+ );
41
+
42
+ The first handler is used to overload arithmetic operations. The first
43
+ argument specifies the opcode of the operator, result is the target zval,
44
+ op1 the first operand and op2 the second operand. For unary operations
45
+ op2 is NULL. If the handler returns FAILURE PHP falls back to the default
46
+ behavior for the operation.
47
+
48
+ The second handler is used to perform comparison operations with
49
+ non-objects. The value written into result must be an IS_LONG with value
50
+ -1 (smaller), 0 (equal) or 1 (greater). The return value is a SUCCESS/FAILURE
51
+ return code. The difference between this handler and compare_objects is
52
+ that it will be triggered for comparisons with non-objects and objects of
53
+ different types. It takes precedence over compare_objects.
54
+
55
+ Further docs in the RFC: https://wiki.php.net/rfc/operator_overloading_gmp
56
+
57
+ b. return_value_ptr now always available, RETVAL_ZVAL_FAST macros
58
+
59
+ The return_value_ptr argument to internal functions is now always set.
60
+ Previously it was only available for functions returning by-reference.
61
+ return_value_ptr can now be used to return zvals without copying them.
62
+ For this purpose two new macros are provided:
63
+
64
+ RETVAL_ZVAL_FAST(zv); /* analog to RETVAL_ZVAL(zv, 1, 0) */
65
+ RETURN_ZVAL_FAST(zv); /* analog to RETURN_ZVAL(zv, 1, 0) */
66
+
67
+ The macros behave similarly to the non-FAST variants with copy=1 and
68
+ dtor=0, but will try to return the zval without making a copy by utilizing
69
+ return_value_ptr.
70
+
71
+ c. POST data handling
72
+
73
+ The sapi_request_info's members post_data, post_data_len and raw_post_data as
74
+ well as raw_post_data_len have been replaced with a temp PHP stream
75
+ request_body.
76
+
77
+ The recommended way to access raw POST data is to open and use a php://input
78
+ stream wrapper. It is safe to be used concurrently and more than once.
79
+
80
+ d. Arginfo changes
81
+
82
+ The pass_rest_by_reference argument of the ZEND_BEGIN_ARG_INFO and
83
+ ZEND_BEGIN_ARG_INFO_EX() is no longer used. The value passed to it is ignored.
84
+
85
+ Instead a variadic argument is created using ZEND_ARG_VARIADIC_INFO():
86
+
87
+ ZEND_ARG_VARIADIC_INFO(0, name) /* pass rest by value */
88
+ ZEND_ARG_VARIADIC_INFO(1, name) /* pass rest by reference */
89
+ ZEND_ARG_VARIADIC_INFO(ZEND_SEND_PREFER_REF, name)
90
+ /* pass rest by prefer-ref */
91
+
92
+ ZEND_ARG_VARIADIC_INFO() should only be used for the last argument.
93
+
94
+ The following changes were applied to the zend_arg_info struct:
95
+
96
+ typedef struct _zend_arg_info {
97
+ const char *class_name;
98
+ zend_uint class_name_len;
99
+ zend_uchar type_hint;
100
+ + zend_uchar pass_by_reference;
101
+ zend_bool allow_null;
102
+ - zend_bool pass_by_reference;
103
+ + zend_bool is_variadic;
104
+ } zend_arg_info;
105
+
106
+ The following changes were applied to the zend_internal_function_info struct:
107
+
108
+ typedef struct _zend_internal_function_info {
109
+ zend_uint required_num_args;
110
+ zend_uchar _type_hint;
111
+ zend_bool return_reference;
112
+ - zend_bool pass_rest_by_reference;
113
+ + zend_bool _allow_null;
114
+ + zend_bool _is_variadic;
115
+ } zend_internal_function_info;
116
+
117
+ The CHECK_ARG_SEND_TYPE(), ARG_MUST_BE_SENT_BY_REF(),
118
+ ARG_SHOULD_BE_SENT_BY_REF() and ARG_MAY_BE_SENT_BY_REF() macros now assume
119
+ that the argument passed to them is a zend_function* and that it is non-NULL.
120
+
121
+ e. tsrm_virtual_cwd.h moved to zend_virtual_cwd.h
21
122
123
+ Memory allocation is now managed by emalloc/efree instead of malloc/free.
124
+
125
+ f. empty strings are interned
126
+
127
+ String created using STR_EMPTY_ALLOC() are now interned.
128
+ convert_to_string use STR_EMPTY_ALLOC() for zval when IS_NULL.
129
+ str_efree() shoud be preferred as efree() on such strings can cause memory
130
+ corruption.
131
+
132
+ g. Additional str_* APIs
133
+
134
+ In addition to the previously existing str_free() and str_efree() macros, the
135
+ following macros have been introduced to simplify dealing with potentially
136
+ interned strings:
137
+
138
+ str_efree_rel(str) - efree_rel() if not interned
139
+ str_erealloc(str, new_len) - erealloc() or emalloc+memcpy if interned
140
+ str_estrndup(str, len) - estrndup() if not interned
141
+ str_strndup(str, len) - zend_strndup() if not interned
142
+ str_hash(str, len) - INTERNED_HASH(str) if interned,
143
+ zend_hash_func(str, len+1) otherwise
144
+
145
+ h. Addition of zend_hash_reindex
146
+
147
+ A zend_hash_reindex() function with the following prototype has been added:
148
+
149
+ void zend_hash_reindex(HashTable *ht, zend_bool only_integer_keys);
150
+
151
+ If only_integer_keys==0, this function will change all keys to be continuous,
152
+ zero-based integers in hash order. If only_integer_keys==1 the same will be
153
+ done only for keys that were already integers previously, while leaving
154
+ string keys alone.
155
+
156
+ i. Addition of zend_hash_splice
157
+
158
+ A zend_hash_splice() macro with the following prototype has been added:
159
+
160
+ void zend_hash_splice(
161
+ HashTable *ht, uint nDataSize, copy_ctor_func_t pCopyConstructor,
162
+ uint offset, uint length,
163
+ void **list, uint list_count, HashTable *removed
164
+ );
165
+
166
+ This function performs an in-place splice operation on a hashtable:
167
+
168
+ The elements between offset and offset+length are removed and the elements in
169
+ list[list_count] are inserted in their place. The removed elements can be
170
+ optionally collected into a hashtable.
171
+
172
+ This operation reindexes the hashtable, i.e. integer keys will be zero-based
173
+ and sequential, while string keys stay intact. The same applies to the
174
+ elements inserted into the removed HT.
175
+
176
+ As a side-effect of this addition the signature of the php_splice() function
177
+ changed:
178
+
179
+ void php_splice(
180
+ HashTable *ht, zend_uint offset, zend_uint length,
181
+ zval ***list, zend_uint list_count, HashTable *removed TSRMLS_DC
182
+ )
183
+
184
+ This function now directly forwards to zend_hash_splice(), resets the
185
+ IAP of ht (for compatibility with the previous implementation) and resets
186
+ CVs if the passed hashtable is the global symbol table.
187
+
188
+ j. An additional parameter is sent to Countable::count()
189
+
190
+ That parameter denotes the $mode passed to count; it shouldn't affect any
191
+ userland code, but any zend_parse_parameters() used with no arguments should
192
+ fail. Extensions which implement Countable internally, need to accept one
193
+ optional long as parameter.
194
+
195
+ k. Unserialization of manipulated object strings
196
+
197
+ Strings requiring unserialization of objects are now explicitly checked
198
+ whether the object they contain implements the Serializable interface.
199
+ This solves the situation where manipulated strings could be passed for
200
+ objects using Serializable to disallow serialization. An object
201
+ implementing Serializable will always start with "C:" in the serialized
202
+ string, all other objects are represented with starting "O:". Objects
203
+ implementing Serializable to disable serialization using
204
+ zend_class_unserialize_deny and zend_class_serialize_deny, when
205
+ instantiated from the serializer with a manipulated "O:" string at the
206
+ start, will most likely be defectively initialized. This is now
207
+ fixed at the appropriate place by checking for the presence of the
208
+ serialize callback in the class entry.
209
+
210
+ l. Removal of IS_CONSTANT_ARRAY and IS_CONSTANT_INDEX hack
211
+
212
+ These two #defines disappeared. Instead we have now IS_CONSTANT_AST which
213
+ covers also the functionality IS_CONSTANT_ARRAY bid and furthermore the
214
+ hack for marking zvals as constant index with IS_CONSTANT_INDEX is now
215
+ superfluous and so removed.
216
+ Please note that IS_CONSTANT_AST now has the same value than
217
+ IS_CONSTANT_ARRAY had.
22
218
23
219
========================
24
220
2. Build system changes
25
221
========================
26
222
27
-
223
+ a. Unix build system changes
224
+ - The bison version check is now a blacklist instead of a whitelist.
225
+ - The bison binary can be specified through the YACC environment/configure
226
+ variable. Previously `bison` was assumed to be in $PATH.
227
+
228
+ b. Windows build system changes
229
+ - The configure option --enable-static-analyze isn't available anymore.
230
+ The new option was introduced --with-analyzer.
231
+ - It is possible to disable PGO for single extensions, to do that
232
+ define a global variable PHP_MYMODULE_PGO evaluating to false
233
+ inside config.w32
0 commit comments