I'm running version 7.x-1.x-dev of the Oracle driver against Oracle 10g Express on Drupal 7.0. On admin/reports/status and all sublevels of admin/config/.... I get the following error message:

PDOException: SQLSTATE[IM001]: Driver does not support this function: driver does not support getting attributes in system_requirements() (line 201 of /var/www/drupal7/modules/system/system.install).

The line in system.install which the statement refers is:

      'value' => Database::getConnection()->version(),

Is anyone else seeing this? I'd appreciate any input on how to go about correcting the problem.

Comments

aaaristo’s picture

Status: Active » Postponed (maintainer needs more info)

just installed drupal 7.0 with latest version of oracle driver and i cannot reproduce it.
wait tomorrow to see if with the last dev snap it works

barrett’s picture

Version: 7.x-1.x-dev » 7.x-1.0

I've tried with both 7.x-1.0 and 7.x-1.x-dev versions and get the same result. I also noticed on update.php I get a white screen and the message...

A PDO database driver is required!

You need to enable the PDO_ORACLE database driver for PHP 5.2.4 or higher so that Drupal 7 can access the database.

See the system requirements page for more information.

My phpinfo() output shows:

PDO_OCI
PDO Driver for OCI 8 and later enabled

Is this not the same as the PDO_ORACLE driver? PDO_OCI is what you told me I needed when I was first trying to get things setup (http://drupal.org/node/803618).

I don't see how it's relevant but I'm running PHP 5.3.2 and Apache 2 on Ubuntu.

aaaristo’s picture

Looks like a PDO_OCI bug in 5.3.2... i'm using php 5.2.12... and it works.
There is no PDO_ORACLE, this is a bug in the includes/update.inc of drupal 7...

aaaristo’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)
aaaristo’s picture

created this bug on the core:
http://drupal.org/node/1029080

aaaristo’s picture

I've got a conversation with the guy who follows PDO, and it looks like they added support for the version attribute from 5.2.5... Reading your error it looks like you think you are using PHP 5.3.2, but you still use 5.2.4!

http://drupal.org/node/1028054#comment-3955716

You need to enable the PDO_ORACLE database driver for PHP 5.2.4 or higher so that Drupal 7 can access the database.

Check you paths... try to run php --version, or look at the header of your phpinfo()...

barrett’s picture

Thanks for following up, Andrea. I don't know what's going on. Over the weekend I purged and reinstalled oracle, removed my old drupal site and did a fresh install, and updated php to 5.3.3 in hopes some combination of those would rectify things.

Unfortunately it seems to have made things worse. When I try to install with Oracle selected as the database, I get a segmentation fault error in my apache error log and the install.php is delivered as a download.

[Wed Jan 19 15:42:03 2011] [notice] child pid 2630 exit signal Segmentation fault (11)

Even just connecting directly through PHP is creating an error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[]: pdo_oci_handle_factory: OCI_INVALID_HANDLE (/tmp/PDO_OCI-1.0/oci_driver.c:463)' in /var/www/index.php:6 Stack trace: #0 /var/www/index.php(6): PDO->__construct('oci:dbname=loca...', 'drupal', 'drupal') #1 {main} thrown in /var/www/index.php on line 6

I know you said you thought it was an issue with the PDO driver in PHP 5.3, but I've been able to find no reports of such a problem. If you can point me at anythign that might help, I'd appreciate it, but it looks like this isn't a problem with the oracle integration with drupal but something deeper on my end.

aaaristo’s picture

add export ORACLE_HOME= to /etc/sysconfig/httpd

so that the pdo_oci knows where is your client installation.

this fixed the problem for me in a similar situation. it really depends on how you compiled pdo_oci.
may be you also have to export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH,
checkj also that apache can access your client directory (permissions).

aaaristo’s picture

i've actually found that pdo_oci for php 5.3.5 have a problem with varchar2 length... probably you will need to change my database.inc and set ORACLE_MAX_VARCHAR2_LENGTH TO 1000:

define('ORACLE_MAX_VARCHAR2_LENGTH',1000);

read this:
http://drupal.org/node/787276#comment-2971758

oshelot’s picture

I think this is a bug with PDO_OCI - some getAttribute() features are are gone. I am running PHP 5.3.3 from a default openSUSE install with PDO_OCI 1.0. Running the following script:


    $dbh = new PDO('oci:host=localhost;dbname=XE', 'drupal', 'password');
try {
    $attr = $dbh->getAttribute(constant("PDO::ATTR_DRIVER_NAME"));
    print $attr . "\n";
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
}

Returns the desired result:
# php ico.php
oci

But trying "SERVER_INFO", "SERVER_VERSION" or other attributes fails (PDO::ATTR_SERVER_INFO) fails with the error some of us are seeing:

# php ico.php
PHP Warning: PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support getting attributes in /tmp/ico.php on line 5

Commenting out line 201 in system.install at least lets you get to the Configuration page although I'm not crazy about doing that.

aaaristo’s picture

yes it is definitely a pdo_oci bug. Can you upgrade to 5.3.5?
otherwise i can override the version() method...

aaaristo’s picture

this code works perfectly on 5.3.5...

    $dbh = new PDO('oci:dbname=//localhost/XE', 'drupal7', 'drupal7');
try {
    $attr = $dbh->getAttribute(PDO::ATTR_SERVER_VERSION);
    print $attr . "\n";
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
}
oshelot’s picture

I think an override of version() is a good idea. Most linux distos aren't going to be at 5.3.5 anytime soon, IMO. Last I checked, RHEL 6 was slated to be released with 5.3.2 and I don't see them pushing an update for a small PDO_OCI bug, also IMO. Personally, at this point, upgrading to 5.3.5 would require compiling from source. Usually, I'm all for this, but it would be a headache. I also think that a small code change would save a lot of potential users from dealing with this issue.

    $dbh = new PDO('oci:host=localhost;dbname=XE', 'drupal', 'password');
    $version = $dbh->getAttribute(constant("PDO::ATTR_SERVER_INFO"));
    $errCode = $dbh->errorCode();
    if($errCode != '00000'){
        try {
         $stmt = $dbh->prepare("select * from v\$version where banner like 'Oracle%'");
         $stmt->execute();
         $version =  $stmt->fetchColumn();
         print $version;
        } catch (PDOException $e) {
        print "Error!: " . $e->getMessage() . "\n";
        die();
    }
}

# php ico.php
PHP Warning: PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support getting attributes in /root/ico.php on line 4
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product

On a side note, manually setting the version as string in system.install doesn't seem to produce any undesirable results that I can see. I can still get to the Configuration page. But I don't know Drupal well enough to say that it won't cause problems.

'title' => $t('Database system version'),
'value' => "Oracle Database 10g Express Edition",
# 'value' => Database::getConnection()->version(),

I'm also not in favor of hacking up core Drupal files. In addition, manually setting 'value' to a string didn't resolve the update.php error referenced above (I'm seeing it also).

aaaristo’s picture

About the update.php it is a drupal core bug: comment out line 131 in includes/update.inc (it is a core bug http://drupal.org/node/1029080)

About the version method i've implemented it so should work even on 5.3.3.
You'll find it in 1.4

oshelot’s picture

Andrea, I updated to Oracle driver 7.x-1.4 but am still seeing the same error. Can you tell me where in the driver you put the override code?

aaaristo’s picture

database.inc line 305


  public function version()
  {
    try
    {
        return $this->getAttribute(PDO::ATTR_SERVER_VERSION);
    }
    catch (Exception $ex)
    {
        return $this->oracleQuery("select regexp_replace(banner,'[^0-9\.]','') from v\$version where banner like 'CORE%'")->fetchColumn();
    }
  }