-
Notifications
You must be signed in to change notification settings - Fork 8.1k
session: fix create_sid()/validateId() check depending on interface order #23329
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
Open
lazerg
wants to merge
4
commits into
php:master
Choose a base branch
from
lazerg:fix/gh-23328-session-iface-order
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+48
−2
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f138ce2
session: fix create_sid()/validateId() check depending on interface o…
lazerg 698f2f4
session: check the interface methods instead of the interface names
lazerg a783cff
session: check the interface entries instead of the method names
lazerg 0c963e4
session: use the session interfaces for the missing method check
lazerg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please move this test into the user_session_submodule subdirectory
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to ext/session/tests/user_session_module/gh23328.phpt in a783cff. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| --TEST-- | ||
| GH-23328: SessionHandlerInterface create_sid()/validateId() warning depends on interface order | ||
| --EXTENSIONS-- | ||
| session | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| abstract class HandlerFirst implements SessionHandlerInterface, SessionIdInterface, SessionUpdateTimestampHandlerInterface {} | ||
| abstract class HandlerLast implements SessionIdInterface, SessionUpdateTimestampHandlerInterface, SessionHandlerInterface {} | ||
|
|
||
| interface CombinedInterface extends SessionIdInterface, SessionUpdateTimestampHandlerInterface {} | ||
| abstract class CombinedFirst implements CombinedInterface, SessionHandlerInterface {} | ||
| abstract class CombinedLast implements SessionHandlerInterface, CombinedInterface {} | ||
|
|
||
| interface NestedInterface extends CombinedInterface {} | ||
| abstract class NestedLast implements SessionHandlerInterface, NestedInterface {} | ||
|
|
||
| abstract class MissingBoth implements SessionHandlerInterface {} | ||
| abstract class MissingValidateId implements SessionHandlerInterface, SessionIdInterface {} | ||
| abstract class MissingCreateSid implements SessionHandlerInterface, SessionUpdateTimestampHandlerInterface {} | ||
|
|
||
| echo "Done\n"; | ||
| ?> | ||
| --EXPECTF-- | ||
| Warning: Class MissingBoth implementing SessionHandlerInterface is missing the create_sid() method which will be required in PHP 9.0 in %s on line %d | ||
|
|
||
| Warning: Class MissingBoth implementing SessionHandlerInterface is missing the validateId() method which will be required in PHP 9.0 in %s on line %d | ||
|
|
||
| Warning: Class MissingValidateId implementing SessionHandlerInterface is missing the validateId() method which will be required in PHP 9.0 in %s on line %d | ||
|
|
||
| Warning: Class MissingCreateSid implementing SessionHandlerInterface is missing the create_sid() method which will be required in PHP 9.0 in %s on line %d | ||
| Done |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather we iterate on
ce->interfaces[i]and check that the CE isSessionIdInterfaceorSessionUpdateTimestampHandlerInterfacerather than name checking.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a783cff. It iterates
ce->interfaces[i]and usesinstanceof_function()per entry, so an interface that extendsSessionIdInterfaceorSessionUpdateTimestampHandlerInterfaceis still recognised before it has been flattened into the list.One case this drops, which the name check covered: a class that gets the methods from an unrelated interface.
implements OwnMethods, SessionHandlerInterfacestays quiet,implements SessionHandlerInterface, OwnMethodsnow warns again.session_set_save_handler()accepts the methods there regardless of the interface, so the two rules differ. Tell me if you want that case back and I will restore the method lookup.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the objective is to move the methods from those 2 interfaces to the "base" interface having another interface declare such a method is not something we should be supporting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, that keeps the check aligned with the migration path, so I have left the behaviour as you asked.
Correction on my earlier reply though: a783cff only carried the test move. I botched the staging and the session.c change never made it into that commit. It is in 0c963e4 now, so the diff you reviewed was still the old name lookup. Sorry for the noise.