diff options
author | friendica <info@friendica.com> | 2015-01-21 16:06:25 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2015-01-21 16:06:25 -0800 |
commit | 29436081a86650e7905a79eba4fdf7dc12f1c7c9 (patch) | |
tree | 2f7e69d1cd55267bdc9eb604d1084e3d2f6ebc88 /include | |
parent | 51848c619080e19cace647966a17eb9a1b42ca25 (diff) | |
download | volse-hubzilla-29436081a86650e7905a79eba4fdf7dc12f1c7c9.tar.gz volse-hubzilla-29436081a86650e7905a79eba4fdf7dc12f1c7c9.tar.bz2 volse-hubzilla-29436081a86650e7905a79eba4fdf7dc12f1c7c9.zip |
slow progress removing bitfields on item table
Diffstat (limited to 'include')
-rw-r--r-- | include/Import/refimport.php | 8 | ||||
-rw-r--r-- | include/activities.php | 5 | ||||
-rw-r--r-- | include/attach.php | 9 | ||||
-rw-r--r-- | include/bb2diaspora.php | 16 | ||||
-rwxr-xr-x | include/diaspora.php | 15 | ||||
-rw-r--r-- | include/event.php | 54 | ||||
-rw-r--r-- | include/externals.php | 20 | ||||
-rwxr-xr-x | include/items.php | 27 | ||||
-rw-r--r-- | include/notifier.php | 3 | ||||
-rw-r--r-- | include/photos.php | 76 | ||||
-rw-r--r-- | include/zot.php | 2 |
11 files changed, 103 insertions, 132 deletions
diff --git a/include/Import/refimport.php b/include/Import/refimport.php index 181b2b398..a7c0ef4c8 100644 --- a/include/Import/refimport.php +++ b/include/Import/refimport.php @@ -88,7 +88,10 @@ function refimport_content(&$a) { $arr['author_xchan'] = $channel['channel_hash']; $arr['owner_xchan'] = $channel['channel_hash']; $arr['app'] = REFLECT_BLOGNAME; - $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL|ITEM_THREAD_TOP; + $arr['item_origin'] = 1; + $arr['item_wall'] = 1; + $arr['item_thread_top'] = 1; + $arr['verb'] = ACTIVITY_POST; // this is an assumption @@ -256,7 +259,8 @@ function reflect_comment_store($channel,$post,$comment,$user) { $arr['edited'] = $comment['created']; $arr['author_xchan'] = $hash; $arr['owner_xchan'] = $channel['channel_hash']; - $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL; + $arr['item_origin'] = 1; + $arr['item_wall'] = 1; $arr['verb'] = ACTIVITY_POST; $arr['comment_policy'] = 'contacts'; diff --git a/include/activities.php b/include/activities.php index d770ccb23..ba12bc5d1 100644 --- a/include/activities.php +++ b/include/activities.php @@ -21,7 +21,10 @@ function profile_activity($changed, $value) { $arr['uid'] = local_user(); $arr['aid'] = $self['channel_account_id']; $arr['owner_xchan'] = $arr['author_xchan'] = $self['xchan_hash']; - $arr['item_flags'] = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; + $arr['item_wall'] = 1; + $arr['item_origin'] = 1; + $arr['item_thread_top'] = 1; + $arr['verb'] = ACTIVITY_UPDATE; $arr['obj_type'] = ACTIVITY_OBJ_PROFILE; diff --git a/include/attach.php b/include/attach.php index 5ef3bea24..5a945dd66 100644 --- a/include/attach.php +++ b/include/attach.php @@ -954,7 +954,9 @@ function file_activity($channel_id, $hash, $allow_cid, $allow_gid, $deny_cid, $d $mid = item_message_id(); - $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_UNSEEN; + $arr['item_wall'] = 1; + $arr['item_origin'] = 1; + $arr['item_unseen'] = 1; if($action == 'post') { //check if activity item exists @@ -975,7 +977,6 @@ function file_activity($channel_id, $hash, $allow_cid, $allow_gid, $deny_cid, $d $arr['uid'] = $channel_id; $arr['mid'] = $dmid; $arr['parent_mid'] = $dmid; - $arr['item_flags'] = $item_flags; $arr['author_xchan'] = $poster['xchan_hash']; $arr['owner_xchan'] = $poster['xchan_hash']; $arr['title'] = ''; @@ -1016,7 +1017,9 @@ function file_activity($channel_id, $hash, $allow_cid, $allow_gid, $deny_cid, $d $arr['uid'] = $channel_id; $arr['mid'] = $mid; $arr['parent_mid'] = $mid; - $arr['item_flags'] = $item_flags; + $arr['item_wall'] = 1; + $arr['item_origin'] = 1; + $arr['item_unseen'] = 1; $arr['author_xchan'] = $poster['xchan_hash']; $arr['owner_xchan'] = $poster['xchan_hash']; $arr['title'] = ''; diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 5c93ac3aa..e8f81aec4 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -271,22 +271,6 @@ function bb2diaspora_itemwallwall(&$item) { . $item['body']; } - // We have to do something similar for wall-to-wall comments. ITEM_WALL|ITEM_ORIGIN indicates that it was posted on this site. - // Regular matrix comments may have one of these bits set, but not both. - - // Update: this is getting triggered way too often and unnecessarily. Commenting out until we find a better solution. - // It's not an easy problem. For now we'll live with the mis-attributions, as wall to wall comments are much less frequent - // than wall-to-wall posts. - -// if(($item['mid'] != $item['parent_mid']) && ($item['author_xchan'] != $item['owner_xchan']) && (($item['item_flags'] & (ITEM_WALL|ITEM_ORIGIN)) == (ITEM_WALL|ITEM_ORIGIN)) && (is_array($item['author'])) && $item['author']['xchan_url'] && $item['author']['xchan_name'] && $item['author']['xchan_photo_m']) { -// logger('bb2diaspora_itemwallwall: wall to wall comment',LOGGER_DEBUG); - // post will come across with the owner's identity. Throw a preamble onto the post to indicate the true author. -// $item['body'] = "\n\n" -// . '[img]' . $item['author']['xchan_photo_m'] . '[/img]' -// . '[url=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/url]' . "\n\n" -// . $item['body']; -// } - // $item['author'] might cause a surprise further down the line if it wasn't expected to be here. if(! $author_exists) diff --git a/include/diaspora.php b/include/diaspora.php index e494aac0f..ae405f663 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1414,7 +1414,7 @@ function diaspora_comment($importer,$xml,$msg) { if($result && $result['success']) $message_id = $result['item_id']; - if(($parent_item['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature)) { + if(intval($parent_item['item_origin']) && (! $parent_author_signature)) { // if the message isn't already being relayed, notify others // the existence of parent_author_signature means the parent_author or owner // is already relaying. @@ -1996,7 +1996,7 @@ function diaspora_like($importer,$xml,$msg) { // the existence of parent_author_signature means the parent_author or owner // is already relaying. The parent_item['origin'] indicates the message was created on our system - if(($parent_item['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature)) + if(intval($parent_item['item_origin']) && (! $parent_author_signature)) proc_run('php','include/notifier.php','comment-import',$message_id); return; @@ -2105,19 +2105,12 @@ function diaspora_signed_retraction($importer,$xml,$msg) { $r[0]['parent'] ); if($p) { - if(($p[0]['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature)) { -// FIXME so we can relay this -// q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", -// $r[0]['id'], -// dbesc($signed_data), -// dbesc($sig), -// dbesc($diaspora_handle) -// ); + if(intval($p[0]['item_origin']) && (! $parent_author_signature)) { // the existence of parent_author_signature would have meant the parent_author or owner // is already relaying. - logger('diaspora_signed_retraction: relaying relayable_retraction'); + logger('diaspora_signed_retraction: relaying relayable_retraction'); proc_run('php','include/notifier.php','drop',$r[0]['id']); } } diff --git a/include/event.php b/include/event.php index 1ed541d99..9da7a42a9 100644 --- a/include/event.php +++ b/include/event.php @@ -456,53 +456,55 @@ function event_store_item($arr,$event) { $private = (($arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid']) ? 1 : 0); - + + $item_wall = 0; + $item_origin = 0; + $item_thread_top = 0; if($item) { $item_arr['id'] = $item['id']; } else { $wall = (($z[0]['channel_hash'] == $event['event_xchan']) ? true : false); - - $item_flags = ITEM_THREAD_TOP; + $item_thread_top = 1; if($wall) { - $item_flags |= ITEM_WALL; - $item_flags |= ITEM_ORIGIN; + $item_wall = 1; + $item_origin = 1; } - $item_arr['item_flags'] = $item_flags; } if(! $arr['mid']) $arr['mid'] = item_message_id(); - $item_arr['aid'] = $z[0]['channel_account_id']; - $item_arr['uid'] = $arr['uid']; - $item_arr['author_xchan'] = $arr['event_xchan']; - $item_arr['mid'] = $arr['mid']; - $item_arr['parent_mid'] = $arr['mid']; + $item_arr['aid'] = $z[0]['channel_account_id']; + $item_arr['uid'] = $arr['uid']; + $item_arr['author_xchan'] = $arr['event_xchan']; + $item_arr['mid'] = $arr['mid']; + $item_arr['parent_mid'] = $arr['mid']; - $item_arr['owner_xchan'] = (($wall) ? $z[0]['channel_hash'] : $arr['event_xchan']); - $item_arr['author_xchan'] = $arr['event_xchan']; - $item_arr['title'] = $arr['summary']; - $item_arr['allow_cid'] = $arr['allow_cid']; - $item_arr['allow_gid'] = $arr['allow_gid']; - $item_arr['deny_cid'] = $arr['deny_cid']; - $item_arr['deny_gid'] = $arr['deny_gid']; - $item_arr['item_private'] = $private; - $item_arr['verb'] = ACTIVITY_POST; + $item_arr['owner_xchan'] = (($wall) ? $z[0]['channel_hash'] : $arr['event_xchan']); + $item_arr['author_xchan'] = $arr['event_xchan']; + $item_arr['title'] = $arr['summary']; + $item_arr['allow_cid'] = $arr['allow_cid']; + $item_arr['allow_gid'] = $arr['allow_gid']; + $item_arr['deny_cid'] = $arr['deny_cid']; + $item_arr['deny_gid'] = $arr['deny_gid']; + $item_arr['item_private'] = $private; + $item_arr['verb'] = ACTIVITY_POST; + $item_arr['item_wall'] = $item_wall; + $item_arr['item_origin'] = $item_origin; + $item_arr['item_thread_top'] = $item_thread_top;; if(array_key_exists('term',$arr)) $item_arr['term'] = $arr['term']; - $item_arr['resource_type'] = 'event'; - $item_arr['resource_id'] = $event['event_hash']; - - $item_arr['obj_type'] = ACTIVITY_OBJ_EVENT; - - $item_arr['body'] = $prefix . format_event_bbcode($arr); + $item_arr['resource_type'] = 'event'; + $item_arr['resource_id'] = $event['event_hash']; + $item_arr['obj_type'] = ACTIVITY_OBJ_EVENT; + $item_arr['body'] = $prefix . format_event_bbcode($arr); // if it's local send the permalink to the channel page. // otherwise we'll fallback to /display/$message_id diff --git a/include/externals.php b/include/externals.php index b0f853dc6..3b6d170d5 100644 --- a/include/externals.php +++ b/include/externals.php @@ -93,26 +93,6 @@ function externals_run($argv, $argc){ $results = process_delivery(array('hash' => 'undefined'), get_item_elements($message), array(array('hash' => $sys['xchan_hash'])), false, true); $total ++; -// $z = q("select id from item where mid = '%s' and uid = %d limit 1", -// dbesc($message['message_id']), -// intval($sys['channel_id']) -// ); -$z = null; - if($z) { - $flag_bits = ITEM_WALL|ITEM_ORIGIN|ITEM_UPLINK; - // preserve the source - - $r = q("update item set source_xchan = owner_xchan where id = %d", - intval($z[0]['id']) - ); - - $r = q("update item set item_flags = ( item_flags | %d ), owner_xchan = '%s' - where id = %d", - intval($flag_bits), - dbesc($sys['xchan_hash']), - intval($z[0]['id']) - ); - } } logger('externals: import_public_posts: ' . $total . ' messages imported', LOGGER_DEBUG); } diff --git a/include/items.php b/include/items.php index fb2f2586a..b2fc05f09 100755 --- a/include/items.php +++ b/include/items.php @@ -364,13 +364,12 @@ function post_activity_item($arr) { if((($arr['parent']) && $arr['parent'] != $arr['id']) || (($arr['parent_mid']) && $arr['parent_mid'] != $arr['mid'])) $is_comment = true; - if(! x($arr,'item_flags')) { - if($is_comment) - $arr['item_flags'] = ITEM_ORIGIN; - else - $arr['item_flags'] = ITEM_ORIGIN | ITEM_WALL | ITEM_THREAD_TOP; - } - + if(! array_key_exists('item_origin',$arr)) + $arr['item_origin'] = 1; + if(! array_key_exists('item_wall',$arr) && (! $is_comment)) + $arr['item_wall'] = 1; + if(! array_key_exists('item_thread_top',$arr) && (! $is_comment)) + $arr['item_thread_top'] = 1; $channel = get_app()->get_channel(); $observer = get_app()->get_observer(); @@ -2917,10 +2916,7 @@ function tag_deliver($uid,$item_id) { // prevent delivery looping - only proceed // if the message originated elsewhere and is a top-level post - if(($item['item_flags'] & ITEM_WALL) - || ($item['item_flags'] & ITEM_ORIGIN) - || (!($item['item_flags'] & ITEM_THREAD_TOP)) - || ($item['id'] != $item['parent'])) { + if(intval($item['item_wall']) || intval($item['item_origin']) || (! intval($item['item_thread_top'])) || ($item['id'] != $item['parent'])) { logger('tag_deliver: item was local or a comment. rejected.'); return; } @@ -3039,7 +3035,10 @@ function start_delivery_chain($channel,$item,$item_id,$parent) { if((! $private) && $new_public_policy) $private = 1; - $flag_bits = $item['item_flags'] | ITEM_WALL|ITEM_ORIGIN; + $item_wall = 1; + $item_origin = 1; + + $flag_bits = $item['item_flags']; // unset the nocomment bit if it's there. @@ -3087,7 +3086,7 @@ function start_delivery_chain($channel,$item,$item_id,$parent) { } $r = q("update item set item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s', - deny_cid = '%s', deny_gid = '%s', item_private = %d, public_policy = '%s', comment_policy = '%s', title = '%s', body = '%s' where id = %d", + deny_cid = '%s', deny_gid = '%s', item_private = %d, public_policy = '%s', comment_policy = '%s', title = '%s', body = '%s', item_wall = %d, item_origin = %d where id = %d", intval($flag_bits), dbesc($channel['channel_hash']), dbesc($channel['channel_allow_cid']), @@ -3099,6 +3098,8 @@ function start_delivery_chain($channel,$item,$item_id,$parent) { dbesc(map_scope($channel['channel_w_comment'])), dbesc($title), dbesc($body), + intval($item_wall), + $intval($item_origin), intval($item_id) ); diff --git a/include/notifier.php b/include/notifier.php index 29646fb38..241dffbd1 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -362,7 +362,7 @@ function notifier_run($argv, $argc){ $encoded_item = encode_item($target_item); - $relay_to_owner = (((! $top_level_post) && ($target_item['item_flags'] & ITEM_ORIGIN)) ? true : false); + $relay_to_owner = (((! $top_level_post) && (intval($target_item['item_origin']))) ? true : false); $uplink = false; @@ -371,7 +371,6 @@ function notifier_run($argv, $argc){ logger('notifier: relay_to_owner: ' . (($relay_to_owner) ? 'true' : 'false'), LOGGER_DATA); logger('notifier: top_level_post: ' . (($top_level_post) ? 'true' : 'false'), LOGGER_DATA); - logger('notifier: target_item_flags: ' . $target_item['item_flags'] . ' ' . (($target_item['item_flags'] & ITEM_ORIGIN ) ? 'true' : 'false'), LOGGER_DATA); // tag_deliver'd post which needs to be sent back to the original author diff --git a/include/photos.php b/include/photos.php index 2393153c6..0ac47f7ba 100644 --- a/include/photos.php +++ b/include/photos.php @@ -225,30 +225,31 @@ function photo_upload($channel, $observer, $args) { // Create item container - $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN); $title = ''; $mid = item_message_id(); $arr = array(); - $arr['aid'] = $account_id; - $arr['uid'] = $channel_id; - $arr['mid'] = $mid; - $arr['parent_mid'] = $mid; - $arr['item_flags'] = $item_flags; - $arr['item_restrict'] = $item_restrict; - $arr['resource_type'] = 'photo'; - $arr['resource_id'] = $photo_hash; - $arr['owner_xchan'] = $channel['channel_hash']; - $arr['author_xchan'] = $observer['xchan_hash']; - $arr['title'] = $title; - $arr['allow_cid'] = $str_contact_allow; - $arr['allow_gid'] = $str_group_allow; - $arr['deny_cid'] = $str_contact_deny; - $arr['deny_gid'] = $str_group_deny; - $arr['verb'] = ACTIVITY_POST; - + $arr['aid'] = $account_id; + $arr['uid'] = $channel_id; + $arr['mid'] = $mid; + $arr['parent_mid'] = $mid; + $arr['item_flags'] = $item_flags; + $arr['item_restrict'] = $item_restrict; + $arr['resource_type'] = 'photo'; + $arr['resource_id'] = $photo_hash; + $arr['owner_xchan'] = $channel['channel_hash']; + $arr['author_xchan'] = $observer['xchan_hash']; + $arr['title'] = $title; + $arr['allow_cid'] = $str_contact_allow; + $arr['allow_gid'] = $str_group_allow; + $arr['deny_cid'] = $str_contact_deny; + $arr['deny_gid'] = $str_group_deny; + $arr['verb'] = ACTIVITY_POST; + $arr['item_wall'] = 1; + $arr['item_origin'] = 1; + $arr['item_thread_top'] = 1; $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid']; if ($width_x_height) @@ -431,7 +432,6 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { // Create item container - $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN); $title = ''; @@ -439,25 +439,27 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { $arr = array(); - $arr['aid'] = $channel['channel_account_id']; - $arr['uid'] = $channel['channel_id']; - $arr['mid'] = $mid; - $arr['parent_mid'] = $mid; - $arr['item_flags'] = $item_flags; - $arr['item_restrict'] = $item_restrict; - $arr['resource_type'] = 'photo'; - $arr['resource_id'] = $photo['resource_id']; - $arr['owner_xchan'] = $channel['channel_hash']; - $arr['author_xchan'] = $creator_hash; - - $arr['allow_cid'] = $photo['allow_cid']; - $arr['allow_gid'] = $photo['allow_gid']; - $arr['deny_cid'] = $photo['deny_cid']; - $arr['deny_gid'] = $photo['deny_gid']; - - $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid']; + $arr['aid'] = $channel['channel_account_id']; + $arr['uid'] = $channel['channel_id']; + $arr['mid'] = $mid; + $arr['parent_mid'] = $mid; + $arr['item_wall'] = 1; + $arr['item_origin'] = 1; + $arr['item_thread_top'] = 1; + $arr['item_restrict'] = $item_restrict; + $arr['resource_type'] = 'photo'; + $arr['resource_id'] = $photo['resource_id']; + $arr['owner_xchan'] = $channel['channel_hash']; + $arr['author_xchan'] = $creator_hash; + + $arr['allow_cid'] = $photo['allow_cid']; + $arr['allow_gid'] = $photo['allow_gid']; + $arr['deny_cid'] = $photo['deny_cid']; + $arr['deny_gid'] = $photo['deny_gid']; + + $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid']; - $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' + $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/zmg]' . '[/zrl]'; diff --git a/include/zot.php b/include/zot.php index 9cb6c47d8..435592b6a 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1549,7 +1549,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque $result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); // We need this line to ensure wall-to-wall comments are relayed (by falling through to the relay bit), // and at the same time not relay any other relayable posts more than once, because to do so is very wasteful. - if(! ($r[0]['item_flags'] & ITEM_ORIGIN)) + if(! intval($r[0]['item_origin'])) continue; } } |