Don't update unmodified blob (thanks to crempa)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@563 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
3b17d67e9a
commit
19e4d597c4
12
edit.inc.php
12
edit.inc.php
|
@ -15,10 +15,12 @@ if ($_POST && !$error && !isset($_GET["select"])) {
|
||||||
$set = array();
|
$set = array();
|
||||||
foreach ($fields as $name => $field) {
|
foreach ($fields as $name => $field) {
|
||||||
$val = process_input($name, $field);
|
$val = process_input($name, $field);
|
||||||
if ($val !== false) {
|
if (!isset($_GET["default"])) {
|
||||||
if (!isset($_GET["default"])) {
|
if ($val !== false || !$update) {
|
||||||
$set[] = idf_escape($name) . " = $val";
|
$set[] = idf_escape($name) . " = " . ($val !== false ? $val : "''");
|
||||||
} elseif ($field["type"] == "timestamp") {
|
}
|
||||||
|
} elseif ($val !== false) {
|
||||||
|
if ($field["type"] == "timestamp") {
|
||||||
$set[] = " MODIFY " . idf_escape($name) . " timestamp" . ($field["null"] ? " NULL" : "") . " DEFAULT $val" . ($_POST["on_update"][bracket_escape($name)] ? " ON UPDATE CURRENT_TIMESTAMP" : "");
|
$set[] = " MODIFY " . idf_escape($name) . " timestamp" . ($field["null"] ? " NULL" : "") . " DEFAULT $val" . ($_POST["on_update"][bracket_escape($name)] ? " ON UPDATE CURRENT_TIMESTAMP" : "");
|
||||||
} else {
|
} else {
|
||||||
$set[] = " ALTER " . idf_escape($name) . ($val == ($field["null"] || $field["type"] == "enum" ? "NULL" : "''") ? " DROP DEFAULT" : " SET DEFAULT $val");
|
$set[] = " ALTER " . idf_escape($name) . ($val == ($field["null"] || $field["type"] == "enum" ? "NULL" : "''") ? " DROP DEFAULT" : " SET DEFAULT $val");
|
||||||
|
@ -45,7 +47,7 @@ if ($_POST) {
|
||||||
} elseif ($where) {
|
} elseif ($where) {
|
||||||
$select = array();
|
$select = array();
|
||||||
foreach ($fields as $name => $field) {
|
foreach ($fields as $name => $field) {
|
||||||
if (isset($field["privileges"]["select"]) && !preg_match('~binary|blob~', $field["type"]) && (!$_GET["clone"] || !$field["auto_increment"])) {
|
if (isset($field["privileges"]["select"]) && (!$_GET["clone"] || !$field["auto_increment"])) {
|
||||||
$select[] = ($field["type"] == "enum" || $field["type"] == "set" ? "1*" . idf_escape($name) . " AS " : "") . idf_escape($name);
|
$select[] = ($field["type"] == "enum" || $field["type"] == "set" ? "1*" . idf_escape($name) . " AS " : "") . idf_escape($name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ function process_input($name, $field) {
|
||||||
return (isset($_GET["default"]) ? "'" . implode(",", array_map(array($mysql, 'escape_string'), (array) $value)) . "'" : array_sum((array) $value));
|
return (isset($_GET["default"]) ? "'" . implode(",", array_map(array($mysql, 'escape_string'), (array) $value)) . "'" : array_sum((array) $value));
|
||||||
} elseif (preg_match('~binary|blob~', $field["type"])) {
|
} elseif (preg_match('~binary|blob~', $field["type"])) {
|
||||||
$file = get_file($idf);
|
$file = get_file($idf);
|
||||||
if (!is_string($file) && ($file != UPLOAD_ERR_NO_FILE || !$field["null"])) {
|
if (!is_string($file)) {
|
||||||
return false; //! report errors
|
return false; //! report errors
|
||||||
}
|
}
|
||||||
return "_binary'" . (is_string($file) ? $mysql->escape_string($file) : "") . "'";
|
return "_binary'" . (is_string($file) ? $mysql->escape_string($file) : "") . "'";
|
||||||
|
|
Loading…
Reference in a new issue