diff options
author | Friendika <info@friendika.com> | 2011-02-04 04:25:53 -0800 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-02-04 04:25:53 -0800 |
commit | 2a9bfae2b7341ebe4d420c627867160c7e1427d9 (patch) | |
tree | f2791a2e6302d57c9478863a2efc16abaa9a7f64 /include | |
parent | 5c98032893d945644c6da6bdf99484c0c8cb7e45 (diff) | |
download | volse-hubzilla-2a9bfae2b7341ebe4d420c627867160c7e1427d9.tar.gz volse-hubzilla-2a9bfae2b7341ebe4d420c627867160c7e1427d9.tar.bz2 volse-hubzilla-2a9bfae2b7341ebe4d420c627867160c7e1427d9.zip |
prevent runaway notifications when parent=0 due to race condition
Diffstat (limited to 'include')
-rw-r--r-- | include/items.php | 14 | ||||
-rw-r--r-- | include/notifier.php | 43 |
2 files changed, 36 insertions, 21 deletions
diff --git a/include/items.php b/include/items.php index 45d8b62c0..0c9d4cfc2 100644 --- a/include/items.php +++ b/include/items.php @@ -688,11 +688,12 @@ function item_store($arr,$force_parent = false) { $arr['parent-uri'] = $r[0]['parent-uri']; } - $parent_id = $r[0]['id']; - $allow_cid = $r[0]['allow_cid']; - $allow_gid = $r[0]['allow_gid']; - $deny_cid = $r[0]['deny_cid']; - $deny_gid = $r[0]['deny_gid']; + $parent_id = $r[0]['id']; + $parent_deleted = $r[0]['deleted']; + $allow_cid = $r[0]['allow_cid']; + $allow_gid = $r[0]['allow_gid']; + $deny_cid = $r[0]['deny_cid']; + $deny_gid = $r[0]['deny_gid']; } else { @@ -750,13 +751,14 @@ function item_store($arr,$force_parent = false) { // Set parent id - and also make sure to inherit the parent's ACL's. $r = q("UPDATE `item` SET `parent` = %d, `allow_cid` = '%s', `allow_gid` = '%s', - `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d WHERE `id` = %d LIMIT 1", + `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d, `deleted` = $d WHERE `id` = %d LIMIT 1", intval($parent_id), dbesc($allow_cid), dbesc($allow_gid), dbesc($deny_cid), dbesc($deny_gid), intval($private), + intval($parent_deleted), intval($current_post) ); diff --git a/include/notifier.php b/include/notifier.php index 8442349cf..a71da853d 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -2,18 +2,18 @@ require_once("boot.php"); function notifier_run($argv, $argc){ - global $a, $db; + global $a, $db; - if(is_null($a)){ - $a = new App; - } + if(is_null($a)){ + $a = new App; + } - if(is_null($db)){ - @include(".htconfig.php"); - require_once("dba.php"); - $db = new dba($db_host, $db_user, $db_pass, $db_data); - unset($db_host, $db_user, $db_pass, $db_data); - }; + if(is_null($db)) { + @include(".htconfig.php"); + require_once("dba.php"); + $db = new dba($db_host, $db_user, $db_pass, $db_data); + unset($db_host, $db_user, $db_pass, $db_data); + } require_once("session.php"); require_once("datetime.php"); @@ -62,11 +62,12 @@ function notifier_run($argv, $argc){ $r = q("SELECT `parent`, `uid`, `edited` FROM `item` WHERE `id` = %d LIMIT 1", intval($item_id) ); - if(! count($r)){ + + if((! count($r)) || (! intval($r[0]['parent']))) { return; } - - $parent_id = $r[0]['parent']; + + $parent_id = intval($r[0]['parent']); $uid = $r[0]['uid']; $updated = $r[0]['edited']; @@ -77,6 +78,13 @@ function notifier_run($argv, $argc){ if(! count($items)){ return; } + + // avoid race condition with deleting entries + + if($items[0]['deleted']) { + foreach($items as $item) + $item['deleted'] = 1; + } $r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, `user`.`page-flags` @@ -122,8 +130,8 @@ function notifier_run($argv, $argc){ $allow_people = expand_acl($parent['allow_cid']); $allow_groups = expand_groups(expand_acl($parent['allow_gid'])); - $deny_people = expand_acl($parent['deny_cid']); - $deny_groups = expand_groups(expand_acl($parent['deny_gid'])); + $deny_people = expand_acl($parent['deny_cid']); + $deny_groups = expand_groups(expand_acl($parent['deny_gid'])); $conversants = array(); @@ -220,6 +228,8 @@ function notifier_run($argv, $argc){ else { if($followup) { foreach($items as $item) { // there is only one item + if(! $item['parent']) + continue; if($item['id'] == $item_id) { logger('notifier: followup: item: ' . print_r($item,true), LOGGER_DATA); $slap = atom_entry($item,'html',$owner,$owner,false); @@ -229,6 +239,9 @@ function notifier_run($argv, $argc){ } else { foreach($items as $item) { + if(! $item['parent']) + continue; + $contact = get_item_contact($item,$contacts); if(! $contact) continue; |