Re: [RFC] session_start(), read_only, lazy_write; Take 2

From: Date: Fri, 28 Mar 2014 23:41:10 +0000
Subject: Re: [RFC] session_start(), read_only, lazy_write; Take 2
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi,

>> > Without API, manager cannot manage how it behaves. In general, submodule
>> > should
>> > avoid manager state dependency in general. It should have dedicated API
>> > for
>> > each
>> > distinct task rather than leaving it to managed by submodule. In
>> > addition,
>> > manager
>> > cannot know if save handler supports API or not. If there is API, I can
>> > display save
>> > handler capability in phpinfo() page, for example.
>> >
>> > If manager expects sub module to behave in some way, it should have
>> > explicit
>> > API
>> > for each feature. Otherwise, sub module implementation may differ module
>> > by
>> > module.
>> > Defined set of feature is better to have explicit API with modular
>> > design.
>> > It's not mandatory,
>> > but the best practice. I don't see reason not to follow the practice
>> > here.
>>
>> I agree in general, but you just gave a good reason not to follow that
>> practice - you can't know if the submodule supports it. Plus, both are
>> write operations with one of them just writing more data. I'm all for
>> best practices, but in this case there's a lot of sense not to do
>> everything by the book.
>
>
> If there is API, sub module capability can be detected.

You yourself told me that there's no way for the SessionHandler class
to know if the storage module supports PS_UPDATE_TIMESTAMP_FUNC() or
not, and that because of that we can't have
SessionHandler::updateTimestamp().

> Writing data and updating time stamp for GC is distinct feature.

For file-based sessions - it is, but for i.e. a database, there's not
much difference. write() does update the timestamp, I see no reason
why it shouldn't be able to update just the timestamp.

> I don't see good reason not to have API for it.

 - Not being able to call parent::updateTimestamp() is a good reason.
 - Having the completely unnecessary SessionUpdateTimestampInterface
is a good reason.
 - Breaking the design of current userland implementations is a good reason.
 - Not being able to have lazy_write (a performance improvement, I
remind you) by default is a good reason.

>> > Besides modular design, if write() and updateTimestamp() are merged,
>> > flag
>> > parameter
>> > for write() should be added. It breaks compatibility with current save
>> > handlers. I don't
>> > want BC that could be avoided also.
>>
>> No it shouldn't, the decision whether to write or just update the
>> timestamp is based on an internal flag, or on $session_data. No
>> additional parameters are required.
>
>
> I removed PS(id) dependency from s_read() with new patch as planned. Why
> should I introduce new dependency to s_write(), i.e. sub module, that breaks
> design?  It does not make sense.

Convenience and consistency in the userland APIs is more important
than "breaking" internal design. I understand you want to stick to
best practices, but those practices are not a religion and sometimes
you need to break them. If you ask me, a lot of things in ext/session
are broken by design ... creating files from inside read() is one
example, all methods exposed to userland to be in an interface is
another. I agree, it's not perfect, but that's just what happens when
we introduce new features into something that was never designed with
possible changes in the future in mind. For PHP6, we'll have the
freedom to redesign the whole thing completely, but for the time being
- userland code is more important than not having some dependancy in
write().

Cheers,
Andrey.


Thread (29 messages)

« previous php.internals (#73475) next »