ID: 38241 Updated by: [EMAIL PROTECTED] Reported By: qw_kerry at yahoo dot com dot cn -Status: Open +Status: Bogus Bug Type: Session related Operating System: Windows 2003 SP1 PHP Version: 5CVS-2006-07-28 (snap) New Comment:
Expected behaviour. Function DBSessionWrite() is called when PDO object is already destroyed. Previous Comments: ------------------------------------------------------------------------ [2006-07-29 09:04:50] qw_kerry at yahoo dot com dot cn Description: ------------ I use session_set_save_handler() to define my own session handler. It can read session values, but can't write them. But the function work well when I run my script on php 5.1.4. Environment OS: Windows 2003 SP1 Apache: 2.2.2 Mysql: 5.0.22 Reproduce code: --------------- You can find my script in the following url. http://www.30t.net/bug/session.txt The session table structure is defined as CREATE TABLE `session` ( sessionid char(28) character set latin1 collate latin1_general_ci NOT NULL, lastupdated int(11) NOT NULL, datavalue varchar(1000) character set latin1 collate latin1_general_ci NOT NULL, PRIMARY KEY (sessionid) ) ENGINE=MEMORY DEFAULT CHARSET=utf8; Expected result: ---------------- One new row should appear in the session table. Actual result: -------------- Fatal error: Call to a member function prepare() on a non-object in E:\sumly2007\test.php on line 6 ------------------------------------------------------------------------ [2006-07-28 09:31:46] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try to avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2006-07-28 09:26:01] qw_kerry at yahoo dot com dot cn Description: ------------ I use session_set_save_handler() to define my own session handler. It can read session values, but can't write them. But the function work well when I run my script on php 5.1.4. Session is stored in database in my script. When I store session in files, session is written well. Reproduce code: --------------- The functions except for DBSessionWrite are omitted. PDO_MYSQL is used. function DBSessionWrite($aKey,$aVal) { global $_sessiondb,$_sessiontable; $sql = "SELECT lastupdated FROM ".$_sessiontable." WHERE sessionid=?"; $stmt = $_sessiondb->prepare($sql); $stmt->execute($aKey); if($stmt->fetchColumn()) { $sql = "UPDATE ".$_sessiontable." SET datavalue=?, lastupdated=? WHERE sessionid=?"; $stmt = $_sessiondb->prepare($sql); $stmt->execute(array($aVal,time(),$aKey)); } else { $sql = "INSERT INTO ".$_sessiontable." VALUES (?,?,?)"; $stmt = $_sessiondb->prepare($sql); $stmt->execute(array($aKey,time(),$aVal)); } return $stmt->rowCount(); } session_set_save_handler("DBSessionOpen", "DBSessionClose", "DBSessionRead", "DBSessionWrite", "DBSessionDestroy", "DBSessionGC"); session_start(); $session_idencode = md5($_SERVER["REMOTE_ADDR"]); if($session_idencode != $_SESSION['idencode']) { session_regenerate_id(true); $_SESSION['idencode'] = $session_idencode; } Expected result: ---------------- One new row should appear in the session table. Actual result: -------------- No new row appear. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38241&edit=1