aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/items.php20
-rw-r--r--include/notifier.php43
2 files changed, 39 insertions, 24 deletions
diff --git a/include/items.php b/include/items.php
index 45d8b62c0..359378ff7 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 {
@@ -739,10 +740,10 @@ function item_store($arr,$force_parent = false) {
return 0;
}
- if($arr['parent-uri'] === $arr['uri'])
+ if((! $parent_id) || ($arr['parent-uri'] === $arr['uri']))
$parent_id = $current_post;
-
- if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid))
+
+ if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid))
$private = 1;
else
$private = $arr['private'];
@@ -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..07bde7c4d 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;