From 0e1599afe0c6aa89c725f31a88d484c901f16359 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Mon, 7 Jul 2014 09:32:26 -0700 Subject: [PATCH 1/5] rm test for now --- ext/intl/tests/bug67052.phpt | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 ext/intl/tests/bug67052.phpt diff --git a/ext/intl/tests/bug67052.phpt b/ext/intl/tests/bug67052.phpt deleted file mode 100644 index f3245f8398d3..000000000000 --- a/ext/intl/tests/bug67052.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -Bug #67052 - NumberFormatter::parse() resets LC_NUMERIC setting ---SKIPIF-- - ---FILE-- -parse($num)."\n"; - $res_str .= setlocale(LC_NUMERIC, 0); - return $res_str; -} - -include_once( 'ut_common.inc' ); -ut_run(); - -?> ---EXPECT-- -1234567,891 -de_DE From 551696363332942d26209368f441f6f152be4769 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Mon, 7 Jul 2014 09:35:37 -0700 Subject: [PATCH 2/5] create locales and re-add test --- .travis.yml | 7 +++++++ ext/intl/tests/bug67052.phpt | 25 +++++++++++++++++++++++++ travis/de | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 ext/intl/tests/bug67052.phpt create mode 100644 travis/de diff --git a/.travis.yml b/.travis.yml index 5b49434cc83b..b2ed607caced 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,9 @@ notifications: email: on_failure: change +cache: + - apt + env: global: - MYSQL_TEST_HOST=127.0.0.1 @@ -21,6 +24,10 @@ env: - ENABLE_MAINTAINER_ZTS=0 ENABLE_DEBUG=0 - ENABLE_MAINTAINER_ZTS=1 ENABLE_DEBUG=1 +before_install: + - sudo cp ./travis/de /var/lib/locales/supported.d/de + - sudo dpkg-reconfigure locales + before_script: # Compile PHP - ./travis/compile.sh diff --git a/ext/intl/tests/bug67052.phpt b/ext/intl/tests/bug67052.phpt new file mode 100644 index 000000000000..c8363b9c7ac1 --- /dev/null +++ b/ext/intl/tests/bug67052.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #67052 - NumberFormatter::parse() resets LC_NUMERIC setting +--SKIPIF-- + +--FILE-- +parse($num)."\n"; + $res_str .= setlocale(LC_NUMERIC, 0); + return $res_str; +} + +include_once( 'ut_common.inc' ); +ut_run(); + +?> +--EXPECT-- +1234567,891 +de_DE + diff --git a/travis/de b/travis/de new file mode 100644 index 000000000000..ae49d969ee2e --- /dev/null +++ b/travis/de @@ -0,0 +1,2 @@ +de_DE.UTF-8 UTF-8 +de_DE ISO-8859-1 From 7c2489751cc48961487edd69b49083d4ca6b4828 Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Mon, 7 Jul 2014 12:19:11 -0700 Subject: [PATCH 3/5] Followup fix to custom session save handlers 2d9885c introduced some regressions. This addresses those. * Don't throw return type notice or session write failure when in an exception * Fix tests to properly return true/false since null is no longer falsy/successy * Rerecord a few tests to accomodate difference in raised warnings --- ext/session/mod_user.c | 5 ++++- ext/session/session.c | 2 +- ext/session/tests/bug60634_error_1.phpt | 1 + ext/session/tests/bug60634_error_2.phpt | 1 + ext/session/tests/save_handler.inc | 5 +++-- .../tests/session_module_name_variation3.phpt | 14 ++++++++------ .../tests/session_set_save_handler_class_002.phpt | 3 ++- .../tests/session_set_save_handler_class_005.phpt | 2 ++ .../tests/session_set_save_handler_class_012.phpt | 6 +++++- .../tests/session_set_save_handler_class_016.phpt | 2 +- .../tests/session_set_save_handler_error3.phpt | 4 +++- .../tests/session_set_save_handler_error4.phpt | 2 +- .../tests/session_set_save_handler_iface_001.phpt | 2 +- .../tests/session_set_save_handler_variation4.phpt | 1 + 14 files changed, 34 insertions(+), 16 deletions(-) diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c index 672098758092..1eabc9432eaf 100644 --- a/ext/session/mod_user.c +++ b/ext/session/mod_user.c @@ -79,7 +79,10 @@ static zval *ps_call_handler(zval *func, int argc, zval **argv TSRMLS_DC) /* BC for clever users - Deprecate me */ \ ret = SUCCESS; \ } else { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Session callback expects true/false return value"); \ + if (!EG(exception)) { \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, \ + "Session callback expects true/false return value"); \ + } \ ret = FAILURE; \ } \ zval_ptr_dtor(&retval); \ diff --git a/ext/session/session.c b/ext/session/session.c index d6568bdbb546..05fa95d4da07 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -566,7 +566,7 @@ static void php_session_save_current_state(TSRMLS_D) /* {{{ */ } } - if (ret == FAILURE) { + if ((ret == FAILURE) && !EG(exception)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write session data (%s). Please " "verify that the current setting of session.save_path " "is correct (%s)", diff --git a/ext/session/tests/bug60634_error_1.phpt b/ext/session/tests/bug60634_error_1.phpt index e41592f18dd0..cc50e8120946 100644 --- a/ext/session/tests/bug60634_error_1.phpt +++ b/ext/session/tests/bug60634_error_1.phpt @@ -16,6 +16,7 @@ function open($save_path, $session_name) { function close() { echo "close: goodbye cruel world\n"; + return true; } function read($id) { diff --git a/ext/session/tests/bug60634_error_2.phpt b/ext/session/tests/bug60634_error_2.phpt index 7c50948ba837..96c8eb61e51e 100644 --- a/ext/session/tests/bug60634_error_2.phpt +++ b/ext/session/tests/bug60634_error_2.phpt @@ -16,6 +16,7 @@ function open($save_path, $session_name) { function close() { echo "close: goodbye cruel world\n"; + return true; } function read($id) { diff --git a/ext/session/tests/save_handler.inc b/ext/session/tests/save_handler.inc index ebe9cac564d6..d27174825914 100644 --- a/ext/session/tests/save_handler.inc +++ b/ext/session/tests/save_handler.inc @@ -31,7 +31,7 @@ function write($id, $session_data) { if ($fp = fopen($session_file, "w")) { $return = fwrite($fp, $session_data); fclose($fp); - return $return; + return (bool)$return; } return false; } @@ -40,7 +40,8 @@ function destroy($id) { global $session_save_path, $name; echo "Destroy [${session_save_path},${id}]\n"; $session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id; - return unlink($session_file); + unlink($session_file); + return true; } function gc($maxlifetime) { diff --git a/ext/session/tests/session_module_name_variation3.phpt b/ext/session/tests/session_module_name_variation3.phpt index dc1c6ba5ec58..e32790d54eff 100644 --- a/ext/session/tests/session_module_name_variation3.phpt +++ b/ext/session/tests/session_module_name_variation3.phpt @@ -21,11 +21,11 @@ function open($save_path, $session_name) { throw new Exception("Stop...!"); } -function close() { } -function read($id) { } -function write($id, $session_data) { } -function destroy($id) { } -function gc($maxlifetime) { } +function close() { return true; } +function read($id) { return ''; } +function write($id, $session_data) { return true; } +function destroy($id) { return true; } +function gc($maxlifetime) { return true; } var_dump(session_module_name("files")); session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); @@ -41,9 +41,11 @@ ob_end_flush(); string(%d) "%s" string(4) "user" -Fatal error: Uncaught exception 'Exception' with message 'Stop...!' in %s:%d +Warning: Uncaught exception 'Exception' with message 'Stop...!' in %s:%d Stack trace: #0 [internal function]: open('', 'PHPSESSID') #1 %s(%d): session_start() #2 {main} thrown in %s on line %d + +Fatal error: session_start(): Failed to initialize storage module: %s in %s/session_module_name_variation3.php on line %d diff --git a/ext/session/tests/session_set_save_handler_class_002.phpt b/ext/session/tests/session_set_save_handler_class_002.phpt index 6fb831f6957a..b75a7e639089 100644 --- a/ext/session/tests/session_set_save_handler_class_002.phpt +++ b/ext/session/tests/session_set_save_handler_class_002.phpt @@ -38,11 +38,12 @@ class MySession2 extends SessionHandler { } public function write($id, $data) { - return file_put_contents($this->path . $id, $data); + return (bool)file_put_contents($this->path . $id, $data); } public function destroy($id) { @unlink($this->path . $id); + return true; } public function gc($maxlifetime) { diff --git a/ext/session/tests/session_set_save_handler_class_005.phpt b/ext/session/tests/session_set_save_handler_class_005.phpt index c74c81de1dbc..5be735306ac6 100644 --- a/ext/session/tests/session_set_save_handler_class_005.phpt +++ b/ext/session/tests/session_set_save_handler_class_005.phpt @@ -52,4 +52,6 @@ array(0) { Warning: SessionHandler::write(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d +Warning: session_write_close(): Failed to write session data %s in %ssession_set_save_handler_class_005.php on line %d + Warning: SessionHandler::close(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d diff --git a/ext/session/tests/session_set_save_handler_class_012.phpt b/ext/session/tests/session_set_save_handler_class_012.phpt index 3899d28816e1..60cd12955c92 100644 --- a/ext/session/tests/session_set_save_handler_class_012.phpt +++ b/ext/session/tests/session_set_save_handler_class_012.phpt @@ -24,7 +24,9 @@ class MySession extends SessionHandler { public function open($path, $name) { ++$this->i; echo 'Open ', session_id(), "\n"; - return parent::open(); + // This test was written for broken return value handling + // Mimmick what was actually being tested by returning true here + return (null === parent::open()); } public function read($key) { ++$this->i; @@ -57,4 +59,6 @@ array(0) { Warning: Unknown: Parent session handler is not open in Unknown on line 0 +Warning: Unknown: Failed to write session data %s in %s on line %d + Warning: Unknown: Parent session handler is not open in Unknown on line 0 diff --git a/ext/session/tests/session_set_save_handler_class_016.phpt b/ext/session/tests/session_set_save_handler_class_016.phpt index 2de03c0682e5..521bd86f3184 100644 --- a/ext/session/tests/session_set_save_handler_class_016.phpt +++ b/ext/session/tests/session_set_save_handler_class_016.phpt @@ -38,7 +38,7 @@ class MySession2 extends SessionHandler { } public function write($id, $data) { - return file_put_contents($this->path . $id, $data); + return (bool)file_put_contents($this->path . $id, $data); } public function destroy($id) { diff --git a/ext/session/tests/session_set_save_handler_error3.phpt b/ext/session/tests/session_set_save_handler_error3.phpt index cb07b0d8dec1..859ba11ad53c 100644 --- a/ext/session/tests/session_set_save_handler_error3.phpt +++ b/ext/session/tests/session_set_save_handler_error3.phpt @@ -34,9 +34,11 @@ ob_end_flush(); --EXPECTF-- *** Testing session_set_save_handler() : error functionality *** -Fatal error: Uncaught exception 'Exception' with message 'Do something bad..!' in %s:%d +Warning: Uncaught exception 'Exception' with message 'Do something bad..!' in %s:%d Stack trace: #0 [internal function]: open('', 'PHPSESSID') #1 %s(%d): session_start() #2 {main} thrown in %s on line %d + +Fatal error: session_start(): Failed to initialize storage module: %s in %ssession_set_save_handler_error3.php on line %d diff --git a/ext/session/tests/session_set_save_handler_error4.phpt b/ext/session/tests/session_set_save_handler_error4.phpt index d286f07d99d7..be3429b08424 100644 --- a/ext/session/tests/session_set_save_handler_error4.phpt +++ b/ext/session/tests/session_set_save_handler_error4.phpt @@ -15,7 +15,7 @@ ob_start(); echo "*** Testing session_set_save_handler() : error functionality ***\n"; -function callback() { } +function callback() { return true; } session_set_save_handler("callback", "callback", "callback", "callback", "callback", "callback"); session_set_save_handler("callback", "echo", "callback", "callback", "callback", "callback"); diff --git a/ext/session/tests/session_set_save_handler_iface_001.phpt b/ext/session/tests/session_set_save_handler_iface_001.phpt index 39a4b9975b58..03ee42865c09 100644 --- a/ext/session/tests/session_set_save_handler_iface_001.phpt +++ b/ext/session/tests/session_set_save_handler_iface_001.phpt @@ -38,7 +38,7 @@ class MySession2 implements SessionHandlerInterface { } public function write($id, $data) { - return file_put_contents($this->path . $id, $data); + return (bool)file_put_contents($this->path . $id, $data); } public function destroy($id) { diff --git a/ext/session/tests/session_set_save_handler_variation4.phpt b/ext/session/tests/session_set_save_handler_variation4.phpt index 3485f2373aa5..c34eb9cd9fb0 100644 --- a/ext/session/tests/session_set_save_handler_variation4.phpt +++ b/ext/session/tests/session_set_save_handler_variation4.phpt @@ -24,6 +24,7 @@ echo "*** Testing session_set_save_handler() : variation ***\n"; function noisy_gc($maxlifetime) { echo("GC [".$maxlifetime."]\n"); gc($maxlifetime); + return true; } require_once "save_handler.inc"; From 604de67b7d0b8c6db76002011e3b55dd9c7aeec8 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Mon, 7 Jul 2014 20:36:06 +0000 Subject: [PATCH 4/5] Fixed bug #66830 (Empty header causes PHP built-in web server to hang). We had an infinite loop in sapi_cli_server_send_headers(): while iterating over the linked list of headers, when an empty header was hit, continue would go to the next iteration of the loop without updating h to be the next value in the linked list. Updating it to always increment regardless of whether the header is actually valid or not fixes the issue. --- NEWS | 2 ++ sapi/cli/php_cli_server.c | 7 +++--- sapi/cli/tests/bug66830.phpt | 43 ++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 sapi/cli/tests/bug66830.phpt diff --git a/NEWS b/NEWS index ee9bb13e3092..53d4f668cd8c 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ PHP NEWS - CLI server: . Implemented FR #67429 (CLI server is missing some new HTTP response codes). (Adam) + . Fixed bug #66830 (Empty header causes PHP built-in web server to hang). + (Adam) - FPM: . Fixed bug #67531 (syslog cannot be set in pool configuration). (Remi) diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 2425cc0c3e66..375aa25c4264 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -540,11 +540,10 @@ static int sapi_cli_server_send_headers(sapi_headers_struct *sapi_headers TSRMLS h = (sapi_header_struct*)zend_llist_get_first_ex(&sapi_headers->headers, &pos); while (h) { - if (!h->header_len) { - continue; + if (h->header_len) { + smart_str_appendl(&buffer, h->header, h->header_len); + smart_str_appendl(&buffer, "\r\n", 2); } - smart_str_appendl(&buffer, h->header, h->header_len); - smart_str_appendl(&buffer, "\r\n", 2); h = (sapi_header_struct*)zend_llist_get_next_ex(&sapi_headers->headers, &pos); } smart_str_appendl(&buffer, "\r\n", 2); diff --git a/sapi/cli/tests/bug66830.phpt b/sapi/cli/tests/bug66830.phpt new file mode 100644 index 000000000000..68fcf21c11a5 --- /dev/null +++ b/sapi/cli/tests/bug66830.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #66830 (Empty header causes PHP built-in web server to hang) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: %s +Content-type: text/html + From 6e9bc95f6726f4d397d6f78e778f512b92b1b54b Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Mon, 7 Jul 2014 14:30:28 -0700 Subject: [PATCH 5/5] Fix still broken session test. Only return true/false. --- ext/session/tests/session_set_save_handler_class_017.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/session/tests/session_set_save_handler_class_017.phpt b/ext/session/tests/session_set_save_handler_class_017.phpt index 756dc55d0304..6f42d7809ade 100644 --- a/ext/session/tests/session_set_save_handler_class_017.phpt +++ b/ext/session/tests/session_set_save_handler_class_017.phpt @@ -38,7 +38,7 @@ class MySession2 extends SessionHandler { } public function write($id, $data) { - return file_put_contents($this->path . $id, $data); + return (bool)file_put_contents($this->path . $id, $data); } public function destroy($id) {