Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97298 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48590 invoked from network); 6 Dec 2016 02:41:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Dec 2016 02:41:48 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:54680] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A2/29-11772-A6526485 for ; Mon, 05 Dec 2016 21:41:47 -0500 Received: (qmail 92322 invoked by uid 89); 6 Dec 2016 02:41:43 -0000 Received: from unknown (HELO mail-wj0-f175.google.com) (yohgaki@ohgaki.net@209.85.210.175) by 0 with ESMTPA; 6 Dec 2016 02:41:43 -0000 Received: by mail-wj0-f175.google.com with SMTP id tk12so11391028wjb.3 for ; Mon, 05 Dec 2016 18:41:42 -0800 (PST) X-Gm-Message-State: AKaTC00x9UPsReFXSPfMv2td6YUtc41Ma5xypi5JSERpd4ASFbM0CbSVIPIM0CzviJia9Bx3cSsFgQiCiEAfxA== X-Received: by 10.194.231.8 with SMTP id tc8mr51739708wjc.193.1480992096516; Mon, 05 Dec 2016 18:41:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.38.7 with HTTP; Mon, 5 Dec 2016 18:40:55 -0800 (PST) In-Reply-To: References: Date: Tue, 6 Dec 2016 11:40:55 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Marco Pivetta Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC][VOTE] User defined session serializer From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi Marco, On Mon, Dec 5, 2016 at 10:52 PM, Marco Pivetta wrote: > On Mon, Dec 5, 2016 at 4:31 AM, Yasuo Ohgaki wrote: >> Firstly, current OO custom save handler design (use of previously used >> internal save handler as its base class) is not good. Overriding >> open()/close()/etc are useless, moreover harmful. Number of bugs >> proved it is not good. > > > Number of bugs? In which adapters? There are well tested session > savehandlers out there, and I'd trade a userland bug for an internals bug > anytime. If you search bug db by "session crash" https://bugs.php.net/search.php?search_for=session+crash&boolean=0&limit=30&order_by=&direction=DESC&cmd=display&status=Closed&bug_type=All&project=All&php_os=&phpver=&cve_id=&assign=&author_email=&bug_age=0&bug_updated=0 You'll find many save handler bug reports. >> Secondly, the only use case, that current OO save handler design is >> useful, is read()/write() override to encrypt/validate session data. > > > What does this RFC do that a custom session savehandler *CANNOT*? Currently, users cannot use arbitrary serialization. Dirty hack (which is inefficient also) is required to do this. >> Thirdly, I fixed _many_ of current OO API bugs, but fixing them all is >> impossible by design. > > > It would need a deprecation of the current session module, and a replacement > with a newer, cleaner API. Although some APIs need improvements, but basic module design is good. If you have a design improvement idea, I appreciate it. >> Current OO save handler API is wrong in many ways and should be >> deprecated and replaced by clean OO API as mentioned in the RFC. >> >> Is there any good reasons to keep problematic API for good? > > > There is a problem with adding a half-feature to fix half the problem, and > then having to deprecate this half-feature when the new full solution is > actually replacing it in a correct way. Correct way would be - deprecate problematic current OO API which uses previously defined save handler as base object. - implement new OO API which simply uses user defined handler. BTW, this is not a topic of this RFC, but it's future scope. Please don't mixed up. This RFC provides mandatory feature that customize session data representation. i.e. serialization format, encrypt/decrypt, validation, etc. >> > This is just confusing, in my opinion, and the API can be replicated in >> > userland with a custom session save handler decorator instead. >> >> I may be too familiar to session module. I don't understand what's >> confusing. Session module has 2 distinct submodules for saving and >> serializing data. These have different tasks. > > > It is confusing that we now have two ways of passing down serializers for > sessions. > The Redis session savehandlers already use igbinary where applicable, for > example, so why do I need to have a second equivalent API? Providing a > userland base session savehandler with pluggable serializers (written in > PHP, not in C, please!) is a much better idea. C module could do anything, but user script cannot. Please don't mixed up C code and user script. This RFC generalizes "serialization" and provide interface to user script which C module cannot. (Since C submodule can do anything, so it's possible that save handlers to provide their own serializer interface/API. However, what's good about this? Session module defines serializer as submodule already. We don't need module A provide A serializer interface, module B provides B serializer interface. It's just a mess and confusing.) >> The RFC allows to save session data in whatever format. e.g. >> XML/JSON/BSON/etc. This is _impossible_ by save handler submodule > > > Savehandlers even save to flat DB tables, so I'm not understanding what is > being explained here... > > Even in the docs, the first example shows how to add encryption to a custom > savehandler: https://secure.php.net/manual/en/class.sessionhandler.php > > Adding a custom serialization is as simple as an `unserialize()` + custom > serializer call (Yes, I can already hear all those microseconds screaming! > The horror!) It seems you misunderstood this RFC. I have to say, you are wrong and your statement is FUD. Try to write your own serializer with current API by yourself. If you could write clean one like this, session_set_serializer( function ($input_array) { return json_encode($input_array); }, function ($input_string) { return json_decode($input_string); } ); // User may use "interface" alternatively. // Optionally, encryption/validation can be with these functions. please show us. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net