php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39352 oci_close fails with global keyword
Submitted: 2006-11-02 22:54 UTC Modified: 2006-12-31 21:01 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: david at acz dot org Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.0 OS: SuSE Linux 9.3
Private report: No CVE-ID: None
 [2006-11-02 22:54 UTC] david at acz dot org
Description:
------------
oci_close() fails if the connection resource is a global accessed via the "global" keyword, but works if accessed using the $GLOBALS array.

Reproduce code:
---------------
$conn = oci_connect(DB_USER, DB_PASS, DB_NAME);
var_dump($conn);

global_keyword();
global_array();

function global_keyword()
{
    global $conn;
    var_dump($conn);
    oci_close($conn);  // this seems to do nothing
    var_dump($conn);
}

function global_array()
{
    var_dump($GLOBALS["conn"]);
    oci_close($GLOBALS["conn"]);  // this works
    var_dump($GLOBALS["conn"]);
}


Expected result:
----------------
resource(8) of type (oci8 connection)
resource(8) of type (oci8 connection)
NULL
NULL
PHP Warning: oci_close() expects parameter 1 to be resource, null given
NULL


Actual result:
--------------
resource(8) of type (oci8 connection)
resource(8) of type (oci8 connection)
resource(8) of type (oci8 connection)
resource(8) of type (oci8 connection)
NULL


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-06 08:50 UTC] anon at anon dot com
reproduced on Windows 2003 server, using Nov 2 release of 5.2.0
 [2006-11-08 10:08 UTC] tony2001@php.net
Actually this has nothing to do with OCI8, as this is the way PHP handles resources.
You can do the same trick with MySQL and it won't actually close the connection when using global variable, but it will work with $GLOBALS.

 [2006-11-09 14:55 UTC] david at acz dot org
Changing category.
 [2006-12-31 21:01 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 05 15:01:34 2025 UTC