aboutsummaryrefslogtreecommitdiffstats
path: root/include
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 /include
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 !!
Diffstat (limited to 'include')
-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
5 files changed, 60 insertions, 27 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');
}