Merge "jquery.byteLimit: Partial rewrite to fix logic errors"
[lhc/web/wiklou.git] / includes / db / DatabaseOracle.php
index 664e7da..8ce6e70 100644 (file)
@@ -2,6 +2,21 @@
 /**
  * This is the Oracle database abstraction layer.
  *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
  * @file
  * @ingroup Database
  */
@@ -226,6 +241,7 @@ class DatabaseOracle extends DatabaseBase {
 
        /**
         * Usually aborts on failure
+        * @return DatabaseBase|null
         */
        function open( $server, $user, $password, $dbName ) {
                if ( !function_exists( 'oci_connect' ) ) {
@@ -285,17 +301,10 @@ class DatabaseOracle extends DatabaseBase {
        /**
         * Closes a database connection, if it is open
         * Returns success, true if already closed
+        * @return bool
         */
-       function close() {
-               $this->mOpened = false;
-               if ( $this->mConn ) {
-                       if ( $this->mTrxLevel ) {
-                               $this->commit();
-                       }
-                       return oci_close( $this->mConn );
-               } else {
-                       return true;
-               }
+       protected function closeConnection() {
+               return oci_close( $this->mConn );
        }
 
        function execFlags() {
@@ -401,6 +410,7 @@ class DatabaseOracle extends DatabaseBase {
 
        /**
         * This must be called after nextSequenceVal
+        * @return null
         */
        function insertId() {
                return $this->mInsertId;
@@ -439,6 +449,7 @@ class DatabaseOracle extends DatabaseBase {
        /**
         * Returns information about an index
         * If errors are explicitly ignored, returns NULL on failure
+        * @return bool
         */
        function indexInfo( $table, $index, $fname = 'DatabaseOracle::indexExists' ) {
                return false;
@@ -679,6 +690,7 @@ class DatabaseOracle extends DatabaseBase {
        }
        /**
         * Return the next in a sequence, save the value for retrieval via insertId()
+        * @return null
         */
        function nextSequenceValue( $seqName ) {
                $res = $this->query( "SELECT $seqName.nextval FROM dual" );
@@ -689,6 +701,7 @@ class DatabaseOracle extends DatabaseBase {
 
        /**
         * Return sequence_name if table has a sequence
+        * @return bool
         */
        private function getSequenceData( $table ) {
                if ( $this->sequenceData == null ) {
@@ -836,6 +849,7 @@ class DatabaseOracle extends DatabaseBase {
 
        /**
         * Query whether a given index exists
+        * @return bool
         */
        function indexExists( $table, $index, $fname = 'DatabaseOracle::indexExists' ) {
                $table = $this->tableName( $table );
@@ -855,6 +869,7 @@ class DatabaseOracle extends DatabaseBase {
 
        /**
         * Query whether a given table exists (in the given schema, or the default mw one if not given)
+        * @return int
         */
        function tableExists( $table, $fname = __METHOD__ ) {
                $table = $this->tableName( $table );
@@ -970,7 +985,8 @@ class DatabaseOracle extends DatabaseBase {
        }
 
        /* defines must comply with ^define\s*([^\s=]*)\s*=\s?'\{\$([^\}]*)\}'; */
-       function sourceStream( $fp, $lineCallback = false, $resultCallback = false, $fname = 'DatabaseOracle::sourceStream' ) {
+       function sourceStream( $fp, $lineCallback = false, $resultCallback = false,
+               $fname = 'DatabaseOracle::sourceStream', $inputCallback = false ) {
                $cmd = '';
                $done = false;
                $dollarquote = false;
@@ -1024,6 +1040,9 @@ class DatabaseOracle extends DatabaseBase {
                                        }
 
                                        $cmd = $this->replaceVars( $cmd );
+                                       if ( $inputCallback ) {
+                                               call_user_func( $inputCallback, $cmd );
+                                       }
                                        $res = $this->doQuery( $cmd );
                                        if ( $resultCallback ) {
                                                call_user_func( $resultCallback, $res, $this );
@@ -1176,9 +1195,7 @@ class DatabaseOracle extends DatabaseBase {
                // a hack for deleting pages, users and images (which have non-nullable FKs)
                // all deletions on these tables have transactions so final failure rollbacks these updates
                $table = $this->tableName( $table );
-               if ( $table == $this->tableName( 'page' ) ) {
-                               $this->update( 'recentchanges', array( 'rc_cur_id' => 0 ), array( 'rc_cur_id' => $conds['page_id'] ), $fname );
-               } elseif ( $table == $this->tableName( 'user' )  ) {
+               if ( $table == $this->tableName( 'user' )  ) {
                                $this->update( 'archive', array( 'ar_user' => 0 ), array( 'ar_user' => $conds['user_id'] ), $fname );
                                $this->update( 'ipblocks', array( 'ipb_user' => 0 ), array( 'ipb_user' => $conds['user_id'] ), $fname );
                                $this->update( 'image', array( 'img_user' => 0 ), array( 'img_user' => $conds['user_id'] ), $fname );