]> git.mxchange.org Git - friendica.git/blobdiff - include/items.php
Merge pull request #2916 from tobiasd/20160925-changes
[friendica.git] / include / items.php
index fa4f3290b142090168fbd36222e13d9f4b75840f..24eb1b30fb7b97c823238d2a2989b9d9413b589e 100644 (file)
@@ -820,7 +820,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
        // Store the unescaped version
        $unescaped = $arr;
 
-       dbesc_array($arr);
+       dbm::esc_array($arr, true);
 
        logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
 
@@ -829,9 +829,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
 
        $r = dbq("INSERT INTO `item` (`"
                        . implode("`, `", array_keys($arr))
-                       . "`) VALUES ('"
-                       . implode("', '", array_values($arr))
-                       . "')");
+                       . "`) VALUES ("
+                       . implode("", array_values($arr))
+                       . ")");
 
        // And restore it
        $arr = $unescaped;
@@ -857,10 +857,15 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
                }
 
                // Now we store the data in the spool directory
-               $file = 'item-'.round(microtime(true) * 10000).".msg";
-               $spool = get_spoolpath().'/'.$file;
-               file_put_contents($spool, json_encode($arr));
-               logger("Item wasn't stored - Item was spooled into file ".$file, LOGGER_DEBUG);
+               // We use "microtime" to keep the arrival order and "mt_rand" to avoid duplicates
+               $file = 'item-'.round(microtime(true) * 10000).'-'.mt_rand().'.msg';
+
+               $spoolpath = get_spoolpath();
+               if ($spoolpath != "") {
+                       $spool = $spoolpath.'/'.$file;
+                       file_put_contents($spool, json_encode($arr));
+                       logger("Item wasn't stored - Item was spooled into file ".$file, LOGGER_DEBUG);
+               }
                return 0;
        }