Ticket #2982: ticket2982.patch

File ticket2982.patch, 696 bytes (added by jcrandall@…, 17 years ago)

Patch to fix this bug by adding a destructor to the Database object which restores the global $db reference and calls session_write_close.

  • includes/objects/Database.php

     
    7777    }
    7878
    7979/**
     80 * Destructor to save the session  before the database connection dies
     81/**/
     82    function __destruct() {
     83        // Restore global db object reference for session write
     84        global $db;
     85        $db = $this;
     86        // Ask session to write and close now, before we lose the db object forever
     87        session_write_close();
     88    }
     89
     90/**
    8091 * This takes the place of a database constructor.  It should be called directly
    8192 * without an object as:
    8293 *