* Fix explicit s-maxage=0 on raw pages; should help with proxy issues in
[lhc/web/wiklou.git] / includes / Database.php
index 0f6c212..1dfe194 100644 (file)
@@ -361,17 +361,6 @@ class Database {
        function query( $sql, $fname = '', $tempIgnore = false ) {
                global $wgProfiling, $wgCommandLineMode;
 
-               if ( wfReadOnly() ) {
-                       # This is a quick check for the most common kinds of write query used
-                       # in MediaWiki, to provide extra safety in addition to UI-level checks.
-                       # It is not intended to prevent every conceivable write query, or even
-                       # to handle such queries gracefully.
-                       if ( preg_match( '/^(?:update|insert|replace|delete)/i', $sql ) ) {
-                               wfDebug( "Write query from $fname blocked\n" );
-                               return false;
-                       }
-               }
-
                if ( $wgProfiling ) {
                        # generalizeSQL will probably cut down the query to reasonable
                        # logging size most of the time. The substr is really just a sanity check.
@@ -1338,15 +1327,20 @@ class Database {
         * $conds may be "*" to copy the whole table
         * srcTable may be an array of tables.
         */
-       function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'Database::insertSelect' ) {
+       function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'Database::insertSelect', 
+               $options = array() ) 
+       {
                $destTable = $this->tableName( $destTable );
-                if( is_array( $srcTable ) ) {
-                        $srcTable =  implode( ',', array_map( array( &$this, 'tableName' ), $srcTable ) );
-               } else {
+               if ( is_array( $options ) ) {
+                       $options = implode( ' ', $options );
+               }
+               if( is_array( $srcTable ) ) {
+                       $srcTable =  implode( ',', array_map( array( &$this, 'tableName' ), $srcTable ) );
+               } else { 
                        $srcTable = $this->tableName( $srcTable );
                }
-               $sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' .
-                       ' SELECT ' . implode( ',', $varMap ) .
+               $sql = "INSERT $options INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' .
+                       ' SELECT ' . implode( ',', $varMap ) . 
                        " FROM $srcTable";
                if ( $conds != '*' ) {
                        $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND );
@@ -1688,7 +1682,7 @@ class Database {
                                $res = $this->query( $cmd, 'dbsource', true );
 
                                if ( false === $res ) {
-                                       $err = $this->mLastError();
+                                       $err = $this->lastError();
                                        return "Query \"{$cmd}\" failed with error code \"$err\".\n";
                                }