The implementation of destroy between Phalcon\Session\Adapter and Phalcon\Session\Adapter\* when destroying is totally different. For example:
Phalcon\Session\Adapter:
public function destroy ( boolean removeData = false ) -> boolean
Phalcon\Session\Adapter\Redis:
public function destroy ( string sessionId = null ) -> boolean
public function destroy ( string $session_id ) : boolean
I propose to refactor:
Phalcon\Session\AdapterInterfacePhalcon\Session\AdapterPhalcon\Session\Adapter\FilesPhalcon\Session\Adapter\LibmemcachedPhalcon\Session\Adapter\MemcachePhalcon\Session\Adapter\Redisfor full compliance with PHP's SessionHandlerInterface.
I believe that Phalcon\Session\AdapterInterface should inherit SessionHandlerInterface.
Obviously these are backward incompatible changes and they should be done in 4.x branch.
Refs:
Cc: @phalcon/core-team, @phalcon/framework-team
+1ed - I believe consistency is key, any change that will promote that has my vote.
I use Aerospike, worth checking if that needs a refactor :)
Absolutely yes
We need to be consistent in all interfaces, all implementations of adapters. This has to be refactored and introduced in 4.x version.
public function destroy (string sessionId = null) -> bool
It will :
null it will destroy the current sessionId sessionIdIf successful returns true. If not false or if the sessionId was not found false again.
Also no underscored variables in any interfaces or in general :(
You mean in methods body? @linxlad yea i agree. But underscored properties should remain - simply to give people option to add their own property for example like $name and we should use property _name imho.
@linxlad This is different issue, not related to the session interface
@sergeyklay I know, I just turned into an annoying PSR-2 warrior lol
馃憤
I'm not understanding why the new standard interface doesn't allow a default argument for the session id: public function destroy ( string $session_id ) : bool.
It seems like that the way the signature is working it should be a static method, but its not. I'm not familiar with most of the adapter backends but it seems like the interface is so overly general that it will be annoying in the most simple cases.
@dschissler What do you mean? Could you please explain a bit more?
So in Phalcon\Session\Adapter\Files the object will already know what the session id, probably as a protected variable in the class. However then to tear down the session you need to specify the session id in the destroy method. Doesn't that seem weird?
Currently this is the sensible behavior:
<?php
var_dump(
$session->destroy()
);
var_dump(
$session->destroy(true)
);
With the new interface it seems that it would need to be like this:
$session->destroy($session->getId());
Has anyone thought about this? As far as I can see SessionHandlerInterface seems like a faulty standard.
@dschissler Could you elaborate on that. Why?
This seems strange.
$session->destroy($session->getId());
Yes, you may need remove not current session, that is owned by some user
How about we add API sugar?:
public function destroyCurrent()
{
$this->destroy($this->getId());
}
@sergeyklay How does Phalcon\Session\Adapter\Redis work with SessionHandlerInterface::open? I don't understand how string $save_path is relevant to service based sessions.
This sugar is not compatible with the interface
Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues
Addressed in https://github.com/phalcon/cphalcon/pull/13673
Most helpful comment
+1ed - I believe consistency is key, any change that will promote that has my vote.