fix a bunch of post editing bugs - though this consolidates some disparate code and may create some new bugs due to regression

This commit is contained in:
friendica 2013-10-04 04:47:41 -07:00
parent 36440e190e
commit ff7182f441
4 changed files with 952 additions and 889 deletions

View File

@ -1793,10 +1793,28 @@ function item_store_update($arr,$allow_exec = false) {
}
$orig_post_id = $arr['id'];
unset($arr['id']);
$uid = $arr['uid'];
$orig = q("select * from item where id = %d and uid = %d limit 1",
intval($orig_post_id),
intval($uid)
);
if(! $orig) {
logger('item_store_update: original post not found: ' . $orig_post_id);
$ret['message'] = 'no original';
return $ret;
}
if($orig[0]['item_flags'] & ITEM_VERIFIED)
$orig[0]['item_flags'] = $orig[0]['item_flags'] ^ ITEM_VERIFIED;
$arr['item_flags'] = intval($arr['item_flags']) | $orig[0]['item_flags'];
$arr['item_restrict'] = intval($arr['item_restrict']) | $orig[0]['item_restrict'];
unset($arr['id']);
unset($arr['uid']);
if(array_key_exists('edit',$arr))
unset($arr['edit']);
$arr['mimetype'] = ((x($arr,'mimetype')) ? notags(trim($arr['mimetype'])) : 'text/bbcode');
if(($arr['mimetype'] == 'application/x-php') && (! $allow_exec)) {
@ -1859,15 +1877,6 @@ function item_store_update($arr,$allow_exec = false) {
}
$orig = q("select * from item where id = %d and uid = %d limit 1",
intval($orig_post_id),
intval($uid)
);
if(! $orig) {
logger('item_store_update: original post not found: ' . $orig_post_id);
$ret['message'] = 'no original';
return $ret;
}
unset($arr['aid']);
unset($arr['mid']);
@ -1885,13 +1894,13 @@ function item_store_update($arr,$allow_exec = false) {
$arr['received'] = datetime_convert();
$arr['changed'] = datetime_convert();
$arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : '');
$arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : '');
$arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : '');
$arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : '');
$arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : '');
$arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : '');
$arr['tgt_type'] = ((x($arr,'tgt_type')) ? notags(trim($arr['tgt_type'])) : '');
$arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : '');
$arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : $orig[0]['location']);
$arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : $orig[0]['coord']);
$arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : $orig[0]['verb']);
$arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : $orig[0]['obj_type']);
$arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : $orig[0]['object']);
$arr['tgt_type'] = ((x($arr,'tgt_type')) ? notags(trim($arr['tgt_type'])) : $orig[0]['tgt_type']);
$arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : $orig[0]['target']);
$arr['plink'] = ((x($arr,'plink')) ? notags(trim($arr['plink'])) : $orig[0]['plink']);
$arr['allow_cid'] = ((x($arr,'allow_cid')) ? trim($arr['allow_cid']) : $orig[0]['allow_cid']);
$arr['allow_gid'] = ((x($arr,'allow_gid')) ? trim($arr['allow_gid']) : $orig[0]['allow_gid']);
@ -1899,12 +1908,13 @@ function item_store_update($arr,$allow_exec = false) {
$arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : $orig[0]['deny_gid']);
$arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : $orig[0]['item_private']);
$arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : '');
$arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : '');
$arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : '');
$arr['item_restrict'] = ((x($arr,'item_restrict')) ? intval($arr['item_restrict']) : $orig[0]['item_restrict'] );
$arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : $orig[0]['item_flags'] );
$arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : $orig[0]['attach']);
$arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : $orig[0]['app']);
// $arr['item_restrict'] = ((x($arr,'item_restrict')) ? intval($arr['item_restrict']) : $orig[0]['item_restrict'] );
// $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : $orig[0]['item_flags'] );
$arr['sig'] = ((x($arr,'sig')) ? $arr['sig'] : '');
$arr['sig'] = ((x($arr,'sig')) ? $arr['sig'] : '');
$arr['layout_mid'] = ((x($arr,'layout_mid')) ? dbesc($arr['layout_mid']) : $orig[0]['layout_mid'] );
call_hooks('post_remote_update',$arr);

View File

@ -88,6 +88,9 @@ function item_post(&$a) {
$pagetitle = strtolower(URLify::transliterate($pagetitle));
}
$item_flags = $item_restrict = 0;
/**
* Is this a reply to something?
*/
@ -251,7 +254,8 @@ function item_post(&$a) {
$title = escape_tags(trim($_REQUEST['title']));
$body = $_REQUEST['body'];
$private = $orig_post['item_private'];
$item_flags = $orig_post['item_flags'];
$item_restrict = $irog_post['item_restrict'];
}
else {
@ -530,8 +534,8 @@ function item_post(&$a) {
}
}
$item_flags = ITEM_UNSEEN;
$item_restrict = ITEM_VISIBLE;
$item_flags |= ITEM_UNSEEN;
$item_restrict |= ITEM_VISIBLE;
if($post_type === 'wall' || $post_type === 'wall-comment')
$item_flags = $item_flags | ITEM_WALL;
@ -658,47 +662,9 @@ function item_post(&$a) {
}
if($orig_post) {
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `mimetype` = '%s', `attach` = '%s', `edited` = '%s', layout_mid = '%s', sig = '%s', item_flags = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
dbesc($datarray['title']),
dbesc($datarray['body']),
dbesc($datarray['mimetype']),
dbesc($datarray['attach']),
dbesc(datetime_convert()),
dbesc($layout_mid),
dbesc($datarray['sig']),
intval($item_flags),
intval($post_id),
intval($profile_uid)
);
// remove taxonomy items for this post - we'll recreate them
q("delete from term where otype = %d and oid = %d and type in (%d, %d, %d, %d) ",
intval(TERM_OBJ_POST),
intval($post_id),
intval(TERM_UNKNOWN),
intval(TERM_HASHTAG),
intval(TERM_MENTION),
intval(TERM_CATEGORY)
);
if(count($post_tags)) {
foreach($post_tags as $tag) {
if(strlen(trim($tag['term']))) {
q("insert into term (uid,oid,otype,type,term,url) values (%d,%d,%d,%d,'%s','%s')",
intval($tag['uid']),
intval($post_id),
intval($tag['otype']),
intval($tag['type']),
dbesc(trim($tag['term'])),
dbesc(trim($tag['url']))
);
}
}
}
$datarray['id'] = $post_id;
item_store_update($datarray,$execflag);
proc_run('php', "include/notifier.php", 'edit_post', $post_id);
if((x($_REQUEST,'return')) && strlen($return_path)) {
@ -712,6 +678,8 @@ function item_post(&$a) {
$post = item_store($datarray,$execflag);
$post_id = $post['item_id'];
if($post_id) {

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
2013-10-03.455
2013-10-04.456