aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-09-10 19:06:06 -0700
committerfriendica <info@friendica.com>2013-09-10 19:06:06 -0700
commit3e5414cf35f3781297490e058c6d366bca45748e (patch)
tree3b317e302652df514c3fe7f1471c14932b1b67db
parent7ada499ca9a1424a59204d87edb5856f88a79b59 (diff)
downloadvolse-hubzilla-3e5414cf35f3781297490e058c6d366bca45748e.tar.gz
volse-hubzilla-3e5414cf35f3781297490e058c6d366bca45748e.tar.bz2
volse-hubzilla-3e5414cf35f3781297490e058c6d366bca45748e.zip
provide detailed error to remote site for the myriad of things that can go wrong inside item_store(), !! this changes the return of item_store !!
-rw-r--r--include/activities.php3
-rw-r--r--include/event.php3
-rwxr-xr-xinclude/items.php63
-rw-r--r--include/photos.php6
-rw-r--r--include/zot.php12
-rw-r--r--mod/item.php3
-rwxr-xr-xmod/like.php3
-rwxr-xr-xmod/mood.php4
-rw-r--r--mod/photos.php4
-rwxr-xr-xmod/subthread.php3
10 files changed, 72 insertions, 32 deletions
diff --git a/include/activities.php b/include/activities.php
index 7ef26abeb..73180eae0 100644
--- a/include/activities.php
+++ b/include/activities.php
@@ -75,7 +75,8 @@ function profile_activity($changed, $value) {
$arr['deny_cid'] = $self['channel_deny_cid'];
$arr['deny_gid'] = $self['channel_deny_gid'];
- $i = item_store($arr);
+ $res = item_store($arr);
+ $i = $res['item_id'];
if($i) {
// FIXME - limit delivery in notifier.php to those specificed in the perms argument
diff --git a/include/event.php b/include/event.php
index 29ada2e96..7873de1ef 100644
--- a/include/event.php
+++ b/include/event.php
@@ -360,7 +360,8 @@ function event_store($arr) {
}
- $item_id = item_store($item_arr);
+ $res = item_store($item_arr);
+ $item_id = $res['item_id'];
call_hooks("event_created", $event['id']);
diff --git a/include/items.php b/include/items.php
index cd3ef7f68..2648a0629 100755
--- a/include/items.php
+++ b/include/items.php
@@ -193,7 +193,9 @@ function post_activity_item($arr) {
}
- $post_id = item_store($arr);
+ $post = item_store($arr);
+ if($post['result'])
+ $post_id = $post['item_id'];
if($post_id) {
$arr['id'] = $post_id;
@@ -1365,9 +1367,12 @@ function encode_rel_links($links) {
function item_store($arr,$allow_exec = false) {
+ $ret = array('result' => false, 'item_id' => 0);
+
if(! $arr['uid']) {
logger('item_store: no uid');
- return 0;
+ $ret['message'] = 'No uid.';
+ return ret;
}
// If a page layout is provided, ensure it exists and belongs to us.
@@ -1392,7 +1397,8 @@ function item_store($arr,$allow_exec = false) {
if(($arr['mimetype'] == 'application/x-php') && (! $allow_exec)) {
logger('item_store: php mimetype but allow_exec is denied.');
- return 0;
+ $ret['message'] = 'exec denied.';
+ return $ret;
}
@@ -1424,7 +1430,8 @@ function item_store($arr,$allow_exec = false) {
call_hooks('item_translate', $translate);
if((! $translate['translated']) && (intval(get_pconfig($arr['uid'],'system','reject_disallowed_languages')))) {
logger('item_store: language ' . $arr['lang'] . ' not accepted for uid ' . $arr['uid']);
- return;
+ $ret['message'] = 'language not accepted';
+ return $ret;
}
$arr = $translate['item'];
}
@@ -1570,7 +1577,8 @@ function item_store($arr,$allow_exec = false) {
}
else {
logger('item_store: item parent was not found - ignoring item');
- return 0;
+ $ret['message'] = 'parent not found.';
+ return $ret;
}
}
@@ -1584,14 +1592,16 @@ function item_store($arr,$allow_exec = false) {
);
if($r) {
logger('item-store: duplicate item ignored. ' . print_r($arr,true));
- return 0;
+ $ret['message'] = 'duplicate post.';
+ return $ret;
}
call_hooks('post_remote',$arr);
if(x($arr,'cancel')) {
logger('item_store: post cancelled by plugin.');
- return 0;
+ $ret['message'] = 'cancelled.';
+ return $ret;
}
// pull out all the taxonomy stuff for separate storage
@@ -1625,7 +1635,8 @@ function item_store($arr,$allow_exec = false) {
}
else {
logger('item_store: could not locate created item');
- return 0;
+ $ret['message'] = 'unable to retrieve.';
+ return $ret;
}
if(count($r) > 1) {
logger('item_store: duplicated post occurred. Removing duplicates.');
@@ -1697,21 +1708,26 @@ function item_store($arr,$allow_exec = false) {
send_status_notifications($current_post,$arr);
tag_deliver($arr['uid'],$current_post);
+ $ret['success'] = true;
+ $ret['item_id'] = $current_post;
- return $current_post;
+ return $ret;
}
function item_store_update($arr,$allow_exec = false) {
+ $ret = array('result' => false, 'item_id' => 0);
if(! intval($arr['uid'])) {
logger('item_store_update: no uid');
- return 0;
+ $ret['message'] = 'no uid.';
+ return $ret;
}
if(! intval($arr['id'])) {
logger('item_store_update: no id');
- return 0;
+ $ret['message'] = 'no id.';
+ return $ret;
}
$orig_post_id = $arr['id'];
@@ -1729,7 +1745,8 @@ function item_store_update($arr,$allow_exec = false) {
call_hooks('item_translate', $translate);
if((! $translate['translated']) && (intval(get_pconfig($arr['uid'],'system','reject_disallowed_languages')))) {
logger('item_store: language ' . $arr['lang'] . ' not accepted for uid ' . $arr['uid']);
- return;
+ $ret['message'] = 'language not accepted';
+ return $ret;
}
$arr = $translate['item'];
}
@@ -1738,7 +1755,8 @@ function item_store_update($arr,$allow_exec = false) {
if(($arr['mimetype'] == 'application/x-php') && (! $allow_exec)) {
logger('item_store: php mimetype but allow_exec is denied.');
- return 0;
+ $ret['message'] = 'exec denied.';
+ return $ret;
}
@@ -1771,7 +1789,8 @@ function item_store_update($arr,$allow_exec = false) {
);
if(! $orig) {
logger('item_store_update: original post not found: ' . $orig_post_id);
- return 0;
+ $ret['message'] = 'no original';
+ return $ret;
}
unset($arr['aid']);
@@ -1814,7 +1833,8 @@ function item_store_update($arr,$allow_exec = false) {
if(x($arr,'cancel')) {
logger('item_store_update: post cancelled by plugin.');
- return 0;
+ $ret['message'] = 'cancelled.';
+ return $ret;
}
// pull out all the taxonomy stuff for separate storage
@@ -1842,7 +1862,8 @@ function item_store_update($arr,$allow_exec = false) {
logger('item_store_update: updated item ' . $orig_post_id, LOGGER_DEBUG);
else {
logger('item_store_update: could not update item');
- return 0;
+ $ret['message'] = 'DB update failed.';
+ return $ret;
}
$r = q("delete from term where oid = %d and otype = %d",
@@ -1871,8 +1892,10 @@ function item_store_update($arr,$allow_exec = false) {
send_status_notifications($orig_post_id,$arr);
tag_deliver($uid,$orig_post_id);
+ $ret['success'] = true;
+ $ret['item_id'] = $orig_post_id;
- return $orig_post_id;
+ return $ret;
}
@@ -2749,7 +2772,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
}
}
- $r = item_store($datarray);
+ $xx = item_store($datarray);
+ $r = $xx['item_id'];
continue;
}
@@ -2879,7 +2903,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
continue;
- $r = item_store($datarray);
+ $xx = item_store($datarray);
+ $r = $xx['item_id'];
continue;
}
diff --git a/include/photos.php b/include/photos.php
index c670bd90c..517212e57 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -222,7 +222,8 @@ function photo_upload($channel, $observer, $args) {
. '[zmg]' . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]'
. '[/zrl]';
- $item_id = item_store($arr);
+ $result = item_store($arr);
+ $item_id = $result['item_id'];
if($visible)
proc_run('php', "include/notifier.php", 'wall-new', $item_id);
@@ -402,7 +403,8 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
. '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/zmg]'
. '[/zrl]';
- $item_id = item_store($arr);
+ $result = item_store($arr);
+ $item_id = $result['item_id'];
return $item_id;
} \ No newline at end of file
diff --git a/include/zot.php b/include/zot.php
index e9084496c..6deee4d52 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -1154,8 +1154,9 @@ function process_delivery($sender,$arr,$deliveries,$relay) {
else {
$arr['aid'] = $channel['channel_account_id'];
$arr['uid'] = $channel['channel_id'];
- $item_id = item_store($arr);
- $result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed'),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>');
+ $item_result = item_store($arr);
+ $item_id = $item_result['item_id'];
+ $result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed:' . $item_result['message']),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>');
}
if($relay && $item_id) {
@@ -1238,8 +1239,11 @@ function remove_community_tag($sender,$arr,$uid) {
function update_imported_item($sender,$item,$uid) {
- item_store_update($item);
- logger('update_imported_item');
+ $x = item_store_update($item);
+ if(! $x['item_id'])
+ logger('update_imported_item: failed: ' . $x['message']);
+ else
+ logger('update_imported_item');
}
diff --git a/mod/item.php b/mod/item.php
index fd93d1dff..367a0c4be 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -689,7 +689,8 @@ function item_post(&$a) {
$post_id = 0;
- $post_id = item_store($datarray,$execflag);
+ $post = item_store($datarray,$execflag);
+ $post_id = $post['item_id'];
if($post_id) {
logger('mod_item: saved item ' . $post_id);
diff --git a/mod/like.php b/mod/like.php
index 0de65f129..84b0a6592 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -171,7 +171,8 @@ function like_content(&$a) {
$arr['deny_cid'] = $item['deny_cid'];
$arr['deny_gid'] = $item['deny_gid'];
- $post_id = item_store($arr);
+ $post = item_store($arr);
+ $post_id = $post['item_id'];
$arr['id'] = $post_id;
diff --git a/mod/mood.php b/mod/mood.php
index 7b6a0c392..83b8bfb57 100755
--- a/mod/mood.php
+++ b/mod/mood.php
@@ -84,7 +84,9 @@ function mood_init(&$a) {
$arr['verb'] = $activity;
$arr['body'] = $action;
- $item_id = item_store($arr);
+ $post = item_store($arr);
+ $item_id = $post['item_id'];
+
if($item_id) {
// q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
// dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
diff --git a/mod/photos.php b/mod/photos.php
index 7da3d3e92..d60029688 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -506,7 +506,9 @@ function photos_post(&$a) {
. $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource_id'] . '</id>';
$arr['target'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource_id'] . '" />' . "\n" . '<link rel="preview" type="'.$p[0]['type'].'" href="' . $a->get_baseurl() . "/photo/" . $p[0]['resource_id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
- $item_id = item_store($arr);
+ $post = item_store($arr);
+ $item_id = $post['item_id'];
+
if($item_id) {
q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
diff --git a/mod/subthread.php b/mod/subthread.php
index 66dc86eb2..11b7236fb 100755
--- a/mod/subthread.php
+++ b/mod/subthread.php
@@ -142,7 +142,8 @@ EOT;
$arr['unseen'] = 1;
$arr['last-child'] = 0;
- $post_id = item_store($arr);
+ $post = item_store($arr);
+ $post_id = $post['item_id'];
if(! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",