Skip to content

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Oct 19, 2022

I started this 3 weeks ago and this is what led me through the whole FCI refactoring bit, but it's probably best to start having part of this already reviewed and merged.

The commits are self contained and should be reviewed independently (and also not squashed).

I've got more ideas for changes lined up, but those will require an RFC.

@Girgias Girgias requested a review from cmb69 October 19, 2022 15:29
public function open($path, $name): bool {
++$this->i;
echo 'Open ', session_id(), "\n";
echo 'Open:', session_id(), "\n";
Copy link
Member

Choose a reason for hiding this comment

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

Not sure whether we really want to add these colons; this doesn't appear to clarify the tests, but might cause merge conflicts in the future. If we'd change to var_dump(session_id(), that might make more sense, although it'd increase the possibility of merge conflicts.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was to get rid of the whitespace sensitivity for the tests, as my IDE loves removing the trailing whitespaces...

class Kill {
function __construct() {
global $HTTP_SESSION_VARS;
$_SESSION = [];
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

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.

Thank you! This looks mostly good to me; I've left some comments.

?>
--CLEAN--
<?php
$path = __DIR__ . '/session_module_name_variation4';
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

Comment on lines 1 to 17
<?php
$save_path = ini_get("session.save_path");
if ($save_path) {
if (!file_exists($save_path)) {
die("skip Session save_path doesn't exist");
}

if ($save_path && !@is_writable($save_path)) {
if (($p = strpos($save_path, ';')) !== false) {
$save_path = substr($save_path, ++$p);
}
if (!@is_writable($save_path)) {
die("skip session.save_path $save_path is not writable\n");
}
}
}
?>
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this an exact duplicate of ext/session/tests/skipif.inc? If so, can't we use that file in the user_session_module tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is a duplicate, but I thought I could get rid of the skipif section all together and not rely on the file system but that doesn't seem likely so the easy fix was to just copy the file again so that I didn't need to amend all paths. But I can try again to get rid or point to the root SKIPIF file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out it's completely useless, even for the normal session tests, as it's meant to check if the INI save path exists and is writeable, but this is never set in our tests.


/* add shutdown function, removing the old one if it exists */
if (!register_user_shutdown_function("session_shutdown", sizeof("session_shutdown") - 1, &shutdown_function_entry)) {
if (!register_user_shutdown_function("session_shutdown", strlen("session_shutdown"), &shutdown_function_entry)) {
Copy link
Member

Choose a reason for hiding this comment

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

There is no need to change strlen() to sizeof; any somewhat reasonable compiler is supposed to optimize strlen for literals.

Copy link
Member Author

Choose a reason for hiding this comment

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

I went the other way, from sizeof to strlen

Copy link
Member

Choose a reason for hiding this comment

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

D'oh! Makes sense, but maybe we should document that preference in our coding style guidelines.

Comment on lines +84 to +90
Validate ID
Read
array(1) {
["OLD_ID"]=>
string(28) "a:1:{s:3:"foo";s:5:"hello";}"
}
Write
Close
Copy link
Member Author

Choose a reason for hiding this comment

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

This looks like a long standing bug to not clear the optional handlers. As this doesn't happen with the Object version.

@Girgias Girgias force-pushed the ext-session-refactoring-1 branch 3 times, most recently from cc18ef3 to 3397200 Compare October 21, 2022 16:27
@Girgias Girgias force-pushed the ext-session-refactoring-1 branch from 3397200 to 74b11b3 Compare October 22, 2022 10:31
@Girgias Girgias merged commit 8e9fa2b into php:master Oct 22, 2022
@Girgias Girgias deleted the ext-session-refactoring-1 branch October 22, 2022 11:47
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.

2 participants