return xmlify($o);
}
+function add_guid($item) {
+ $r = q("SELECT `guid` FROM `guid` WHERE `guid` = '%s' LIMIT 1", dbesc($item["guid"]));
+ if ($r)
+ return;
+ q("INSERT INTO `guid` (`guid`,`plink`,`uri`,`network`) VALUES ('%s','%s','%s','%s')",
+ dbesc($item["guid"]), dbesc($item["plink"]),
+ dbesc($item["uri"]), dbesc($item["network"]));
+}
function item_store($arr,$force_parent = false, $notify = false, $dontcache = false) {
}
}
}
-/*
+
// If there is no guid then take the same guid that was taken before for the same uri
- if ((trim($arr['guid']) == "") AND (trim($arr['uri']) != "")) {
+ if ((trim($arr['guid']) == "") AND (trim($arr['uri']) != "") AND (trim($arr['network']) != "")) {
logger('item_store: checking for an existing guid for uri '.$arr['uri'], LOGGER_DEBUG);
- $r = q("SELECT `guid` FROM `item` WHERE `uri` = '%s' AND `guid` != '' LIMIT 1",
- dbesc(trim($arr['uri']))
- );
+ $r = q("SELECT `guid` FROM `guid` WHERE `uri` = '%s' AND `network` = '%s' LIMIT 1",
+ dbesc(trim($arr['uri'])), dbesc(trim($arr['network'])));
if(count($r)) {
$arr['guid'] = $r[0]["guid"];
}
// If there is no guid then take the same guid that was taken before for the same plink
- if ((trim($arr['guid']) == "") AND (trim($arr['plink']) != "")) {
+ if ((trim($arr['guid']) == "") AND (trim($arr['plink']) != "") AND (trim($arr['network']) != "")) {
logger('item_store: checking for an existing guid for plink '.$arr['plink'], LOGGER_DEBUG);
- $r = q("SELECT `guid` FROM `item` WHERE `plink` = '%s' AND `guid` != '' LIMIT 1",
- dbesc(trim($arr['plink']))
- );
+ $r = q("SELECT `guid` FROM `guid` WHERE `plink` = '%s' AND `network` = '%s' LIMIT 1",
+ dbesc(trim($arr['plink'])), dbesc(trim($arr['network'])));
if(count($r)) {
$arr['guid'] = $r[0]["guid"];
logger('item_store: found guid '.$arr['guid'].' for plink '.$arr['plink'], LOGGER_DEBUG);
}
}
-*/
+
// Shouldn't happen but we want to make absolutely sure it doesn't leak from a plugin.
// Deactivated, since the bbcode parser can handle with it - and it destroys posts with some smileys that contain "<"
//if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
);
if(count($r)) {
+
+ // Store the guid and other relevant data
+ add_guid($arr);
+
$current_post = $r[0]['id'];
logger('item_store: created item ' . $current_post);