- if ($orig_post) {
- $fields = [
- 'title' => $post['title'],
- 'body' => $post['body'],
- 'attach' => $post['attach'],
- 'file' => $post['file'],
- 'edited' => DateTimeFormat::utcNow(),
- 'changed' => DateTimeFormat::utcNow()
- ];
-
- $fields['body'] = Item::setHashtags($fields['body']);
-
- $quote_uri_id = Item::getQuoteUriId($fields['body'], $post['uid']);
- if (!empty($quote_uri_id)) {
- $fields['quote-uri-id'] = $quote_uri_id;
- $fields['body'] = BBCode::removeSharedData($post['body']);
- }
-
- Item::update($fields, ['id' => $post_id]);
- Item::updateDisplayCache($orig_post['uri-id']);
-
- if ($return_path) {
- DI::baseUrl()->redirect($return_path);
- }
-
- throw new HTTPException\OKException(DI::l10n()->t('Post updated.'));
- }
-
- $post_id = Item::insert($post);
- if (!$post_id) {
- DI::sysmsg()->addNotice(DI::l10n()->t('Item wasn\'t stored.'));
- if ($return_path) {
- DI::baseUrl()->redirect($return_path);
- }
-
- throw new HTTPException\InternalServerErrorException(DI::l10n()->t('Item wasn\'t stored.'));
- }
-
- $post = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]);
- if (!DBA::isResult($post)) {
- Logger::error('Item couldn\'t be fetched.', ['post_id' => $post_id]);
- if ($return_path) {
- DI::baseUrl()->redirect($return_path);
- }
-
- throw new HTTPException\InternalServerErrorException(DI::l10n()->t('Item couldn\'t be fetched.'));
- }
-
- $recipients = explode(',', $emailcc);
-
- DI::contentItem()->postProcessPost($post, $recipients);
-
- Logger::debug('post_complete');
-
- item_post_return(DI::baseUrl(), $return_path);
- // NOTREACHED