diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-07-08 11:32:29 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-07-08 11:32:29 +0400 |
commit | 8ce2f2caacc99c8a579ebfaa078ac9a063e2936f (patch) | |
tree | eeac185eb793b7a4e81d32ae4bbf84fb66b05246 | |
parent | b36aaea6ede499589b3298e204095c292d025c34 (diff) | |
parent | 6e9bc95f6726f4d397d6f78e778f512b92b1b54b (diff) | |
download | php-git-8ce2f2caacc99c8a579ebfaa078ac9a063e2936f.tar.gz |
Merge branch 'master' into phpng
* master:
Fix still broken session test. Only return true/false.
Fixed bug #66830 (Empty header causes PHP built-in web server to hang).
Followup fix to custom session save handlers
create locales and re-add test
rm test for now
Conflicts:
ext/session/tests/session_set_save_handler_class_012.phpt
20 files changed, 96 insertions, 28 deletions
diff --git a/.travis.yml b/.travis.yml index 248ab861f8..d9e11a07d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,9 @@ notifications: email: on_failure: change +cache: + - apt + env: global: - MYSQL_TEST_HOST=127.0.0.1 @@ -28,6 +31,9 @@ env: before_install: - sudo apt-get update -qq - sudo apt-get install -y libenchant-dev libaspell-dev libpspell-dev librecode-dev + - 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 index f3245f8398..c8363b9c7a 100644 --- a/ext/intl/tests/bug67052.phpt +++ b/ext/intl/tests/bug67052.phpt @@ -7,13 +7,12 @@ Bug #67052 - NumberFormatter::parse() resets LC_NUMERIC setting function ut_main() { - setlocale(LC_ALL, 'de_DE'); - - $fmt = new NumberFormatter( 'sl_SI.UTF-8', NumberFormatter::DECIMAL); - $num = "1.234.567,891"; - $res_str = $fmt->parse($num)."\n"; - $res_str .= setlocale(LC_NUMERIC, 0); - return $res_str; + setlocale(LC_ALL, 'de_DE'); + $fmt = new NumberFormatter( 'sl_SI.UTF-8', NumberFormatter::DECIMAL); + $num = "1.234.567,891"; + $res_str = $fmt->parse($num)."\n"; + $res_str .= setlocale(LC_NUMERIC, 0); + return $res_str; } include_once( 'ut_common.inc' ); @@ -23,3 +22,4 @@ ut_run(); --EXPECT-- 1234567,891 de_DE + diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c index 7996575cd4..9e09dff83b 100644 --- a/ext/session/mod_user.c +++ b/ext/session/mod_user.c @@ -80,7 +80,10 @@ static void ps_call_handler(zval *func, int argc, zval *argv, zval *retval TSRML /* 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 529e6eee2d..fdd6b1696a 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -556,7 +556,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 e41592f18d..cc50e81209 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 7c50948ba8..96c8eb61e5 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 ebe9cac564..d271748259 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 dc1c6ba5ec..e32790d54e 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 6fb831f695..b75a7e6390 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 c74c81de1d..5be735306a 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 282f293b45..91e751bdfc 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: SessionHandler::write(): Parent session handler is not open in Unknown on line 0 +Warning: session_write_close(): Failed to write session data %s in %s on line %d + Warning: SessionHandler::close(): 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 2de03c0682..521bd86f31 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_class_017.phpt b/ext/session/tests/session_set_save_handler_class_017.phpt index 756dc55d03..6f42d7809a 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) { diff --git a/ext/session/tests/session_set_save_handler_error3.phpt b/ext/session/tests/session_set_save_handler_error3.phpt index cb07b0d8de..859ba11ad5 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 d286f07d99..be3429b084 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 39a4b9975b..03ee42865c 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 3485f2373a..c34eb9cd9f 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"; diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 85881bcab5..4b16e97a56 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -597,11 +597,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 0000000000..58c07e031a --- /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-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php +include "php_cli_server.inc"; +php_cli_server_start(<<<'PHP' +header(' '); +PHP +); + +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); +$port = intval($port)?:80; + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} + +if(fwrite($fp, <<<HEADER +GET / HTTP/1.1 +Host: {$host} + + +HEADER +)) { + while (!feof($fp)) { + echo fgets($fp); + } +} + +fclose($fp); +?> +--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: %s +Content-type: text/html; charset=UTF-8 + diff --git a/travis/de b/travis/de new file mode 100644 index 0000000000..ae49d969ee --- /dev/null +++ b/travis/de @@ -0,0 +1,2 @@ +de_DE.UTF-8 UTF-8 +de_DE ISO-8859-1 |