Skip to content

Commit f282504

Browse files
committed
Merge branch 'master' into jsond
Conflicts: ext/json/json.c
2 parents 0a81f9a + ce9f52a commit f282504

File tree

186 files changed

+8987
-5738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+8987
-5738
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ before_script:
4444

4545
# Run PHPs run-tests.php
4646
script:
47-
- ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff --set-timeout 120
47+
- ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --offline --show-diff --set-timeout 120
4848
- ./sapi/cli/php sapi/phpdbg/tests/run-tests.php -diff2stdout --phpdbg sapi/phpdbg/phpdbg

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@
102102
- PCRE:
103103
. Removed support for the /e (PREG_REPLACE_EVAL) modifier. (Nikita)
104104

105+
- PDO:
106+
. Fixed bug #59450 (./configure fails with "Cannot find php_pdo_driver.h").
107+
(maxime dot besson at smile dot fr)
108+
105109
- PDO_mysql:
106110
. Fixed bug #68424 (Add new PDO mysql connection attr to control multi
107111
statements option). (peter dot wolanin at acquia dot com)

UPGRADING

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ PHP X.Y UPGRADE NOTES
7272
hexadecimal numbers. Furthermore is_numeric() will not consider hexadecimal
7373
strings to be numeric (use FILTER_VALIDATE_INT instead).
7474
(RFC: https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings)
75+
. $HTTP_RAW_POST_DATA is no longer available. Use the php://input stream instead.
7576

7677
- Date:
7778
. Removed $is_dst parameter from mktime() and gmmktime().
@@ -191,6 +192,7 @@ PHP X.Y UPGRADE NOTES
191192
- Core
192193
. Removed asp_tags ini directive. Trying to enable it will result in a fatal
193194
error.
195+
. Removed always_populate_raw_post_data ini directive.
194196

195197
========================================
196198
12. Windows Support

UPGRADING.INTERNALS

+19-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ PHP 7.0 INTERNALS UPGRADE NOTES
2727
1. Internal API changes
2828
========================
2929

30-
a. zend_set_memory_limit() now takes the TSRMLS_CC macro as its last argument
3130
e. New data types
3231

3332
String
@@ -180,6 +179,11 @@ PHP 7.0 INTERNALS UPGRADE NOTES
180179
r. In accordance with general use of size_t as string length, all PDO API
181180
functions now use size_t for string length.
182181

182+
s. Removed ZEND_REGISTER/FETCH_RESOURCE, use zend_fetch_resource and
183+
and zend_register_resource instead, zend_fetch_resource accepts a zend_resource *
184+
as first argument, if you still need to fetch a resource from zval, use
185+
zend_fetch_resource_ex. More details can be found in Zend/zend_list.c.
186+
183187

184188
========================
185189
2. Build system changes
@@ -214,12 +218,20 @@ PHP 7.0 INTERNALS UPGRADE NOTES
214218

215219
- PS_MOD_UPDATE_TIMESTAMP() session save handler definition is added. New
216220
save handler should use PS_MOD_UPDATE_TIMESTAMP() definition. Save handler
217-
must not refer/change PS() variables directly from save handler.
218-
- PS_MOD_UPDATE_TIMESTAMP() defines validate_sid() handler. This handler
219-
must validate if requested session ID is in session data storage or not.
220-
Internal save handler needed to asscess PS(id) directly to validate it.
221-
Do not access PS(id), but use this handler.
222-
- PS_MOD_UPDATE_TIMESTAMP() defines update_timestamp() handlers. This handler
221+
must not refer/change PS() variables directly from save handler. Use
222+
parameters.
223+
- PS_MOD()/PS_MOD_SID() macro exist only for transition. Beware these
224+
save handlers are less secure and slower than PS_MOD_UPDATE_TIMESTAMP().
225+
- PS(invalid_session_id) was removed. It was never worked as it supposed.
226+
To report invalid session ID, use PS_VALIDATE_SID() handler.
227+
- PS_VALIDATE_SID() defines session ID validation handler. This handler
228+
must validate if requested session ID exists in session data storage or not.
229+
Do not access PS(id) directly, but use this handler and it's parameter.
230+
- PS_UPDATE_TIMESTAMP() defines timestamp updating handler. This handler
223231
must update session data timestamp for GC if it is needed. e.g. Memcache
224232
updates timestap on read, so it does not need to update timestamp. Return
225233
SUCCESS simply for this case.
234+
- PS_CREATE_SID() should check session ID collision. Return NULL for failure.
235+
- More documentation can be found in ext/session/mod_files.c as comments.
236+
mod_files.c may be used as reference implementation.
237+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Return type hinting for internal functions
3+
4+
--SKIPIF--
5+
<?php
6+
if (!function_exists('zend_test_func')) {
7+
print 'skip';
8+
}
9+
10+
--FILE--
11+
<?php
12+
zend_test_func();
13+
?>
14+
--EXPECTF--
15+
Fatal error: Return value of zend_test_func() must be of the type array, null returned in %s on line %d
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Return type hinting for internal functions 2
3+
4+
--SKIPIF--
5+
<?php
6+
if (!function_exists('zend_test_func2')) {
7+
print 'skip';
8+
}
9+
10+
--FILE--
11+
<?php
12+
zend_test_func2();
13+
echo "==DONE==\n"
14+
?>
15+
--EXPECTF--
16+
==DONE==

Zend/zend.c

+13-7
Original file line numberDiff line numberDiff line change
@@ -957,15 +957,15 @@ ZEND_API zval *zend_get_configuration_directive(zend_string *name) /* {{{ */
957957
} \
958958
} while (0)
959959

960-
#if !defined(ZEND_WIN32) && !defined(DARWIN)
960+
#if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
961961
ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
962962
#else
963963
static void zend_error_va_list(int type, const char *format, va_list args)
964964
#endif
965965
{
966966
char *str;
967967
int len;
968-
#if !defined(ZEND_WIN32) && !defined(DARWIN)
968+
#if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
969969
va_list args;
970970
#endif
971971
va_list usr_copy;
@@ -1059,17 +1059,21 @@ static void zend_error_va_list(int type, const char *format, va_list args)
10591059
}
10601060

10611061
#ifdef HAVE_DTRACE
1062-
if(DTRACE_ERROR_ENABLED()) {
1062+
if (DTRACE_ERROR_ENABLED()) {
10631063
char *dtrace_error_buffer;
1064+
#if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
10641065
va_start(args, format);
1066+
#endif
10651067
zend_vspprintf(&dtrace_error_buffer, 0, format, args);
10661068
DTRACE_ERROR(dtrace_error_buffer, (char *)error_filename, error_lineno);
10671069
efree(dtrace_error_buffer);
1070+
#if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
10681071
va_end(args);
1072+
#endif
10691073
}
10701074
#endif /* HAVE_DTRACE */
10711075

1072-
#if !defined(ZEND_WIN32) && !defined(DARWIN)
1076+
#if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
10731077
va_start(args, format);
10741078
#endif
10751079

@@ -1182,7 +1186,7 @@ static void zend_error_va_list(int type, const char *format, va_list args)
11821186
break;
11831187
}
11841188

1185-
#if !defined(ZEND_WIN32) && !defined(DARWIN)
1189+
#if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
11861190
va_end(args);
11871191
#endif
11881192

@@ -1199,9 +1203,10 @@ static void zend_error_va_list(int type, const char *format, va_list args)
11991203
}
12001204
/* }}} */
12011205

1202-
#if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__))
1206+
#ifdef HAVE_NORETURN
1207+
# ifdef HAVE_NORETURN_ALIAS
12031208
void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((alias("zend_error"),noreturn));
1204-
#elif defined(ZEND_WIN32) || defined(DARWIN)
1209+
# else
12051210
ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
12061211
{
12071212
va_list va;
@@ -1220,6 +1225,7 @@ ZEND_API ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ..
12201225
va_end(va);
12211226
}
12221227
/* }}} */
1228+
# endif
12231229
#endif
12241230

12251231
ZEND_API void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) /* {{{ */

Zend/zend.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@
7777
ZEND_TSRMLS_CACHE_EXTERN;
7878

7979
#ifdef HAVE_NORETURN
80-
# if defined(ZEND_WIN32)
81-
ZEND_API ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...);
82-
# else
80+
# ifdef ZEND_NORETRUN_ALIAS
8381
void zend_error_noreturn(int type, const char *format, ...) ZEND_NORETURN;
82+
# else
83+
ZEND_API ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...);
8484
# endif
8585
#else
8686
# define zend_error_noreturn zend_error

Zend/zend_API.c

+23
Original file line numberDiff line numberDiff line change
@@ -2002,6 +2002,13 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
20022002
internal_function->num_args--;
20032003
}
20042004
if (info->type_hint) {
2005+
if (info->class_name) {
2006+
ZEND_ASSERT(info->type_hint == IS_OBJECT);
2007+
if (!strcasecmp(info->class_name, "self") && !scope) {
2008+
zend_error(E_CORE_ERROR, "Cannot declare a return type of self outside of a class scope");
2009+
}
2010+
}
2011+
20052012
internal_function->fn_flags |= ZEND_ACC_HAS_RETURN_TYPE;
20062013
}
20072014
} else {
@@ -2086,12 +2093,16 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
20862093
__tostring = reg_function;
20872094
} else if (zend_string_equals_literal(lowercase_name, ZEND_GET_FUNC_NAME)) {
20882095
__get = reg_function;
2096+
scope->ce_flags |= ZEND_ACC_USE_GUARDS;
20892097
} else if (zend_string_equals_literal(lowercase_name, ZEND_SET_FUNC_NAME)) {
20902098
__set = reg_function;
2099+
scope->ce_flags |= ZEND_ACC_USE_GUARDS;
20912100
} else if (zend_string_equals_literal(lowercase_name, ZEND_UNSET_FUNC_NAME)) {
20922101
__unset = reg_function;
2102+
scope->ce_flags |= ZEND_ACC_USE_GUARDS;
20932103
} else if (zend_string_equals_literal(lowercase_name, ZEND_ISSET_FUNC_NAME)) {
20942104
__isset = reg_function;
2105+
scope->ce_flags |= ZEND_ACC_USE_GUARDS;
20952106
} else if (zend_string_equals_literal(lowercase_name, ZEND_DEBUGINFO_FUNC_NAME)) {
20962107
__debugInfo = reg_function;
20972108
} else {
@@ -2202,6 +2213,18 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
22022213
zend_error(error_type, "Method %s::%s() cannot be static", scope->name->val, __debugInfo->common.function_name->val);
22032214
}
22042215
}
2216+
2217+
if (ctor && ctor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && ctor->common.fn_flags & ZEND_ACC_CTOR) {
2218+
zend_error(E_CORE_ERROR, "Constructor %s::%s() cannot declare a return type", scope->name->val, ctor->common.function_name->val);
2219+
}
2220+
2221+
if (dtor && dtor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && dtor->common.fn_flags & ZEND_ACC_DTOR) {
2222+
zend_error(E_CORE_ERROR, "Destructor %s::%s() cannot declare a return type", scope->name->val, dtor->common.function_name->val);
2223+
}
2224+
2225+
if (clone && clone->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && dtor->common.fn_flags & ZEND_ACC_DTOR) {
2226+
zend_error(E_CORE_ERROR, "%s::%s() cannot declare a return type", scope->name->val, clone->common.function_name->val);
2227+
}
22052228
efree((char*)lc_class_name);
22062229
}
22072230
return SUCCESS;

Zend/zend_API.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,15 @@ typedef struct _zend_fcall_info_cache {
105105
#define ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, NULL, type_hint, pass_by_ref, allow_null, 0 },
106106
#define ZEND_ARG_VARIADIC_INFO(pass_by_ref, name) { #name, NULL, 0, pass_by_ref, 0, 1 },
107107

108+
109+
#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, class_name, allow_null) \
110+
static const zend_internal_arg_info name[] = { \
111+
{ (const char*)(zend_uintptr_t)(required_num_args), class_name, type, return_reference, allow_null, 0 },
112+
#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(name, type, class_name, allow_null) \
113+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, 0, -1, type, class_name, allow_null)
114+
108115
#define ZEND_BEGIN_ARG_INFO_EX(name, _unused, return_reference, required_num_args) \
109-
static const zend_internal_arg_info name[] = { \
116+
static const zend_internal_arg_info name[] = { \
110117
{ (const char*)(zend_uintptr_t)(required_num_args), NULL, 0, return_reference, 0, 0 },
111118
#define ZEND_BEGIN_ARG_INFO(name, _unused) \
112119
ZEND_BEGIN_ARG_INFO_EX(name, 0, ZEND_RETURN_VALUE, -1)

Zend/zend_builtin_functions.c

+18-1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ static ZEND_FUNCTION(debug_backtrace);
8787
static ZEND_FUNCTION(debug_print_backtrace);
8888
#if ZEND_DEBUG
8989
static ZEND_FUNCTION(zend_test_func);
90+
static ZEND_FUNCTION(zend_test_func2);
9091
#ifdef ZTS
9192
static ZEND_FUNCTION(zend_thread_id);
9293
#endif
@@ -243,6 +244,14 @@ ZEND_END_ARG_INFO()
243244
ZEND_BEGIN_ARG_INFO_EX(arginfo_extension_loaded, 0, 0, 1)
244245
ZEND_ARG_INFO(0, extension_name)
245246
ZEND_END_ARG_INFO()
247+
248+
#ifdef ZEND_DEBUG
249+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func, IS_ARRAY, NULL, 0)
250+
ZEND_END_ARG_INFO()
251+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func2, IS_ARRAY, NULL, 1)
252+
ZEND_END_ARG_INFO()
253+
#endif
254+
246255
/* }}} */
247256

248257
static const zend_function_entry builtin_functions[] = { /* {{{ */
@@ -304,7 +313,8 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
304313
ZEND_FE(debug_backtrace, arginfo_debug_backtrace)
305314
ZEND_FE(debug_print_backtrace, arginfo_debug_print_backtrace)
306315
#if ZEND_DEBUG
307-
ZEND_FE(zend_test_func, NULL)
316+
ZEND_FE(zend_test_func, arginfo_zend_test_func)
317+
ZEND_FE(zend_test_func2, arginfo_zend_test_func2)
308318
#ifdef ZTS
309319
ZEND_FE(zend_thread_id, NULL)
310320
#endif
@@ -1954,6 +1964,13 @@ ZEND_FUNCTION(zend_test_func)
19541964
zend_get_parameters(ZEND_NUM_ARGS(), 2, &arg1, &arg2);
19551965
}
19561966

1967+
ZEND_FUNCTION(zend_test_func2)
1968+
{
1969+
zval *arg1, *arg2;
1970+
1971+
zend_get_parameters(ZEND_NUM_ARGS(), 2, &arg1, &arg2);
1972+
}
1973+
19571974

19581975
#ifdef ZTS
19591976
ZEND_FUNCTION(zend_thread_id)

Zend/zend_compile.c

+4
Original file line numberDiff line numberDiff line change
@@ -4130,24 +4130,28 @@ void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_boo
41304130
"public visibility and cannot be static");
41314131
}
41324132
ce->__get = (zend_function *) op_array;
4133+
ce->ce_flags |= ZEND_ACC_USE_GUARDS;
41334134
} else if (zend_string_equals_literal(lcname, ZEND_SET_FUNC_NAME)) {
41344135
if (!is_public || is_static) {
41354136
zend_error(E_WARNING, "The magic method __set() must have "
41364137
"public visibility and cannot be static");
41374138
}
41384139
ce->__set = (zend_function *) op_array;
4140+
ce->ce_flags |= ZEND_ACC_USE_GUARDS;
41394141
} else if (zend_string_equals_literal(lcname, ZEND_UNSET_FUNC_NAME)) {
41404142
if (!is_public || is_static) {
41414143
zend_error(E_WARNING, "The magic method __unset() must have "
41424144
"public visibility and cannot be static");
41434145
}
41444146
ce->__unset = (zend_function *) op_array;
4147+
ce->ce_flags |= ZEND_ACC_USE_GUARDS;
41454148
} else if (zend_string_equals_literal(lcname, ZEND_ISSET_FUNC_NAME)) {
41464149
if (!is_public || is_static) {
41474150
zend_error(E_WARNING, "The magic method __isset() must have "
41484151
"public visibility and cannot be static");
41494152
}
41504153
ce->__isset = (zend_function *) op_array;
4154+
ce->ce_flags |= ZEND_ACC_USE_GUARDS;
41514155
} else if (zend_string_equals_literal(lcname, ZEND_TOSTRING_FUNC_NAME)) {
41524156
if (!is_public || is_static) {
41534157
zend_error(E_WARNING, "The magic method __toString() must have "

Zend/zend_compile.h

+3
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ typedef struct _zend_try_catch_element {
242242
#define ZEND_ACC_RETURN_REFERENCE 0x4000000
243243
#define ZEND_ACC_DONE_PASS_TWO 0x8000000
244244

245+
/* class has magic methods __get/__set/__unset/__isset that use guards */
246+
#define ZEND_ACC_USE_GUARDS 0x1000000
247+
245248
/* function has arguments with type hinting */
246249
#define ZEND_ACC_HAS_TYPE_HINTS 0x10000000
247250

0 commit comments

Comments
 (0)