X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fitems.php;h=0445c4490cb97f1f6ff446837f25dd4724c05107;hb=3d4e1176ec9b18e9e7547b91d36554f2375ddb8e;hp=e9354b62d3eda2906753cb6641259640294ba856;hpb=0ef764b167336eb1ea559b77712a84940bfc8826;p=friendica.git diff --git a/include/items.php b/include/items.php index e9354b62d3..0445c4490c 100644 --- a/include/items.php +++ b/include/items.php @@ -417,6 +417,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa $dsprsig = null; if (x($arr,'dsprsig')) { + $encoded_signature = $arr['dsprsig']; $dsprsig = json_decode(base64_decode($arr['dsprsig'])); unset($arr['dsprsig']); } @@ -845,15 +846,27 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa } } else { // This can happen - for example - if there are locking timeouts. - logger("Item wasn't stored - we quit here."); - q("COMMIT"); + q("ROLLBACK"); + + // Store the data into a spool file so that we can try again later. + + // At first we restore the Diaspora signature that we removed above. + if (isset($encoded_signature)) { + $arr['dsprsig'] = $encoded_signature; + } + + // 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); return 0; } if ($current_post == 0) { // This is one of these error messages that never should occur. logger("couldn't find created item - we better quit now."); - q("COMMIT"); + q("ROLLBACK"); return 0; } @@ -868,7 +881,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa if (!dbm::is_result($r)) { // This shouldn't happen, since COUNT always works when the database connection is there. logger("We couldn't count the stored entries. Very strange ..."); - q("COMMIT"); + q("ROLLBACK"); return 0; } @@ -883,7 +896,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa } elseif ($r[0]["entries"] == 0) { // This really should never happen since we quit earlier if there were problems. logger("Something is terribly wrong. We haven't found our created entry."); - q("COMMIT"); + q("ROLLBACK"); return 0; }