Skip to content

Commit

Permalink
Merge branch 'master' into phpng
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dstogov committed Jul 8, 2014
2 parents b36aaea + 6e9bc95 commit 8ce2f2c
Show file tree
Hide file tree
Showing 20 changed files with 96 additions and 28 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ notifications:
email:
on_failure: change

cache:
- apt

env:
global:
- MYSQL_TEST_HOST=127.0.0.1
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions ext/intl/tests/bug67052.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -23,3 +22,4 @@ ut_run();
--EXPECT--
1234567,891
de_DE

5 changes: 4 additions & 1 deletion ext/session/mod_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
} \
Expand Down
2 changes: 1 addition & 1 deletion ext/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
1 change: 1 addition & 0 deletions ext/session/tests/bug60634_error_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function open($save_path, $session_name) {

function close() {
echo "close: goodbye cruel world\n";
return true;
}

function read($id) {
Expand Down
1 change: 1 addition & 0 deletions ext/session/tests/bug60634_error_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function open($save_path, $session_name) {

function close() {
echo "close: goodbye cruel world\n";
return true;
}

function read($id) {
Expand Down
5 changes: 3 additions & 2 deletions ext/session/tests/save_handler.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down
14 changes: 8 additions & 6 deletions ext/session/tests/session_module_name_variation3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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
3 changes: 2 additions & 1 deletion ext/session/tests/session_set_save_handler_class_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions ext/session/tests/session_set_save_handler_class_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion ext/session/tests/session_set_save_handler_class_012.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion ext/session/tests/session_set_save_handler_class_016.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion ext/session/tests/session_set_save_handler_class_017.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion ext/session/tests/session_set_save_handler_error3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion ext/session/tests/session_set_save_handler_error4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion ext/session/tests/session_set_save_handler_iface_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions ext/session/tests/session_set_save_handler_variation4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
7 changes: 3 additions & 4 deletions sapi/cli/php_cli_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
43 changes: 43 additions & 0 deletions sapi/cli/tests/bug66830.phpt
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions travis/de
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
de_DE.UTF-8 UTF-8
de_DE ISO-8859-1

0 comments on commit 8ce2f2c

Please sign in to comment.