Commit graph

1800 commits

Author SHA1 Message Date
Niels Dossche
dcd3ef33b3
Realign entries 2025-08-15 08:41:56 +02:00
Niels Dossche
1bba07ecc0
partitioned option for setcookie/setrawcookie and sessions
RFC: https://wiki.php.net/rfc/CHIPS

Closes GH-12646.
Closes GH-12652.
2025-08-15 08:41:24 +02:00
Tim Düsterhus
3d9d68e1ca
zend_compile: Deprecate backticks as an alias for shell_exec() (#19443)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_backticks_as_an_alias_for_shell_exec
2025-08-12 12:02:13 +02:00
Calvin Buckley
18dee43e02
Add SAPI_HEADER_DELETE_PREFIX, make ext/session use it (#18678)
* Add SAPI_HEADER_DELETE_PREFIX operation

The session ext currently munges into the linked list of headers
itself, because the delete header API is given the key for headers to
delete. The session ext wants to use a prefix past the colon separator,
for i.e. "Set-Cookie: PHPSESSID=", to eliminate only the specific cookie
rather than all cookies.

This changes the SAPI code to add a new header op to take a prefix
instead. Call sites are yet unchanged. Also fix some whitespace.

* Simplify cookie setting code in ext/session

Use the modern SAPI header ops API, including the remove prefix op we
just added.

* [ci skip] Remove redundant and unnecessary comment

The purpose of this is clear, and after refactoring, the special case is
no longer there, so it has no value.

* Un-deprecate simple add/replace header API, use it

Suggestion from Jakub.

* Restore the optimization removing session cookies had

I don't think this needs to be special cased with the parameter.

* Move setting header length to caller

Suggestion from Jakub.

* [ci skip] adjust tab count

It may be better to use spaces in here instead.

* Use session_cookie_len rather than calling strlen
2025-07-31 19:52:04 -03:00
David CARLIER
bd886d21e7
Fix GH-19197: session build fails on system with memcpy as macro. (#19198)
Thus ZEND_STRL macro does not expand as expected so going back
to not using it like lower branches.
2025-07-21 10:19:29 +01:00
DanielEScherzer
d8577d9bfb
Deprecate returning non-string values from a user output handler (#18932)
https://wiki.php.net/rfc/deprecations_php_8_4
2025-07-07 14:31:13 -07:00
Gina Peter Banyard
36358bad84 ext/session: get rid of sname_len field
This is unnecessary now that the session name is a zend_string
2025-07-06 17:21:00 +01:00
Gina Peter Banyard
c3dac0f8b6 ext/session: Minor code cleanups 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
db01dbc4ee ext/session: Initialize variable with default value
To make it easier for IDEs to understand what is going on
2025-07-06 17:21:00 +01:00
Gina Peter Banyard
766ccc2210 ext/session: Use zend_string for some session globals 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
f5166b3bb6 ext/session: convert global session_name to zstr 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
b83484df97 ext/session: Use is_numeric_str helper 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
ac3807ee8d ext/session: Use ZEND_STRL() 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
c529e2f85b ext/session: Use smart_str_append when possible 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
eaee504c4d ext/session: Concert save_path to zstr 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
9c68853023 ext/session: copy zstr instead of initializing a new one 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
43fe9fd171 ext/session: convert some globals to zend_string
This prevents some strlen computations
2025-07-06 17:21:00 +01:00
Gina Peter Banyard
7f80d4dc7d ext/session: Remove bool type coercions in tests 2025-06-23 14:57:13 +02:00
Jessica Smith
042a975238
ext/session: Fix GH-18634 (#18653)
Show warning when saving session if a pipe character is used in one of the $_SESSION keys

Fixes #18634
2025-05-26 11:17:25 +01:00
Jorg Adam Sowa
3f3ac4de25
[skip ci] Remove wrappers comments in session ext (#18017) 2025-03-13 12:14:31 +00:00
Gina Peter Banyard
3930b6f378
Merge branch 'PHP-8.4'
* PHP-8.4:
  ext/session: Fix GH-17541 (ext/session NULL pointer dereferencement during ID reset)
2025-01-24 14:10:12 +00:00
Gina Peter Banyard
d35904adf2
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  ext/session: Fix GH-17541 (ext/session NULL pointer dereferencement during ID reset)
2025-01-24 14:10:00 +00:00
Gina Peter Banyard
a85666c17b
ext/session: Fix GH-17541 (ext/session NULL pointer dereferencement during ID reset)
Closes GH-17541
Closes GH-17546
2025-01-24 14:04:58 +00:00
Niels Dossche
6d4598eba8
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix type confusion with session SID constant
2025-01-23 19:03:45 +01:00
Niels Dossche
b448d540c2
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix type confusion with session SID constant
2025-01-23 19:03:35 +01:00
Niels Dossche
2a2cc2ccce
Fix type confusion with session SID constant
Closes GH-17548.
2025-01-23 19:03:04 +01:00
David Carlier
a091e52316
ext/session: session_start() options arguments type checks.
close GH-17388
2025-01-07 23:52:39 +00:00
Gina Peter Banyard
6ab38b52d3 ext/standard: Refactor tick and shutdown functions
Remove usage of FCI and store the parameters and count of it directly on the relevant structures
This reduces the size of the structs by ~50
2024-12-29 23:41:06 +00:00
Niels Dossche
173bdb2c06
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16590: UAF in session_encode()
  Fix various memory leaks on error conditions in openssl_x509_parse()
2024-11-04 20:05:42 +01:00
Niels Dossche
cc39bc21e3
Fix GH-16590: UAF in session_encode()
The `PS_ENCODE_LOOP` does not protect the session hash table that it
iterates over. Change it by temporarily creating a copy.

Closes GH-16640.
2024-11-04 20:05:32 +01:00
Calvin Buckley
84d6cb8cf0
Unify headers already sent/session already started error handler (#16451)
* Unify headers already sent errors

Now whenever we need to check where headers were already sent in
ext/session, we call a single location that prints where, keeping it
consistent output wise.

* Unify session aready started errors

Similar to the one for headers.

* Also change session active checks too

This usually go hand in hand with the headers already sent checks, but
is in a separate commit because of the amount of tests it changes.
2024-10-17 13:13:56 -03:00
Calvin Buckley
edf351ce6d
Mention where headers were already sent if session_start fails (#16378)
We had previously improved where sessions were already started, and
where headers were already sent when setting headers, but not where a
header has been sent if we try to set the header cookie.

Fixes GH-16372
2024-10-14 21:13:43 -03:00
David Carlier
4d008e300b
Merge branch 'PHP-8.3' into PHP-8.4 2024-10-13 14:19:45 +01:00
David Carlier
f31232e218
Merge branch 'PHP-8.2' into PHP-8.3 2024-10-13 14:19:33 +01:00
David Carlier
84a8fea251
Fix GH-16290: session cookie_lifetime ini value overflow.
close GH-16295
2024-10-13 14:19:18 +01:00
Niels Dossche
45f7f87b75
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16385: Unexpected null returned by session_set_cookie_params
2024-10-12 13:09:24 +02:00
Niels Dossche
a1f7ce5617
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16385: Unexpected null returned by session_set_cookie_params
2024-10-12 13:09:06 +02:00
Niels Dossche
7cdd1302c3
Fix GH-16385: Unexpected null returned by session_set_cookie_params
Two issues:
1) The check happened before ZPP checks
2) The `return;` statement caused NULL to be returned while this
   function can only return booleans. An exception seems not acceptable
   in stable versions, but a warning may do.

Closes GH-16386.
2024-10-12 13:08:37 +02:00
Christoph M. Becker
217ea732fc
Use php_error_docref() instead of zend_error() in session.c (GH-15505)
Using `php_error_docref()` is preferable since it outputs additional
details (which function has been called and whether it is a startup or
shutdown error), uses HTML markup, and also provides a link to the
documentation, if configured.

Since these deprecation warnings have been introduced recently[1][2],
i.e. for PHP 8.4, there are no BC concerns.

[1] <e8ff7c70f9>
[2] <b36eac94d2>

Co-authored-by: Máté Kocsis <kocsismate90@gmail.com>
2024-09-04 16:00:28 +02:00
Kamil Tekiela
c5bce0d8a2
Deprecate disabling use_only_cookies (#13578) 2024-08-24 16:33:45 +02:00
Máté Kocsis
8d12f666ae
Fix registration of internal readonly child classes (#15459)
Currently, internal classes are registered with the following code:

INIT_CLASS_ENTRY(ce, "InternalClass", class_InternalClass_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ...;

This has worked well so far, except if InternalClass is readonly. It is because some inheritance checks are run by zend_register_internal_class_ex before ZEND_ACC_READONLY_CLASS is added to ce_flags.

The issue is fixed by adding a zend_register_internal_class_with_flags() zend API function that stubs can use from now on. This function makes sure to add the flags before running any checks. Since the new API is not available in lower PHP versions, gen_stub.php has to keep support for the existing API for PHP 8.3 and below.
2024-08-24 12:36:54 +02:00
Jorg Adam Sowa
ff69f334f1
ext/session: Warn when providing invalid values for session.gc_probability and session.gc_divisor 2024-08-22 01:29:40 +01:00
Christoph M. Becker
3ed5eee5d3
[skip ci] Fix bug71162.phpt xfail message (GH-15506)
The test failure is unlikely to be caused by `SessionHandlerInterface`
not being available.
2024-08-20 14:48:52 +02:00
Peter Kokot
80d784610a
Add date extension to dependencies (#15475)
This is at this point only meta-data information for extensions to
depend also on date extension. This is a configure phase dependency for
consistency.
2024-08-18 16:47:57 +02:00
Jorg Adam Sowa
21fa5e15f9
ext/session: session_create_id() now throws a ValueError for large prefix (#15338) 2024-08-15 11:10:18 +01:00
Jorg Adam Sowa
c4eccf33e9
ext/session: session.save_handler - add tests fortwo uncovered cases (#15337) 2024-08-11 15:39:56 +01:00
Jorg Adam Sowa
6bf7b7220d
ValueError on null byte in session_name() (#15286) 2024-08-11 13:26:54 +01:00
Peter Kokot
97eb89afd6
Autotools: Improve --with-mm configure option check (#15212)
The mm check code block needs to done only when session is enabled to
prevent redundant mm library linkage in edge case mistakes like:

    ./configure --disable-session --with-mm

CS is synced with AC_* macros. The 'm4_text_wrap' macro joins the given
text with single space characters and limits it to 79 characters width.

Co-authored-by: Gina Peter Banyard <girgias@php.net>
2024-08-04 21:16:15 +02:00
Tim Düsterhus
e8ff7c70f9
session: Deprecate session.sid_length and session.sid_bits_per_character (#15213)
RFC: https://wiki.php.net/rfc/deprecations_php_8_4
2024-08-04 18:25:31 +02:00
Peter Kokot
16d9bd0aae
Sync AC_DEFINE help texts (#15207) 2024-08-03 09:47:39 +02:00