]> git.joonet.de Git - adminer.git/commitdiff
Improve session management
authorJakub Vrana <jakub@vrana.cz>
Sun, 19 Aug 2012 20:42:13 +0000 (13:42 -0700)
committerJakub Vrana <jakub@vrana.cz>
Sun, 19 Aug 2012 20:42:13 +0000 (13:42 -0700)
adminer/drivers/mysql.inc.php
adminer/include/bootstrap.inc.php
adminer/include/design.inc.php
adminer/include/functions.inc.php
adminer/select.inc.php
adminer/sql.inc.php

index 41c685c53d161c106ab782fd554ad94056256944..dce1433eb667785a91a3ce7c8b40fae7b7b6e345 100644 (file)
@@ -271,11 +271,13 @@ if (!defined("DRIVER")) {
                $return = &get_session("dbs");
                if ($return === null) {
                        if ($flush) {
-                               restart_session();
                                ob_flush();
                                flush();
                        }
-                       $return = get_vals($connection->server_info >= 5 ? "SELECT SCHEMA_NAME FROM information_schema.SCHEMATA" : "SHOW DATABASES"); // SHOW DATABASES can be disabled by skip_show_database
+                       $databases = get_vals($connection->server_info >= 5 ? "SELECT SCHEMA_NAME FROM information_schema.SCHEMATA" : "SHOW DATABASES"); // SHOW DATABASES can be disabled by skip_show_database
+                       restart_session();
+                       $return = $databases;
+                       stop_session();
                }
                return $return;
        }
index e9d787fde9bd3de84a22ff00fef0e270ed252d25..48a36dd1f9706fa9b0eedeedd03f6f3b616402d6 100644 (file)
@@ -76,8 +76,8 @@ include "../adminer/include/auth.inc.php";
 include "./include/connect.inc.php";
 include "./include/editing.inc.php";
 
-session_cache_limiter(""); // to allow restarting session
 if (!ini_bool("session.use_cookies") || @ini_set("session.use_cookies", false) !== false) { // @ - may be disabled
+       session_cache_limiter(""); // to allow restarting session
        session_write_close(); // improves concurrency if a user opens several pages at once, may be restarted later
 }
 
index 4fb81df50ec1bc14732669d1b5aa6019091cb67b..6bbcf564f698a6d36bd1a81b019307677ac2fe15 100644 (file)
@@ -77,6 +77,7 @@ document.body.className = document.body.className.replace(/ nojs/, ' js');
        if (DB != "" && $databases && !in_array(DB, $databases, true)) {
                $databases = null;
        }
+       stop_session();
        if ($error) {
                echo "<div class='error'>$error</div>\n";
        }
index 97d011eb6d9e4bf4eb6744ad9e1bcc302ba75535..6f7004d2f37f4f8fc5780445de1772ce43dcd6d3 100644 (file)
@@ -396,6 +396,15 @@ function restart_session() {
        }
 }
 
+/** Stop session if it would be possible to restart it later
+* @return null
+*/
+function stop_session() {
+       if (!ini_bool("session.use_cookies")) {
+               session_write_close();
+       }
+}
+
 /** Get session variable for current server
 * @param string
 * @return mixed
index 9a0a781f88fb01bda3433d90e8661f086afa0a3c..23c2329e428e8690a50b42693502062c735b9481 100644 (file)
@@ -189,7 +189,6 @@ if ($_POST && !$error) {
 
 $table_name = $adminer->tableName($table_status);
 page_header(lang('Select') . ": $table_name", $error);
-session_write_close();
 
 $set = null;
 if (isset($rights["insert"])) {
index 58d260a72c6d7ca11d495e6dedf4f0308a529769..6355c5c110925cc840adc558ece0180f66241a4e 100644 (file)
@@ -39,9 +39,6 @@ if (!$error && $_POST) {
                        }
                }
                $space = "(?:\\s|/\\*.*\\*/|(?:#|-- )[^\n]*\n|--\n)";
-               if (!ini_bool("session.use_cookies")) {
-                       session_write_close();
-               }
                $delimiter = ";";
                $offset = 0;
                $empty = true;
@@ -136,7 +133,7 @@ if (!$error && $_POST) {
                                                                if (preg_match("~^$space*(CREATE|DROP|ALTER)$space+(DATABASE|SCHEMA)\\b~isU", $q)) {
                                                                        restart_session();
                                                                        set_session("dbs", null); // clear cache
-                                                                       session_write_close();
+                                                                       stop_session();
                                                                }
                                                                if (!$_POST["only_errors"]) {
                                                                        echo "<p class='message' title='" . h($connection->info) . "'>" . lang('Query executed OK, %d row(s) affected.', $connection->affected_rows) . "$time\n";