Skip to content

Commit 7497c87

Browse files
committed
Merge branch 'master' into phpng
* master: (51 commits) Update Git rules Back to -dev (with EOL notice in NEWS) new NEWS block for the next release It's 2014 already, fix copyright year where user visible PHP 5.3.29 Some changes were lost in the merge commit of #66091 Updated NEWS for #66091 Fixed #66091 Updated NEWS for #66091 Updated NEWS for #66091 Fixed #66091 updated NEWS updated NEWS updated NEWS backported the fix for bug #41577 NEWS entry for e6d93a1 / d73d44c restore FPM compatibility with mod_fastcgi broken since #694 / 67541, fixes bug 67606 Revert "Merge branch 'pull-request/694' into PHP-5.6" PHP 5.3.29RC1 Fix missing type checks in various functions ... Conflicts: ext/date/php_date.c ext/standard/math.c
2 parents 773d80c + 37e91cc commit 7497c87

File tree

6 files changed

+103
-30
lines changed

6 files changed

+103
-30
lines changed

README.GIT-RULES

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ Currently we have the following branches in use::
5151
PHP-5.4 Is used to release the PHP 5.4.x series. This is a current
5252
stable version and is open for bugfixes only.
5353

54-
PHP-5.3 Is used to release the PHP 5.3.x series. This is currently
55-
in extended support and open forsecurity fixes only. Triaged
56-
via security@php.net
54+
PHP-5.3 This branch is closed.
5755

5856
PHP-5.2 This branch is closed.
5957

@@ -63,7 +61,7 @@ Currently we have the following branches in use::
6361

6462
The next few rules are more of a technical nature::
6563

66-
1. All changes should first go to the lowest branch (i.e. 5.3) and then
64+
1. All changes should first go to the lowest branch (i.e. 5.4) and then
6765
get merged up to all other branches. If a change is not needed for
6866
later branches (i.e. fixes for features which where dropped from later
6967
branches) an empty merge should be done.

ext/com_dotnet/com_dotnet.c

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ PHP_FUNCTION(com_dotnet_create_instance)
198198
IUnknown *unk = NULL;
199199

200200
php_com_initialize(TSRMLS_C);
201-
if (COMG(dotnet_runtime_stuff) == NULL) {
201+
stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
202+
if (stuff == NULL) {
202203
hr = dotnet_init(&where TSRMLS_CC);
203204
if (FAILED(hr)) {
204205
char buf[1024];
@@ -210,9 +211,35 @@ PHP_FUNCTION(com_dotnet_create_instance)
210211
ZEND_CTOR_MAKE_NULL();
211212
return;
212213
}
213-
}
214+
stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
214215

215-
stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
216+
} else if (stuff->dotnet_domain == NULL) {
217+
where = "ICorRuntimeHost_GetDefaultDomain";
218+
hr = ICorRuntimeHost_GetDefaultDomain(stuff->dotnet_host, &unk);
219+
if (FAILED(hr)) {
220+
char buf[1024];
221+
char *err = php_win32_error_to_msg(hr);
222+
snprintf(buf, sizeof(buf), "Failed to re-init .Net domain [%s] %s", where, err);
223+
if (err)
224+
LocalFree(err);
225+
php_com_throw_exception(hr, buf TSRMLS_CC);
226+
ZVAL_NULL(object);
227+
return;
228+
}
229+
230+
where = "QI: System._AppDomain";
231+
hr = IUnknown_QueryInterface(unk, &IID_mscorlib_System_AppDomain, (LPVOID*)&stuff->dotnet_domain);
232+
if (FAILED(hr)) {
233+
char buf[1024];
234+
char *err = php_win32_error_to_msg(hr);
235+
snprintf(buf, sizeof(buf), "Failed to re-init .Net domain [%s] %s", where, err);
236+
if (err)
237+
LocalFree(err);
238+
php_com_throw_exception(hr, buf TSRMLS_CC);
239+
ZVAL_NULL(object);
240+
return;
241+
}
242+
}
216243

217244
obj = CDNO_FETCH(object);
218245

ext/date/php_date.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2596,16 +2596,18 @@ PHP_FUNCTION(date_create)
25962596
zval *timezone_object = NULL;
25972597
char *time_str = NULL;
25982598
int time_str_len = 0;
2599+
zval datetime_object;
25992600

26002601
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
26012602
RETURN_FALSE;
26022603
}
26032604

2604-
php_date_instantiate(date_ce_date, return_value TSRMLS_CC);
2605-
if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) {
2606-
zval_dtor(return_value);
2605+
php_date_instantiate(date_ce_date, &datetime_object TSRMLS_CC);
2606+
if (!php_date_initialize(Z_PHPDATE_P(&datetime_object), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) {
2607+
zval_dtor(&datetime_object);
26072608
RETURN_FALSE;
26082609
}
2610+
RETVAL_ZVAL(&datetime_object, 0, 0);
26092611
}
26102612
/* }}} */
26112613

@@ -2617,16 +2619,18 @@ PHP_FUNCTION(date_create_immutable)
26172619
zval *timezone_object = NULL;
26182620
char *time_str = NULL;
26192621
int time_str_len = 0;
2622+
zval datetime_object;
26202623

26212624
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
26222625
RETURN_FALSE;
26232626
}
26242627

2625-
php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC);
2626-
if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) {
2627-
zval_dtor(return_value);
2628+
php_date_instantiate(date_ce_immutable, &datetime_object TSRMLS_CC);
2629+
if (!php_date_initialize(Z_PHPDATE_P(&datetime_object), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) {
2630+
zval_dtor(&datetime_object);
26282631
RETURN_FALSE;
26292632
}
2633+
RETVAL_ZVAL(&datetime_object, 0, 0);
26302634
}
26312635
/* }}} */
26322636

@@ -2638,16 +2642,18 @@ PHP_FUNCTION(date_create_from_format)
26382642
zval *timezone_object = NULL;
26392643
char *time_str = NULL, *format_str = NULL;
26402644
int time_str_len = 0, format_str_len = 0;
2645+
zval datetime_object;
26412646

26422647
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|O", &format_str, &format_str_len, &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
26432648
RETURN_FALSE;
26442649
}
26452650

2646-
php_date_instantiate(date_ce_date, return_value TSRMLS_CC);
2647-
if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) {
2648-
zval_dtor(return_value);
2651+
php_date_instantiate(date_ce_date, &datetime_object TSRMLS_CC);
2652+
if (!php_date_initialize(Z_PHPDATE_P(&datetime_object), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) {
2653+
zval_dtor(&datetime_object);
26492654
RETURN_FALSE;
26502655
}
2656+
RETVAL_ZVAL(&datetime_object, 0, 0);
26512657
}
26522658
/* }}} */
26532659

@@ -2659,16 +2665,18 @@ PHP_FUNCTION(date_create_immutable_from_format)
26592665
zval *timezone_object = NULL;
26602666
char *time_str = NULL, *format_str = NULL;
26612667
int time_str_len = 0, format_str_len = 0;
2668+
zval datetime_object;
26622669

26632670
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|O", &format_str, &format_str_len, &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
26642671
RETURN_FALSE;
26652672
}
26662673

2667-
php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC);
2668-
if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) {
2669-
zval_dtor(return_value);
2674+
php_date_instantiate(date_ce_immutable, &datetime_object TSRMLS_CC);
2675+
if (!php_date_initialize(Z_PHPDATE_P(&datetime_object), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) {
2676+
zval_dtor(&datetime_object);
26702677
RETURN_FALSE;
26712678
}
2679+
RETVAL_ZVAL(&datetime_object, 0, 0);
26722680
}
26732681
/* }}} */
26742682

@@ -2738,7 +2746,7 @@ PHP_METHOD(DateTimeImmutable, createFromMutable)
27382746
}
27392747
/* }}} */
27402748

2741-
static int php_date_initialize_from_hash(zval *return_value, php_date_obj **dateobj, HashTable *myht TSRMLS_DC) /* {{{ */
2749+
static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht TSRMLS_DC)
27422750
{
27432751
zval *z_date;
27442752
zval *z_timezone;
@@ -2810,7 +2818,7 @@ PHP_METHOD(DateTime, __set_state)
28102818

28112819
php_date_instantiate(date_ce_date, return_value TSRMLS_CC);
28122820
dateobj = Z_PHPDATE_P(return_value);
2813-
if (!php_date_initialize_from_hash(return_value, &dateobj, myht TSRMLS_CC)) {
2821+
if (!php_date_initialize_from_hash(&dateobj, myht TSRMLS_CC)) {
28142822
php_error(E_ERROR, "Invalid serialization data for DateTime object");
28152823
}
28162824
}
@@ -2832,7 +2840,7 @@ PHP_METHOD(DateTimeImmutable, __set_state)
28322840

28332841
php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC);
28342842
dateobj = Z_PHPDATE_P(return_value);
2835-
if (!php_date_initialize_from_hash(return_value, &dateobj, myht TSRMLS_CC)) {
2843+
if (!php_date_initialize_from_hash(&dateobj, myht TSRMLS_CC)) {
28362844
php_error(E_ERROR, "Invalid serialization data for DateTimeImmutable object");
28372845
}
28382846
}
@@ -2850,7 +2858,7 @@ PHP_METHOD(DateTime, __wakeup)
28502858

28512859
myht = Z_OBJPROP_P(object);
28522860

2853-
if (!php_date_initialize_from_hash(return_value, &dateobj, myht TSRMLS_CC)) {
2861+
if (!php_date_initialize_from_hash(&dateobj, myht TSRMLS_CC)) {
28542862
php_error(E_ERROR, "Invalid serialization data for DateTime object");
28552863
}
28562864
}

ext/standard/config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ fi
338338
dnl
339339
dnl Check for available functions
340340
dnl
341-
AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan mempcpy strpncpy)
341+
AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p log2 hypot glob strfmon nice fpclass isinf isnan mempcpy strpncpy)
342342
AC_FUNC_FNMATCH
343343

344344
dnl

ext/standard/math.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -792,15 +792,27 @@ PHP_FUNCTION(log)
792792
if (ZEND_NUM_ARGS() == 1) {
793793
RETURN_DOUBLE(log(num));
794794
}
795-
if (base <= 0.0) {
796-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "base must be greater than 0");
797-
RETURN_FALSE;
795+
796+
#ifdef HAVE_LOG2
797+
if (base == 2.0) {
798+
RETURN_DOUBLE(log2(num));
798799
}
799-
if (base == 1) {
800+
#endif
801+
802+
if (base == 10.0) {
803+
RETURN_DOUBLE(log10(num));
804+
}
805+
806+
if (base == 1.0) {
800807
RETURN_DOUBLE(php_get_nan());
801-
} else {
802-
RETURN_DOUBLE(log(num) / log(base));
803808
}
809+
810+
if (base <= 0.0) {
811+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "base must be greater than 0");
812+
RETURN_FALSE;
813+
}
814+
815+
RETURN_DOUBLE(log(num) / log(base));
804816
}
805817
/* }}} */
806818

sapi/fpm/fpm/fpm_main.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,22 @@ static void init_request_info(TSRMLS_D)
11371137
TRANSLATE_SLASHES(env_document_root);
11381138
}
11391139

1140+
if (!apache_was_here && env_path_translated != NULL && env_redirect_url != NULL &&
1141+
env_path_translated != script_path_translated &&
1142+
strcmp(env_path_translated, script_path_translated) != 0) {
1143+
/*
1144+
* pretty much apache specific. If we have a redirect_url
1145+
* then our script_filename and script_name point to the
1146+
* php executable
1147+
* we don't want to do this for the new mod_proxy_fcgi approach,
1148+
* where redirect_url may also exist but the below will break
1149+
* with rewrites to PATH_INFO, hence the !apache_was_here check
1150+
*/
1151+
script_path_translated = env_path_translated;
1152+
/* we correct SCRIPT_NAME now in case we don't have PATH_INFO */
1153+
env_script_name = env_redirect_url;
1154+
}
1155+
11401156
#ifdef __riscos__
11411157
/* Convert path to unix format*/
11421158
__riscosify_control |= __RISCOSIFY_DONT_CHECK_DIR;
@@ -1314,6 +1330,18 @@ static void init_request_info(TSRMLS_D)
13141330
}
13151331
script_path_translated = _sapi_cgibin_putenv("SCRIPT_FILENAME", script_path_translated TSRMLS_CC);
13161332
}
1333+
if (!apache_was_here && env_redirect_url) {
1334+
/* if we used PATH_TRANSLATED to work around Apache mod_fastcgi (but not mod_proxy_fcgi,
1335+
* hence !apache_was_here) weirdness, strip info accordingly */
1336+
if (orig_path_info) {
1337+
_sapi_cgibin_putenv("ORIG_PATH_INFO", orig_path_info TSRMLS_CC);
1338+
_sapi_cgibin_putenv("PATH_INFO", NULL TSRMLS_CC);
1339+
}
1340+
if (orig_path_translated) {
1341+
_sapi_cgibin_putenv("ORIG_PATH_TRANSLATED", orig_path_translated TSRMLS_CC);
1342+
_sapi_cgibin_putenv("PATH_TRANSLATED", NULL TSRMLS_CC);
1343+
}
1344+
}
13171345
if (env_script_name != orig_script_name) {
13181346
if (orig_script_name) {
13191347
_sapi_cgibin_putenv("ORIG_SCRIPT_NAME", orig_script_name TSRMLS_CC);

0 commit comments

Comments
 (0)