Merge "Make wfForeignMemcKey consistent with wfMemcKey"
[lhc/web/wiklou.git] / includes / db / DatabaseOracle.php
index 34305f7..2ccc056 100644 (file)
@@ -249,6 +249,7 @@ class DatabaseOracle extends DatabaseBase {
         * @return DatabaseBase|null
         */
        function open( $server, $user, $password, $dbName ) {
+               global $wgDBOracleDRCP;
                if ( !function_exists( 'oci_connect' ) ) {
                        throw new DBConnectionError( $this, "Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n (Note: if you recently installed PHP, you may need to restart your webserver and database)\n" );
                }
@@ -276,9 +277,16 @@ class DatabaseOracle extends DatabaseBase {
                        return;
                }
 
+               if ( $wgDBOracleDRCP ) {
+                       $this->setFlag( DBO_PERSISTENT );
+               }
+
                $session_mode = $this->mFlags & DBO_SYSDBA ? OCI_SYSDBA : OCI_DEFAULT;
+
                wfSuppressWarnings();
-               if ( $this->mFlags & DBO_DEFAULT ) {
+               if ( $this->mFlags & DBO_PERSISTENT ) {
+                       $this->mConn = oci_pconnect( $this->mUser, $this->mPassword, $this->mServer, $this->defaultCharset, $session_mode );
+               } else if ( $this->mFlags & DBO_DEFAULT ) {
                        $this->mConn = oci_new_connect( $this->mUser, $this->mPassword, $this->mServer, $this->defaultCharset, $session_mode );
                } else {
                        $this->mConn = oci_connect( $this->mUser, $this->mPassword, $this->mServer, $this->defaultCharset, $session_mode );
@@ -333,7 +341,7 @@ class DatabaseOracle extends DatabaseBase {
                $union_unique = ( preg_match( '/\/\* UNION_UNIQUE \*\/ /', $sql ) != 0 );
                // EXPLAIN syntax in Oracle is EXPLAIN PLAN FOR and it return nothing
                // you have to select data from plan table after explain
-               $explain_id = date( 'dmYHis' );
+               $explain_id = MWTimestamp::getLocalInstance()->format( 'dmYHis' );
 
                $sql = preg_replace( '/^EXPLAIN /', 'EXPLAIN PLAN SET STATEMENT_ID = \'' . $explain_id . '\' FOR', $sql, 1, $explain_count );
 
@@ -456,15 +464,15 @@ class DatabaseOracle extends DatabaseBase {
         * If errors are explicitly ignored, returns NULL on failure
         * @return bool
         */
-       function indexInfo( $table, $index, $fname = 'DatabaseOracle::indexExists' ) {
+       function indexInfo( $table, $index, $fname = __METHOD__ ) {
                return false;
        }
 
-       function indexUnique( $table, $index, $fname = 'DatabaseOracle::indexUnique' ) {
+       function indexUnique( $table, $index, $fname = __METHOD__ ) {
                return false;
        }
 
-       function insert( $table, $a, $fname = 'DatabaseOracle::insert', $options = array() ) {
+       function insert( $table, $a, $fname = __METHOD__, $options = array() ) {
                if ( !count( $a ) ) {
                        return true;
                }
@@ -624,7 +632,7 @@ class DatabaseOracle extends DatabaseBase {
                oci_free_statement( $stmt );
        }
 
-       function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'DatabaseOracle::insertSelect',
+       function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = __METHOD__,
                $insertOptions = array(), $selectOptions = array() )
        {
                $destTable = $this->tableName( $destTable );
@@ -763,7 +771,7 @@ class DatabaseOracle extends DatabaseBase {
                return $this->lastErrno() == 'OCI-00060';
        }
 
-       function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'DatabaseOracle::duplicateTableStructure' ) {
+       function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = __METHOD__ ) {
                $temporary = $temporary ? 'TRUE' : 'FALSE';
 
                $newName = strtoupper( $newName );
@@ -776,7 +784,7 @@ class DatabaseOracle extends DatabaseBase {
                return $this->doQuery( "BEGIN DUPLICATE_TABLE( '$tabName', '$oldPrefix', '$newPrefix', $temporary ); END;" );
        }
 
-       function listTables( $prefix = null, $fname = 'DatabaseOracle::listTables' ) {
+       function listTables( $prefix = null, $fname = __METHOD__ ) {
                $listWhere = '';
                if ( !empty( $prefix ) ) {
                        $listWhere = ' AND table_name LIKE \'' . strtoupper( $prefix ) . '%\'';
@@ -800,7 +808,7 @@ class DatabaseOracle extends DatabaseBase {
                return $endArray;
        }
 
-       public function dropTable( $tableName, $fName = 'DatabaseOracle::dropTable' ) {
+       public function dropTable( $tableName, $fName = __METHOD__ ) {
                $tableName = $this->tableName( $tableName );
                if ( !$this->tableExists( $tableName ) ) {
                        return false;
@@ -837,7 +845,7 @@ class DatabaseOracle extends DatabaseBase {
        /**
         * @return string wikitext of a link to the server software's web site
         */
-       public static function getSoftwareLink() {
+       public function getSoftwareLink() {
                return '[http://www.oracle.com/ Oracle]';
        }
 
@@ -857,7 +865,7 @@ class DatabaseOracle extends DatabaseBase {
         * Query whether a given index exists
         * @return bool
         */
-       function indexExists( $table, $index, $fname = 'DatabaseOracle::indexExists' ) {
+       function indexExists( $table, $index, $fname = __METHOD__ ) {
                $table = $this->tableName( $table );
                $table = strtoupper( $this->removeIdentifierQuotes( $table ) );
                $index = strtoupper( $index );
@@ -961,12 +969,12 @@ class DatabaseOracle extends DatabaseBase {
                return $this->fieldInfoMulti( $table, $field );
        }
 
-       protected function doBegin( $fname = 'DatabaseOracle::begin' ) {
+       protected function doBegin( $fname = __METHOD__ ) {
                $this->mTrxLevel = 1;
                $this->doQuery( 'SET CONSTRAINTS ALL DEFERRED' );
        }
 
-       protected function doCommit( $fname = 'DatabaseOracle::commit' ) {
+       protected function doCommit( $fname = __METHOD__ ) {
                if ( $this->mTrxLevel ) {
                        $ret = oci_commit( $this->mConn );
                        if ( !$ret ) {
@@ -977,7 +985,7 @@ class DatabaseOracle extends DatabaseBase {
                }
        }
 
-       protected function doRollback( $fname = 'DatabaseOracle::rollback' ) {
+       protected function doRollback( $fname = __METHOD__ ) {
                if ( $this->mTrxLevel ) {
                        oci_rollback( $this->mConn );
                        $this->mTrxLevel = 0;
@@ -987,7 +995,7 @@ class DatabaseOracle extends DatabaseBase {
 
        /* defines must comply with ^define\s*([^\s=]*)\s*=\s?'\{\$([^\}]*)\}'; */
        function sourceStream( $fp, $lineCallback = false, $resultCallback = false,
-               $fname = 'DatabaseOracle::sourceStream', $inputCallback = false ) {
+               $fname = __METHOD__, $inputCallback = false ) {
                $cmd = '';
                $done = false;
                $dollarquote = false;
@@ -1139,7 +1147,7 @@ class DatabaseOracle extends DatabaseBase {
                return $conds2;
        }
 
-       function selectRow( $table, $vars, $conds, $fname = 'DatabaseOracle::selectRow', $options = array(), $join_conds = array() ) {
+       function selectRow( $table, $vars, $conds, $fname = __METHOD__, $options = array(), $join_conds = array() ) {
                if ( is_array( $conds ) ) {
                        $conds = $this->wrapConditionsForWhere( $table, $conds );
                }
@@ -1188,7 +1196,7 @@ class DatabaseOracle extends DatabaseBase {
                return array( $startOpts, $useIndex, $preLimitTail, $postLimitTail );
        }
 
-       public function delete( $table, $conds, $fname = 'DatabaseOracle::delete' ) {
+       public function delete( $table, $conds, $fname = __METHOD__ ) {
                if ( is_array( $conds ) ) {
                        $conds = $this->wrapConditionsForWhere( $table, $conds );
                }
@@ -1211,7 +1219,7 @@ class DatabaseOracle extends DatabaseBase {
                return parent::delete( $table, $conds, $fname );
        }
 
-       function update( $table, $values, $conds, $fname = 'DatabaseOracle::update', $options = array() ) {
+       function update( $table, $values, $conds, $fname = __METHOD__, $options = array() ) {
                global $wgContLang;
 
                $table = $this->tableName( $table );