]> git.joonet.de Git - adminer.git/commitdiff
Don't update unmodified blob (thanks to crempa)
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Wed, 4 Mar 2009 17:22:28 +0000 (17:22 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Wed, 4 Mar 2009 17:22:28 +0000 (17:22 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@563 7c3ca157-0c34-0410-bff1-cbf682f78f5c

edit.inc.php
editing.inc.php

index 7b1446797ecd91b9f3dff1825ba94f17e94dfb2d..bf6c26a6ca7e840e212fee9475f40870c5fb549f 100644 (file)
@@ -15,10 +15,12 @@ if ($_POST && !$error && !isset($_GET["select"])) {
                $set = array();
                foreach ($fields as $name => $field) {
                        $val = process_input($name, $field);
-                       if ($val !== false) {
-                               if (!isset($_GET["default"])) {
-                                       $set[] = idf_escape($name) . " = $val";
-                               } elseif ($field["type"] == "timestamp") {
+                       if (!isset($_GET["default"])) {
+                               if ($val !== false || !$update) {
+                                       $set[] = idf_escape($name) . " = " . ($val !== false ? $val : "''");
+                               }
+                       } 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" : "");
                                } else {
                                        $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) {
        $select = array();
        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);
                }
        }
index 2e10d02ba82ab945cfca8b554ed89fb261968855..ac37f3558a70590d6c1a9be4c3674a73dc8843a7 100644 (file)
@@ -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));
        } elseif (preg_match('~binary|blob~', $field["type"])) {
                $file = get_file($idf);
-               if (!is_string($file) && ($file != UPLOAD_ERR_NO_FILE || !$field["null"])) {
+               if (!is_string($file)) {
                        return false; //! report errors
                }
                return "_binary'" . (is_string($file) ? $mysql->escape_string($file) : "") . "'";