accessor for database delimiter
[lhc/web/wiklou.git] / includes / db / Database.php
index 465f25d..db050f2 100644 (file)
@@ -290,6 +290,13 @@ abstract class DatabaseBase implements DatabaseType {
                return $this->getServerVersion();
        }
 
+       /**
+        * @return string: command delimiter used by this database engine
+        */
+       public function getDelimiter() {
+               return $this->delimiter;
+       }
+
        /**
         * Boolean, controls output of large amounts of debug information.
         * @param $debug bool|null
@@ -753,15 +760,12 @@ abstract class DatabaseBase implements DatabaseType {
                $this->mOpened = false;
                if ( $this->mConn ) {
                        if ( $this->trxLevel() ) {
-                               if ( $this->mTrxAutomatic ) {
-                                       // clear flag, so commit() doesn't complain about an explicit commit of an implicit transaction.
-                                       $this->mTrxAutomatic = false;
-                               } else {
+                               if ( !$this->mTrxAutomatic ) {
                                        wfWarn( "Transaction still in progress (from {$this->mTrxFname}), " .
                                                " performing implicit commit before closing connection!" );
                                }
 
-                               $this->commit( __METHOD__ );
+                               $this->commit( __METHOD__, 'flush' );
                        }
 
                        $ret = $this->closeConnection();
@@ -1803,7 +1807,7 @@ abstract class DatabaseBase implements DatabaseType {
                                $list .= "$value";
                        } elseif ( ( $mode == LIST_AND || $mode == LIST_OR ) && is_array( $value ) ) {
                                if ( count( $value ) == 0 ) {
-                                       throw new MWException( __METHOD__ . ': empty input' );
+                                       throw new MWException( __METHOD__ . ": empty input for field $field" );
                                } elseif ( count( $value ) == 1 ) {
                                        // Special-case single values, as IN isn't terribly efficient
                                        // Don't necessarily assume the single key is 0; we don't
@@ -2983,12 +2987,24 @@ abstract class DatabaseBase implements DatabaseType {
         * Nesting of transactions is not supported.
         *
         * @param $fname string
-        */
-       final public function commit( $fname = 'DatabaseBase::commit' ) {
-               if ( !$this->mTrxLevel ) {
-                       wfWarn( "$fname: No transaction to commit, something got out of sync!" );
-               } elseif( $this->mTrxAutomatic ) {
-                       wfWarn( "$fname: Explicit commit of implicit transaction. Something may be out of sync!" );
+        * @param $flush String Flush flag, set to 'flush' to disable warnings about explicitly committing implicit
+        *        transactions, or calling commit when no transaction is in progress.
+        *        This will silently break any ongoing explicit transaction. Only set the flush flag if you are sure
+        *        that it is safe to ignore these warnings in your context.
+        */
+       final public function commit( $fname = 'DatabaseBase::commit', $flush = '' ) {
+               if ( $flush != 'flush' ) {
+                       if ( !$this->mTrxLevel ) {
+                               wfWarn( "$fname: No transaction to commit, something got out of sync!" );
+                       } elseif( $this->mTrxAutomatic ) {
+                               wfWarn( "$fname: Explicit commit of implicit transaction. Something may be out of sync!" );
+                       }
+               } else {
+                       if ( !$this->mTrxLevel ) {
+                               return; // nothing to do
+                       } elseif( !$this->mTrxAutomatic ) {
+                               wfWarn( "$fname: Flushing an explicit transaction, getting out of sync!" );
+                       }
                }
 
                $this->doCommit( $fname );