Skip to content

Commit 457f1a3

Browse files
committed
Merge remote-tracking branch 'origin/master' into str_size_and_int64
* origin/master: This test depends on expose_php being on fixed broken merged code Fixed a bug that cannot access custom request header stored in apache_request_headers() though array index. Test output relies on expose_php being on 1.2 is a problematic float to print out Lower the default display precision for this test The test output is dependent on expose_php ini cleanup file headers. Do not kill children process in pre-fork mode when parent process quit. update year & copyright Fix bug #67587: Redirection loop on nginx with FPM Fix still broken session test. Only return true/false. Followup fix to custom session save handlers Fix handling of session user module custom handlers. Update info.c Conflicts: ext/session/mod_user.c main/php_content_types.c
2 parents 6ac9e10 + 833e466 commit 457f1a3

17 files changed

+51
-45
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PHP NEWS
1212

1313
- Standard:
1414
. Removed call_user_method() and call_user_method_array() functions. (Kalle)
15+
. Fix user session handlers (See rfc:session.user.return-value). (Sara)
1516

1617
- XSL:
1718
. Fixed bug #64776 (The XSLT extension is not thread safe). (Mike)

ext/session/mod_user.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,25 @@ static zval *ps_call_handler(zval *func, int argc, zval **argv TSRMLS_DC)
6868

6969
#define PSF(a) PS(mod_user_names).name.ps_##a
7070

71-
#define FINISH \
72-
if (retval) { \
73-
convert_to_int(retval); \
74-
ret = Z_IVAL_P(retval); \
75-
zval_ptr_dtor(&retval); \
76-
} \
71+
#define FINISH \
72+
if (retval) { \
73+
if (Z_TYPE_P(retval) == IS_BOOL) { \
74+
ret = Z_BVAL_P(retval) ? SUCCESS : FAILURE; \
75+
} else if ((Z_TYPE_P(retval) == IS_INT) && (Z_IVAL_P(retval) == -1)) { \
76+
/* BC for clever users - Deprecate me */ \
77+
ret = FAILURE; \
78+
} else if ((Z_TYPE_P(retval) == IS_INT) && (Z_IVAL_P(retval) == 0)) { \
79+
/* BC for clever users - Deprecate me */ \
80+
ret = SUCCESS; \
81+
} else { \
82+
if (!EG(exception)) { \
83+
php_error_docref(NULL TSRMLS_CC, E_WARNING, \
84+
"Session callback expects true/false return value"); \
85+
} \
86+
ret = FAILURE; \
87+
} \
88+
zval_ptr_dtor(&retval); \
89+
} \
7790
return ret
7891

7992
PS_OPEN_FUNC(user)

ext/session/session.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ static void php_session_save_current_state(TSRMLS_D) /* {{{ */
566566
}
567567
}
568568

569-
if (ret == FAILURE) {
569+
if ((ret == FAILURE) && !EG(exception)) {
570570
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write session data (%s). Please "
571571
"verify that the current setting of session.save_path "
572572
"is correct (%s)",

ext/session/tests/bug60634_error_1.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function open($save_path, $session_name) {
1616

1717
function close() {
1818
echo "close: goodbye cruel world\n";
19+
return true;
1920
}
2021

2122
function read($id) {

ext/session/tests/bug60634_error_2.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function open($save_path, $session_name) {
1616

1717
function close() {
1818
echo "close: goodbye cruel world\n";
19+
return true;
1920
}
2021

2122
function read($id) {

ext/session/tests/save_handler.inc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function write($id, $session_data) {
3131
if ($fp = fopen($session_file, "w")) {
3232
$return = fwrite($fp, $session_data);
3333
fclose($fp);
34-
return $return;
34+
return (bool)$return;
3535
}
3636
return false;
3737
}
@@ -40,7 +40,8 @@ function destroy($id) {
4040
global $session_save_path, $name;
4141
echo "Destroy [${session_save_path},${id}]\n";
4242
$session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id;
43-
return unlink($session_file);
43+
unlink($session_file);
44+
return true;
4445
}
4546

4647
function gc($maxlifetime) {

ext/session/tests/session_module_name_variation3.phpt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ function open($save_path, $session_name) {
2121
throw new Exception("Stop...!");
2222
}
2323

24-
function close() { }
25-
function read($id) { }
26-
function write($id, $session_data) { }
27-
function destroy($id) { }
28-
function gc($maxlifetime) { }
24+
function close() { return true; }
25+
function read($id) { return ''; }
26+
function write($id, $session_data) { return true; }
27+
function destroy($id) { return true; }
28+
function gc($maxlifetime) { return true; }
2929

3030
var_dump(session_module_name("files"));
3131
session_set_save_handler("open", "close", "read", "write", "destroy", "gc");
@@ -41,9 +41,11 @@ ob_end_flush();
4141
string(%d) "%s"
4242
string(4) "user"
4343

44-
Fatal error: Uncaught exception 'Exception' with message 'Stop...!' in %s:%d
44+
Warning: Uncaught exception 'Exception' with message 'Stop...!' in %s:%d
4545
Stack trace:
4646
#0 [internal function]: open('', 'PHPSESSID')
4747
#1 %s(%d): session_start()
4848
#2 {main}
4949
thrown in %s on line %d
50+
51+
Fatal error: session_start(): Failed to initialize storage module: %s in %s/session_module_name_variation3.php on line %d

ext/session/tests/session_set_save_handler_class_002.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ class MySession2 extends SessionHandler {
3838
}
3939

4040
public function write($id, $data) {
41-
return file_put_contents($this->path . $id, $data);
41+
return (bool)file_put_contents($this->path . $id, $data);
4242
}
4343

4444
public function destroy($id) {
4545
@unlink($this->path . $id);
46+
return true;
4647
}
4748

4849
public function gc($maxlifetime) {

ext/session/tests/session_set_save_handler_class_005.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ array(0) {
5252

5353
Warning: SessionHandler::write(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d
5454

55+
Warning: session_write_close(): Failed to write session data %s in %ssession_set_save_handler_class_005.php on line %d
56+
5557
Warning: SessionHandler::close(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d

ext/session/tests/session_set_save_handler_class_012.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ class MySession extends SessionHandler {
2424
public function open($path, $name) {
2525
++$this->i;
2626
echo 'Open ', session_id(), "\n";
27-
return parent::open();
27+
// This test was written for broken return value handling
28+
// Mimmick what was actually being tested by returning true here
29+
return (null === parent::open());
2830
}
2931
public function read($key) {
3032
++$this->i;
@@ -57,4 +59,6 @@ array(0) {
5759

5860
Warning: Unknown: Parent session handler is not open in Unknown on line 0
5961

62+
Warning: Unknown: Failed to write session data %s in %s on line %d
63+
6064
Warning: Unknown: Parent session handler is not open in Unknown on line 0

ext/session/tests/session_set_save_handler_class_016.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MySession2 extends SessionHandler {
3838
}
3939

4040
public function write($id, $data) {
41-
return file_put_contents($this->path . $id, $data);
41+
return (bool)file_put_contents($this->path . $id, $data);
4242
}
4343

4444
public function destroy($id) {

ext/session/tests/session_set_save_handler_class_017.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MySession2 extends SessionHandler {
3838
}
3939

4040
public function write($id, $data) {
41-
return file_put_contents($this->path . $id, $data);
41+
return (bool)file_put_contents($this->path . $id, $data);
4242
}
4343

4444
public function destroy($id) {

ext/session/tests/session_set_save_handler_error3.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ ob_end_flush();
3434
--EXPECTF--
3535
*** Testing session_set_save_handler() : error functionality ***
3636

37-
Fatal error: Uncaught exception 'Exception' with message 'Do something bad..!' in %s:%d
37+
Warning: Uncaught exception 'Exception' with message 'Do something bad..!' in %s:%d
3838
Stack trace:
3939
#0 [internal function]: open('', 'PHPSESSID')
4040
#1 %s(%d): session_start()
4141
#2 {main}
4242
thrown in %s on line %d
43+
44+
Fatal error: session_start(): Failed to initialize storage module: %s in %ssession_set_save_handler_error3.php on line %d

ext/session/tests/session_set_save_handler_error4.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ob_start();
1515

1616
echo "*** Testing session_set_save_handler() : error functionality ***\n";
1717

18-
function callback() { }
18+
function callback() { return true; }
1919

2020
session_set_save_handler("callback", "callback", "callback", "callback", "callback", "callback");
2121
session_set_save_handler("callback", "echo", "callback", "callback", "callback", "callback");

ext/session/tests/session_set_save_handler_iface_001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MySession2 implements SessionHandlerInterface {
3838
}
3939

4040
public function write($id, $data) {
41-
return file_put_contents($this->path . $id, $data);
41+
return (bool)file_put_contents($this->path . $id, $data);
4242
}
4343

4444
public function destroy($id) {

ext/session/tests/session_set_save_handler_variation4.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ echo "*** Testing session_set_save_handler() : variation ***\n";
2424
function noisy_gc($maxlifetime) {
2525
echo("GC [".$maxlifetime."]\n");
2626
gc($maxlifetime);
27+
return true;
2728
}
2829

2930
require_once "save_handler.inc";

main/php_content_types.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,6 @@ SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
4242
/* no post handler registered, so we just swallow the data */
4343
sapi_read_standard_form_data(TSRMLS_C);
4444
}
45-
46-
if (populate_raw_post_data(TSRMLS_C)) {
47-
size_t length;
48-
char *data = NULL;
49-
50-
php_stream_rewind(SG(request_info).request_body);
51-
length = php_stream_copy_to_mem(SG(request_info).request_body, &data, PHP_STREAM_COPY_ALL, 0);
52-
php_stream_rewind(SG(request_info).request_body);
53-
54-
if (length > INT_MAX) {
55-
sapi_module.sapi_error(E_WARNING,
56-
"HTTP_RAW_POST_DATA truncated from %lu to %d bytes",
57-
(unsigned long) length, INT_MAX);
58-
length = INT_MAX;
59-
}
60-
SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, length);
61-
62-
sapi_module.sapi_error(E_DEPRECATED,
63-
"Automatically populating $HTTP_RAW_POST_DATA is deprecated and "
64-
"will be removed in a future version. To avoid this warning set "
65-
"'always_populate_raw_post_data' to '-1' in php.ini and use the "
66-
"php://input stream instead.");
67-
}
6845
}
6946
}
7047
/* }}} */

0 commit comments

Comments
 (0)