Merge remote-tracking branch 'upstream/develop' into bugfix-sql-date

This commit is contained in:
Michael
2017-02-23 06:54:50 +00:00
3 changed files with 72 additions and 28 deletions
+9 -4
View File
@@ -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;
}
+15 -1
View File
@@ -27,13 +27,27 @@ function spool_post_run($argv, $argc) {
$path = get_spoolpath();
if (is_writable($path)){
if (($path != '') AND is_writable($path)){
if ($dh = opendir($path)) {
while (($file = readdir($dh)) !== false) {
// It is not named like a spool file, so we don't care.
if (substr($file, 0, 5) != "item-") {
continue;
}
$fullfile = $path."/".$file;
// We don't care about directories either
if (filetype($fullfile) != "file") {
continue;
}
// We can't read or write the file? So we don't care about it.
if (!is_writable($fullfile) OR !is_readable($fullfile)) {
continue;
}
$arr = json_decode(file_get_contents($fullfile), true);
// If it isn't an array then it is no spool file