Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate disabling use_only_cookies #13578

Merged
merged 13 commits into from
Aug 24, 2024

Conversation

kamil-tekiela
Copy link
Member

No description provided.

@kamil-tekiela kamil-tekiela force-pushed the Deprecate-GET/SET-session-SID branch 3 times, most recently from 1d8cbc2 to c051248 Compare April 5, 2024 19:30
@kamil-tekiela kamil-tekiela force-pushed the Deprecate-GET/SET-session-SID branch 2 times, most recently from 30cff65 to 26db3b0 Compare May 3, 2024 13:22
@kamil-tekiela kamil-tekiela marked this pull request as ready for review May 3, 2024 13:24
@kamil-tekiela
Copy link
Member Author

I don't know why the Windows tests are failing. Can someone assist?

@nielsdos
Copy link
Member

nielsdos commented May 3, 2024

I don't know why the Windows tests are failing. Can someone assist?

Add an INI section to the tests where you set error_reporting=-1, the default Windows configuration used in CI doesn't set E_DEPRECATED by default in its error_reporting. That should make them pass.
In any case, setting the error_reporting explicitly in the INI section also avoids false failures when people run the tests with their own php.ini.

@nielsdos
Copy link
Member

nielsdos commented May 3, 2024

Looks like it'll still fail because they come from startup, i.e. before it had the chance of updating the INI options. Probably the CI runner configuration should then be adjusted instead...

@kamil-tekiela
Copy link
Member Author

Where do I change the CI configuration?

@nielsdos
Copy link
Member

nielsdos commented May 3, 2024

If I had to take a guess, the error reporting is set too low in the php.ini file used for the Windows CI, but I'm not sure without digging into it where that's set. @iluuu1994 did set up the CI so he might know.

@iluuu1994
Copy link
Member

Windows apparently only does release builds, which we should probably change. You could try changing this line:

--disable-debug-pack ^

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good just some minor comments that need addressing.

@kamil-tekiela
Copy link
Member Author

Windows apparently only does release builds, which we should probably change. You could try changing this line:

--disable-debug-pack ^

This did not help. See the last commit.

@iluuu1994
Copy link
Member

Ok, I don't know then. error_reporting is handled by run-tests.php, so there's shouldn't be a need to set it again.

@TimWolla TimWolla removed their request for review May 5, 2024 17:18
@jorgsowa
Copy link
Contributor

jorgsowa commented Jul 6, 2024

RFC for reference: https://wiki.php.net/rfc/deprecate-get-post-sessions

@kocsismate
Copy link
Member

@cmb69 I cc you in the hope that you how to fix the Windows failure :)

@cmb69
Copy link
Member

cmb69 commented Jul 26, 2024

When running nmake test TESTS=ext\session\tests\rfc1867_inter.phpt, the relevant system_with_timeout() of run-tests.php returns:

Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is deprecated in Unknown on line 0
X-Powered-By: PHP/8.4.0-dev
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-type: text/html; charset=UTF-8

string(13) "rfc1867-inter"
array(2) {
  ["file1"]=>
  array(6) {
<rest omitted for brevity>

Now I wonder why that startup error is output at the end of the test on other platforms. What am I missing?

@iluuu1994, --disable-debug-pack will result in an executable without any associated debug info (.pdb). You can use --disable-debug-pack --enable-debug to have a full fledged debug build. Running such builds in CI might make sense, especially if the envvar PHP_WIN32_DEBUG_HEAP would be set when running the tests, since this gives some basic heap checking. ASAN would be much better, though.

@nielsdos
Copy link
Member

@cmb69

Now I wonder why that startup error is output at the end of the test on other platforms. What am I missing?

I think I figured it out. It's because startup errors go though php_log_err_with_severity which will call this function on CLI:

php-src/sapi/cli/php_cli.c

Lines 350 to 356 in a7bd911

static void sapi_cli_log_message(const char *message, int syslog_type_int) /* {{{ */
{
fprintf(stderr, "%s\n", message);
#ifdef PHP_WIN32
fflush(stderr);
#endif
}

Notice that the buffer is flushed on Windows but not on other platforms. But the normal test output is not sent through stderr, it is sent to stdout. So that's why we end up with different ordering: stderr is already flushed on Windows but not on other platforms so on Windows it appears before stdout and on other platforms it appears after.

@cmb69
Copy link
Member

cmb69 commented Jul 27, 2024

@nielsdos, good thinking, but apparently sapi_cli_log_message() isn't even called, since the test is supposed to be run via php-cgi. Still a stdout vs. stderr issue may be the problem, although stderr is unbuffered on POSIX systems, if I remember correctly (and as such the special case on Windows would be supposed to trigger roughly the same behavior).

Anyway, since debugging PHPTs is harder than simple PHP files (although debugging PHPTs is supported by the php-sdk), I came up with the following simplification of ext/session/tests/bug36459.phpt: x64\Debug\php-cgi.exe -n -d html_errors=0 -d session.use_trans_sid=1 -d session.use_cookies=0 -d session.use_only_cookies=0 -d session.name=sid -f ext\session\tests\bug36459.php, where bug36459.php contains just the --FILE-- section of the PHPT. On Windows this outputs:


Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is deprecated in Unknown on line 0

Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0

Warning: session_start(): Session cache limiter cannot be sent after headers have already been sent in C:\php-sdk\phpdev\vs17\x64\php-src\ext\session\tests\bug36459.php on line 4
<html>
  <head>
    <title>Bug #36459 Incorrect adding PHPSESSID to links, which contains \r\n</title>
  </head>
  <body>
    <p>See source html code</p>
    <a href="/b2w/www/ru/adm/pages/?action=prev&rec_id=8&pid=2&sid=eb20fcb52d5932c00460b5d72fcbd460"
       style="font: normal 11pt Times New Roman">incorrect link</a><br />
    <br />
    <a href="/b2w/www/ru/adm/pages/?action=prev&rec_id=8&pid=2&sid=eb20fcb52d5932c00460b5d72fcbd460" style="font: normal 11pt Times New Roman">correct link</a>
  </body>
</html>

I get the same output with 2>&1 appended to the command (which is what run-tests.php does) on Windows.

I'm now going to build this PR on WSL, to be able to compare what is going on. Haven't done WSL builds for quite a while – might be fun. :)

@nielsdos
Copy link
Member

Right, the cgi one is here

static void sapi_cgi_log_message(const char *message, int syslog_type_int)

And it doesn't explicitly flush on Windows.

@kamil-tekiela kamil-tekiela force-pushed the Deprecate-GET/SET-session-SID branch from 0e99d4f to ffade41 Compare August 21, 2024 10:23
@kamil-tekiela kamil-tekiela force-pushed the Deprecate-GET/SET-session-SID branch from ffade41 to ad35e68 Compare August 21, 2024 10:26
bool *p = (bool *) ZEND_INI_GET_ADDR();
*p = zend_ini_parse_bool(new_value);
if (!*p) {
php_error_docref(NULL, E_DEPRECATED, "Disabling session.use_only_cookies INI setting is deprecated");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
php_error_docref(NULL, E_DEPRECATED, "Disabling session.use_only_cookies INI setting is deprecated");
php_error_docref("session.configuration", E_DEPRECATED, "Disabling session.use_only_cookies INI setting is deprecated");

Same for the other two below. See #15505.

@kamil-tekiela
Copy link
Member Author

Now back to the issue at hand. To enforce the same behavior on all platforms, we could simply add display_startup_errors=0 at the beginning of the --INI-- sections of the affected tests. Of course, the deprecation warning at the end of the --EXPECT-- sections would need to be removed to let the tests pass. To also check for the deprecation warning, the --EXPECTHEADERS-- hack I suggested above for Windows would not work on POSIX platforms, since the lines are terminated by LF there, and as such would not be detected as headers by run-tests.php. So either we could introduce something like --EXPECTSTARTUPERRORS--, or just ignore the startup errors in these tests, since they are already tested by other tests. I suggest the latter to not have to spend even more time on this issue.

Is what I did in ad35e68 what you had in mind but for all tests in this PR?

@cmb69
Copy link
Member

cmb69 commented Aug 21, 2024

Is what I did in ad35e68 what you had in mind but for all tests in this PR?

Right; well, for all tests which requires it (likely all rfc1867_*.phpts).

@kamil-tekiela
Copy link
Member Author

I don't think I can do that with ext/session/tests/rfc1867_sid_invalid.phpt. If I disable startup errors then the whole test is borked.

@cmb69
Copy link
Member

cmb69 commented Aug 21, 2024

I don't think I can do that with ext/session/tests/rfc1867_sid_invalid.phpt. If I disable startup errors then the whole test is borked.

Ah, interesting. I'll have a closer look at this one soon.

@cmb69
Copy link
Member

cmb69 commented Aug 21, 2024

Ah, interesting. I'll have a closer look at this one soon.

That test uses output buffering and manual session start to work around the startup error issue. But for this test, I don't see any good reason why we would need session.use_only_cookies=0, so I suggest to remove it.

@kamil-tekiela kamil-tekiela force-pushed the Deprecate-GET/SET-session-SID branch from c32805d to 5ba6f11 Compare August 21, 2024 17:58
Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the two nits, this looks good to me. Thanks for your patience! :)

But let's wait what others have to say (still almost a week till PHP 8.4.0beta4).

@cmb69 cmb69 requested a review from Girgias August 21, 2024 19:16
Co-authored-by: Christoph M. Becker <[email protected]>
@cmb69
Copy link
Member

cmb69 commented Aug 24, 2024

Note that the respective RFC has been accepted unanimously (29:0 votes); it would be a shame if it wouldn't make it into PHP 8.4.

@kamil-tekiela
Copy link
Member Author

@NattyNarwhal Can we merge it as is?

Copy link
Member

@NattyNarwhal NattyNarwhal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to merge to me

@kamil-tekiela kamil-tekiela merged commit c5bce0d into php:master Aug 24, 2024
10 checks passed
@kamil-tekiela kamil-tekiela deleted the Deprecate-GET/SET-session-SID branch August 24, 2024 15:45
cmb69 added a commit to cmb69/php-src that referenced this pull request Sep 12, 2024
This RFC[1] has already been implemented via its respective PR[2], so
we add this information to UPGRADING.

[1] <https://wiki.php.net/rfc/deprecate-get-post-sessions>
[2] <php#13578>
cmb69 added a commit to cmb69/php-src that referenced this pull request Sep 12, 2024
This RFC[1] has already been implemented via its respective PR[2], so
we add this information to UPGRADING.

[1] <https://wiki.php.net/rfc/deprecate-get-post-sessions>
[2] <php#13578>
Girgias pushed a commit that referenced this pull request Sep 13, 2024
This RFC[1] has already been implemented via its respective PR[2], so
we add this information to UPGRADING.

[1] <https://wiki.php.net/rfc/deprecate-get-post-sessions>
[2] <#13578>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants