Bug #72932 [Opn->Wfx]: database sessions causes upload to CRASH if upload progress used
| From: | yohgaki@php.net | Date: | Wed, 24 Aug 2016 07:03:27 +0000 |
| Subject: | Bug #72932 [Opn->Wfx]: database sessions causes upload to CRASH if upload progress used | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203519@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72932&edit=1
ID: 72932
Updated by: yohgaki@php.net
Reported by: mark at sasoft dot co dot za
Summary: database sessions causes upload to CRASH if upload
progress used
-Status: Open
+Status: Wont fix
Type: Bug
Package: Session related
Operating System: Windows
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
First of all, unless there is working session save handler, file upload progress wouldn't work
at all.
What do you mean by "then the upload actually crashes the script"? I guess you mean PHP
script execution is terminated by "PHP Fatal error: Unknown: Failed to initialize storage
module: user (path: C:\WINDOWS\Temp) in Unknown on line 0".
There will be errors when save handler didn't work. This behavior cannot be changed for
reasons.
It seems file upload have problems in 7.0. If this is the case, please comment appropriate bug
reports. Thank you.
Previous Comments:
------------------------------------------------------------------------
[2016-08-23 15:18:44] mark at sasoft dot co dot za
Description:
------------
It appears this bug exists regardless of any version of php or OS or web server. I have physically
tested this to occur across:
- Windows 7, Windows Server 2012 R2
- PHP Version 5.3, 5.4, 5.5, 5.6 and 7.0.10 (all binaries downloaded from php.net windows already
compiled as NTS x86 and x64)
- Apache 2.2 and IIS (7+8)
My php.ini has been modified only for session.save_handler = user. All other settings left as
default.
What happens is that if I submit a form with file upload progress utilisation (ie. name as value
from ini_get("session.upload_progress.name")) then the upload actually crashes the script
and my error log file contains the contents :
PHP Warning: Unknown: user session functions not defined in Unknown on line 0
PHP Fatal error: Unknown: Failed to initialize storage module: user (path: C:\WINDOWS\Temp) in
Unknown on line 0
It appears that php is trying to default back to use save_hander=files and then fails. If i COMMENT
OUT the PHP_SESSION_UPLOAD_PROGRESS line so that file upload progress is disabled, it works
perfectly. It also works perfectly if i set the save_handler back to "files" in my
php.ini.
Naturally, even if it didnt generate a fatal error, the file session info would still be
inaccessible to my database session if it succeeds in writing to the file.
Test script:
---------------
The html form looks like this :
<iframe id="upload_iframe" name="upload_iframe" style="width: 1px;
height: 1px; display: block;border:0px;"></iframe>
<form id="myUploadForm" name="myUploadForm" target="upload_iframe"
action="uploadFile.php" method="post"
enctype="multipart/form-data">
<input type="hidden" name="UID" value="1">
<input type="hidden" value="myUploadForm"
name="PHP_SESSION_UPLOAD_PROGRESS">
<input type="file" class="upload" name="file"
id="file">
<input type="submit" class="cmi-button small white" value="Upload"
onclick="fileUpload.startUploadMonitoring();">
</form>
My session_set_save_handler override for _open looks like this :
function _open() {
if( ($this->dbc = mysqli_connect(DBSettings::HOSTNAME, DBSettings::USERNAME,
DBSettings::PASSWORD)) !== false ) {
$select_db = mysqli_select_db($this->dbc, DBSettings::DATABASE_SHARED_SERVICES);
// $set_charset = mysqli_set_charset($this->dbc, DB_CHARSET);
return( $select_db /*&& $set_charset*/ );
}
else {
trigger_error(mysqli_error($this->dbc), E_USER_ERROR);
}
return( false );
}
(but i think the above handler override is irrelevant to this bug as even if i change the
trigger_error to return true rather, it makes no difference as the error occurs BEFORE control is
handed over to the USER script)
Expected result:
----------------
it should firstly NOT crash PHP, and secondly it should use the php.ini setting for my database
session handler.
my error log file contains the contents :
PHP Warning: Unknown: user session functions not defined in Unknown on line 0
PHP Fatal error: Unknown: Failed to initialize storage module: user (path: C:\WINDOWS\Temp) in
Unknown on line 0
Actual result:
--------------
my error log file contains the contents :
PHP Warning: Unknown: user session functions not defined in Unknown on line 0
PHP Fatal error: Unknown: Failed to initialize storage module: user (path: C:\WINDOWS\Temp) in
Unknown on line 0
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72932&edit=1