Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve concurrency

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1225 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
commit f9a20232aef6741fdfb4c97903aed160d2c947e9 1 parent dfb36a6
jakubvrana authored
View
1  adminer/include/adminer.inc.php
@@ -358,6 +358,7 @@ function selectEmailProcess($where, $foreignKeys) {
* @return string
*/
function messageQuery($query) {
+ session_start();
$id = "sql-" . count($_SESSION["messages"]);
$_SESSION["history"][$_GET["server"]][DB][] = $query;
return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre class='jush-sql'>" . shorten_utf8($query, 1000) . '</pre><a href="' . h(ME . 'sql=&history=' . (count($_SESSION["history"][$_GET["server"]][DB]) - 1)) . '">' . lang('Edit') . '</a></div>';
View
5 adminer/include/bootstrap.inc.php
@@ -91,6 +91,11 @@
include "./include/editing.inc.php";
include "./include/export.inc.php";
+session_cache_limiter(""); // to allow restarting session
+if (@ini_set("session.use_cookies", false) !== false) { // @ - may be disabled
+ session_write_close(); // improves concurrency, may be restarted later
+}
+
$confirm = " onclick=\"return confirm('" . lang('Are you sure?') . "');\"";
$token = $_SESSION["tokens"][$_GET["server"]];
$error = ($_POST
View
3  adminer/include/design.inc.php
@@ -40,6 +40,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
echo "$title\n";
}
echo "<h2>$title_all</h2>\n";
+ restart_session();
if ($_SESSION["messages"]) {
echo "<div class='message'>" . implode("</div>\n<div class='message'>", $_SESSION["messages"]) . "</div>\n";
$_SESSION["messages"] = array();
@@ -51,7 +52,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
if (strlen(DB) && $databases && !in_array(DB, $databases, true)) {
$databases = null;
}
- if (isset($databases) && !isset($_GET["sql"])) {
+ if ((isset($databases) && !isset($_GET["sql"])) || !ini_get("session.use_cookies")) {
// improves concurrency if a user opens several pages at once
session_write_close();
}
View
1  adminer/include/editing.inc.php
@@ -351,6 +351,7 @@ function drop_create($drop, $create, $location, $message_drop, $message_alter, $
$dropped = strlen($name) && ($_POST["dropped"] || queries($drop));
$created = queries($create);
if (!queries_redirect($location, (strlen($name) ? $message_alter : $message_create), $created) && $dropped) {
+ session_start();
$_SESSION["messages"][] = $message_drop;
}
return $dropped;
View
16 adminer/include/functions.inc.php
@@ -204,6 +204,15 @@ function cookie($name, $value) {
return setcookie($name, $value, time() + 2592000, preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"])); // 2592000 = 30 * 24 * 60 * 60
}
+/** Restart stopped session
+* @return null
+*/
+function restart_session() {
+ if (!ini_get("session.use_cookies")) {
+ session_start();
+ }
+}
+
/** Send Location header and exit
* @param string
* @param string
@@ -211,6 +220,7 @@ function cookie($name, $value) {
*/
function redirect($location, $message = null) {
if (isset($message)) {
+ session_start();
$_SESSION["messages"][] = $message;
}
header("Location: " . (strlen($location) ? $location : "."));
@@ -228,13 +238,13 @@ function redirect($location, $message = null) {
*/
function query_redirect($query, $location, $message, $redirect = true, $execute = true, $failed = false) {
global $connection, $error, $adminer;
+ if ($execute) {
+ $failed = !$connection->query($query);
+ }
$sql = "";
if ($query) {
$sql = $adminer->messageQuery($query);
}
- if ($execute) {
- $failed = !$connection->query($query);
- }
if ($failed) {
$error = h($connection->error) . $sql;
return false;
View
1  adminer/include/mysql.inc.php
@@ -168,6 +168,7 @@ function get_databases($flush = true) {
// SHOW DATABASES can take a very long time so it is cached
$return = &$_SESSION["databases"][$_GET["server"]];
if (!isset($return)) {
+ restart_session();
$return = get_vals("SHOW DATABASES");
if ($flush) {
ob_flush();
View
4 adminer/sql.inc.php
@@ -27,8 +27,8 @@
$space = "(\\s|/\\*.*\\*/|(#|-- )[^\n]*\n|--\n)";
$alter_database = "(CREATE|DROP)$space+(DATABASE|SCHEMA)\\b~isU";
$databases = &$_SESSION["databases"][$_GET["server"]];
- if (isset($databases) && !preg_match("~\\b$alter_database", $query)) { // quick check - may be inside string
- //! false positive with $fp
+ if ((isset($databases) && !preg_match("~\\b$alter_database", $query)) || !ini_get("session.use_cookies")) { // quick check - may be inside string
+ //! false positive with $fp and disabled ini_set() and enabled session.use_cookies
session_write_close();
}
$delimiter = ";";
View
1  changes.txt
@@ -1,4 +1,5 @@
Adminer 2.2.1-dev:
+Improve concurrency
Link new item in backward keys (Editor)
Adminer 2.2.0 (released 2009-10-20):
Please sign in to comment.
Something went wrong with that request. Please try again.