Permalink
Browse files

Minimize the chance of displaying message on different page (thanks t…

…o Tomas Brukner)
  • Loading branch information...
1 parent ceef6bc commit 79fa7dab3ba510eb310c220cc7f04d25e079c207 @vrana committed Jan 30, 2011
@@ -404,8 +404,9 @@ function selectEmailProcess($where, $foreignKeys) {
*/
function messageQuery($query) {
global $jush;
+ static $count = 0;
restart_session();
- $id = "sql-" . count($_SESSION["messages"]);
+ $id = "sql-" . ($count++);
$history = &get_session("queries");
$history[$_GET["db"]][] = (strlen($query) > 1e6 // not DB - reset in drop database
? ereg_replace('[\x80-\xFF]+$', '', substr($query, 0, 1e6)) . "\n..." // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
@@ -64,9 +64,11 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
}
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();
+ $uri = preg_replace('~^[^?]*/~', '', $_SERVER["REQUEST_URI"]);
+ $messages = $_SESSION["messages"][$uri];
+ if ($messages) {
+ echo "<div class='message'>" . implode("</div>\n<div class='message'>", $messages) . "</div>\n";
+ unset($_SESSION["messages"][$uri]);
}
$databases = &get_session("dbs");
if (DB != "" && $databases && !in_array(DB, $databases, true)) {
@@ -349,7 +349,7 @@ function drop_create($drop, $create, $location, $message_drop, $message_alter, $
$created = queries($create);
if (!queries_redirect($location, ($name != "" ? $message_alter : $message_create), $created) && $dropped) {
restart_session();
- $_SESSION["messages"][] = $message_drop;
+ $_SESSION["messages"][preg_replace('~^[^?]*/~', '', $_SERVER["REQUEST_URI"])][] = $message_drop;
}
return $dropped;
}
@@ -384,7 +384,7 @@ function is_ajax() {
function redirect($location, $message = null) {
if (isset($message)) {
restart_session();
- $_SESSION["messages"][] = $message;
+ $_SESSION["messages"][preg_replace('~^[^?]*/~', '', $location)][] = $message;
}
if (isset($location)) {
if ($location == "") {

0 comments on commit 79fa7da

Please sign in to comment.