Re: Fixing bug #71038 session_start() returns TRUE on failure

From: Date: Fri, 15 Jan 2016 09:17:37 +0000
Subject: Re: Fixing bug #71038 session_start() returns TRUE on failure
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-90658@lists.php.net to get a copy of this message
Hi Stas, On Fri, Jan 15, 2016 at 5:22 PM, Stanislav Malyshev <smalyshev@gmail.com> wrote: >> Read failure is special because old save handler allowed returning false >> for read and continued as if there is no errors. I cannot fix this without >> braking buggy save handlers compatibility. > > Ah, you mean when read actually worked but handler returns false? If the > session is set up correctly, then returning true is OK I guess. There are many codes like function read($id) { return @file_get_contents(FILE_PATH.$id); } It returns FALSE for non-existing session data. i.e. The first access to the server. To make it work, user should either - check file existence and return '' (empty string) - cast FALSE to "string" to get '' (empty string). e.g. (string)@file_get_contents() So I cannot return FALSE on session_start() read failure w/o breaking existing codes. PHP 7.0 is strict for return values, so session_start() returns FALSE on read failure. Even if it is expected behavior for PHP 7.0, there was bug report on this, though. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#90658) next »