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

Fixed incompatible interface deprecations in DB Session Adapter #3497

Merged
merged 3 commits into from
Sep 7, 2023

Conversation

elidrissidev
Copy link
Member

@elidrissidev elidrissidev commented Sep 6, 2023

Description (*)

Small fix to make the methods in DB session adapter compatible with SessionHandlerInterface.

Fixed Issues (if relevant)

  1. Fixes Incompatible interface deprecations in Mage_Core_Model_Resource_Session #3496

Manual testing scenarios (*)

  1. Switch <session_save> in local.xml to db.
  2. Clean the cache and check system.log.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)
  • Add yourself to contributors list

@github-actions github-actions bot added the Component: Core Relates to Mage_Core label Sep 6, 2023
@elidrissidev elidrissidev force-pushed the fix/db-session-adapter-php8 branch from b710633 to 57ec921 Compare September 6, 2023 16:22
@elidrissidev elidrissidev force-pushed the fix/db-session-adapter-php8 branch from 57ec921 to 27bef5a Compare September 6, 2023 16:42
@elidrissidev
Copy link
Member Author

I tried adding the type hints following SessionHandlerInterface signature and only adding ReturnTypeWillChange to the methods with union types which aren't supported pre-PHP 8, but PHPStan keeps complaining 🤷‍♂️

@elidrissidev elidrissidev added the PHP 8 Related to PHP8 label Sep 6, 2023
@colinmollenhour
Copy link
Member

I didn't see your PR and made an attempt to ignore these errors here: #3498 but it seems yours actually works. 😄

What do you think about changing:

class Mage_Core_Model_Resource_Session implements Zend_Session_SaveHandler_Interface

to

class Mage_Core_Model_Resource_Session implements SessionHandlerInterface

?

@elidrissidev
Copy link
Member Author

@colinmollenhour I've switched it. Zend_Session_SaveHandler_Interface wasn't referenced anywhere anyways.

@fballiano
Copy link
Contributor

if we change the interface of a public class, shouldn't we have this PR in the next branch?

@elidrissidev
Copy link
Member Author

The interface is unused in the core and the only reference I found was commented out 15 years ago.

@fballiano
Copy link
Contributor

😂 ok then, it seems enough

some of our code is really old

@fballiano
Copy link
Contributor

on my local machine phpstan runs without errors also without the ReturnTypeWillChange now that we're using the SessionInterface, should we still keep the ReturnTypeWillChange?

@elidrissidev
Copy link
Member Author

The issue this PR was meant to be fixing is PHP deprecation errors related to incompatible types with the interface. PHPStan never complained about them in main, but I think it should fix it in next.

@fballiano
Copy link
Contributor

sure, that's why I'm running phpstan on my local machine with php8, which is the difference that triggers the error in next ;-)

(actually i've to admin I ran it with php8.2 instead of 8.1)

@elidrissidev
Copy link
Member Author

elidrissidev commented Sep 7, 2023

In next proper types could be added to this class. Here it's either you remove ReturnTypeWillChange which causes PHP deprecation messages, or you try to introduce types but PHPStan's expectations do not conform with what's in PHP documentation, it seems to expect the methods to have mixed type which is not available in PHP 7.x.

@fballiano
Copy link
Contributor

true, this version works correctly but it would have to be committed only on the next branch

@colinmollenhour
Copy link
Member

Does this patch also fix the next branch? My only goal was to get the PHPStan action passing again - if this does that then I am for it. :)
What is the difference between main and next that causes next to fail in the first place?

@fballiano
Copy link
Contributor

It should only be that next workflows run on php8.1

@elidrissidev
Copy link
Member Author

Does this patch also fix the next branch?

It should fix it.

Copy link
Member

@colinmollenhour colinmollenhour left a comment

Choose a reason for hiding this comment

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

Looks good to me. The change of which interface class is implemented should be benign.

@fballiano
Copy link
Contributor

I would have preferred the proper fix on the next branch :-\

@elidrissidev
Copy link
Member Author

@fballiano Feel free to open one for next to introducing proper types :)

@fballiano
Copy link
Contributor

done, but I think this one should be merged too, right?

@elidrissidev
Copy link
Member Author

Yeah. The PR for next should wait until this one is merged and forward-ported so you can rebase it and remove the ReturnTypeWillChange since it won't be needed there.

@fballiano fballiano changed the title Fix incompatible interface deprecations in DB Session Adapter Fixed incompatible interface deprecations in DB Session Adapter Sep 7, 2023
@fballiano
Copy link
Contributor

then I guess it's time ;-)

@fballiano fballiano merged commit 0b3d782 into OpenMage:main Sep 7, 2023
@elidrissidev elidrissidev deleted the fix/db-session-adapter-php8 branch September 7, 2023 22:27
@fballiano
Copy link
Contributor

merged, forward ported and updated #3499 ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Relates to Mage_Core PHP 8 Related to PHP8
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incompatible interface deprecations in Mage_Core_Model_Resource_Session
3 participants