Author: arekm                        Date: Thu Jun 29 11:00:10 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- new

---- Files affected:
SOURCES:
   database_autoincrement_corruption.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/database_autoincrement_corruption.patch
diff -u /dev/null SOURCES/database_autoincrement_corruption.patch:1.1
--- /dev/null   Thu Jun 29 13:00:10 2006
+++ SOURCES/database_autoincrement_corruption.patch     Thu Jun 29 13:00:05 2006
@@ -0,0 +1,28 @@
+diff -ruBbd cacti-0.8.6h/lib/database.php cacti-0.8.6h-patched/lib/database.php
+--- cacti-0.8.6h/lib/database.php      2006-04-24 20:07:11.000000000 -0400
++++ cacti-0.8.6h-patched/lib/database.php      2006-04-24 20:04:26.000000000 
-0400
+@@ -214,17 +214,21 @@
+    @arg $table_name - the name of the table to make the replacement in
+    @arg $key_cols - the primary key(s)
+    @returns - the auto incriment id column (if applicable) */
+-function sql_save($array_items, $table_name, $key_cols = "id", $autoinc = 
TRUE) {
++function sql_save($array_items, $table_name, $key_cols = "id", $autoinc = 
true) {
+       global $cnn_id;
+ 
+       while (list ($key, $value) = each ($array_items)) {
+               $array_items[$key] = "\"" . sql_sanitize($value) . "\"";
+       }
+ 
+-      if (!$cnn_id->Replace($table_name, $array_items, $key_cols, FALSE, 
$autoinc)) { return 0; }
++      $replace_result = $cnn_id->Replace($table_name, $array_items, 
$key_cols, FALSE, $autoinc);
++
++      if ($replace_result == 0) {
++              return 0;
++      }
+ 
+       /* get the last AUTO_ID and return it */
+-      if ($cnn_id->Insert_ID() == "0") {
++      if (($cnn_id->Insert_ID() == "0") || ($replace_result == 1)) {
+               if (!is_array($key_cols)) {
+                       if (isset($array_items[$key_cols])) {
+                               return str_replace("\"", "", 
$array_items[$key_cols]);
================================================================
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to