Many item calls are now isolated in a single function

This commit is contained in:
Michael 2018-02-06 12:40:22 +00:00
parent c8cc7f13f1
commit e609de2957
23 changed files with 161 additions and 387 deletions

View file

@ -2218,7 +2218,7 @@ function api_statuses_destroy($type)
$ret = api_statuses_show($type);
Item::delete($id);
Item::deleteById($id);
return $ret;
}
@ -2459,9 +2459,7 @@ function api_favorites_create_destroy($type)
throw new BadRequestException("Invalid action ".$action);
}
$r = q("UPDATE item SET starred=%d WHERE id=%d AND uid=%d", $item[0]['starred'], $itemid, api_user());
q("UPDATE thread SET starred=%d WHERE iid=%d AND uid=%d", $item[0]['starred'], $itemid, api_user());
Item::update(['starred' => $item[0]['starred']], ['id' => $itemid]);
if ($r === false) {
throw new InternalServerErrorException("DB error");
@ -3991,7 +3989,7 @@ function api_fr_photoalbum_delete($type)
if (!DBM::is_result($photo_item)) {
throw new InternalServerErrorException("problem with deleting items occured");
}
Item::delete($photo_item[0]['id']);
Item::deleteById($photo_item[0]['id']);
}
// now let's delete all photos from the album
@ -4294,7 +4292,7 @@ function api_fr_photo_delete($type)
}
// function for setting the items to "deleted = 1" which ensures that comments, likes etc. are not shown anymore
// to the user and the contacts of the users (drop_items() do all the necessary magic to avoid orphans in database and federate deletion)
Item::delete($photo_item[0]['id']);
Item::deleteById($photo_item[0]['id']);
$answer = ['result' => 'deleted', 'message' => 'photo with id `' . $photo_id . '` has been deleted from server.'];
return api_format_data("photo_delete", $type, ['$result' => $answer]);