php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #37566 session_set_save_handler _write can't throw Exception.
Submitted: 2006-05-23 21:49 UTC Modified: 2007-06-17 09:02 UTC
From: kotsutsumi at xenophy dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kotsutsumi at xenophy dot com
New email:
PHP Version: OS:

 

 [2006-05-23 21:49 UTC] kotsutsumi at xenophy dot com
Description:
------------
It mounts in the class. 

       session_set_save_handler(
           array($this, '_open'),
           array($this, '_close'),
           array($this, '_read'),
           array($this, '_write'),
           array($this, '_destroy'),
           array($this, '_clean')
       );

...

public function _write( $strID, &$objData ) {

   // some process.
   throw new Exception;
}

Result:
Exception thrown without a stack frame in ....

Why?
The exception is normally generated in other methods. 
ex. _read,_destroy,_clear... 

Reproduce code:
---------------
    public function _write( $strID, &$objData ) {

        try {
            $strSQL = "REPLACE INTOd sessions hogeVALUES ( ?, ?, ?  )";

            $putData = $this->objResource->prepare( $strSQL );
            $putData->bindParam( 1, $strID );
            $putData->bindParam( 2, time() );
            $putData->bindParam( 3, $objData );
            $putData->execute();
            return true;
        } catch( PDOException $e) {
            $strError = sprintf( "?Z?b?V?????f?[?^?̐ݒ??Ɏ??s???܂????B<br><br>%s" ,$e->getMessage() );
            throw new Exception( $strError );
        }
   }

Expected result:
----------------
Fatal error: Exception thrown without a stack frame in Unknown on line 0


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-23 22:03 UTC] bjori@php.net
Reclassified as documentation problem.

session_write_close() (write and close) is called during 
the script shutdown and can't therefor throw exceptions.
 [2007-06-17 09:02 UTC] didou@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:10 UTC] phpdocbot@php.net
Automatic comment on behalf of didou
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=cacbe74a9688964547b912e75323578b73b79b24
Log: Fix #37566: Cannot throw exceptions
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 08 22:01:31 2025 UTC