php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76804 oci_pconnect with OCI_CRED_EXT not working.
Submitted: 2018-08-27 20:13 UTC Modified: 2018-12-08 10:29 UTC
From: dave dot reddy at enbridge dot com Assigned: sixd (profile)
Status: Closed Package: OCI8 related
PHP Version: 7.2.9 OS: AIX 7.1
Private report: No CVE-ID: None
 [2018-08-27 20:13 UTC] dave dot reddy at enbridge dot com
Description:
------------
oci_pconnect using clear text credentials works as expected.

oci_pconnect using OCI_CRED_EXT (Oracle Wallets) works only for the first PHP script run by a PHP FastCGI (php-fpm) child process.  The second script run by the child process will think it finds a valid database connection, but the resource type is incorrect and nothing works.

In the first script run, the resource returned by oci_pconnect has a resource type of "oci8 persistent connection".

In subsequent scripts run by the same child fpm process, the resource type is "unknown", the data type is shown as "resource (closed)".



Test script:
---------------
<?php

$sql = "select to_char(sysdate, 'dd-Mon-yyyy hh24:mi:ss') \"DATE\" from dual";

echo "Connection Test 1\n";
// You'll need to setup an Oracle Wallet for the credentials
$conn = oci_pconnect("/", "", "DEV9_DASHBOARD", null, OCI_CRED_EXT);

print_r(gettype($conn));
echo "\n";
print_r(get_resource_type($conn));
echo "\n";

if ($conn === false) {
  echo "Connection dead\n";
} else {
  $stmt = oci_parse($conn, $sql);
  if ($stmt === false) {
    echo "oci_parse returns FALSE\n";
  } else {
    oci_execute($stmt);
    $row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS);
    var_dump($row);
    sleep(1);
  }
}
?>

Expected result:
----------------
Expected Results (this is the result the first time script is executed)

Connection Test 1
resource
oci8 persistent connection
array(1) {
  ["DATE"]=>
  string(20) "27-Aug-2018 15:09:26"
}

Actual result:
--------------
When the fpm child process runs the same script a 2nd or subsequent time, the following results.

Connection Test 1
resource (closed)
Unknown


Warning:  oci_parse(): supplied resource is not a valid oci8 connection resource in /website205/PHPTEST/webapps/php/util/testoci.php on line 22

oci_parse returns FALSE

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-08-27 20:18 UTC] dave dot reddy at enbridge dot com
OCI8 2.1.8 (as downloaded with php)

32 bit Oracle client.
32 bit build of PHP-FPM
 [2018-09-04 17:31 UTC] php at koenigskind dot net
Pull request: https://github.com/php/php-src/pull/3491
 [2018-12-08 10:29 UTC] sixd@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: sixd
 [2018-12-08 10:29 UTC] sixd@php.net
The PR was merged to 7.2/7.3/master and will later be released on PECL as OCI8 2.1.9.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC