Merge pull request #7915 from annando/issue-7914

Fixes issue 7914: Reshares got crumbled
This commit is contained in:
Hypolite Petovan 2019-12-07 16:53:50 -05:00 committed by GitHub
commit 2b12cd473d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 7 deletions

View file

@ -652,6 +652,9 @@ function item_post(App $a) {
if ($orig_post) { if ($orig_post) {
$datarray['edit'] = true; $datarray['edit'] = true;
} else { } else {
// If this was a share, add missing data here
$datarray = Item::addShareDataFromOriginal($datarray);
$datarray['edit'] = false; $datarray['edit'] = false;
} }
@ -730,9 +733,6 @@ function item_post(App $a) {
} }
} }
// If this was a share, add missing data here
$datarray = Item::addShareDataFromOriginal($datarray);
$post_id = Item::insert($datarray); $post_id = Item::insert($datarray);
if (!$post_id) { if (!$post_id) {

View file

@ -953,10 +953,9 @@ class BBCode extends BaseObject
public static function convertShare($text, callable $callback) public static function convertShare($text, callable $callback)
{ {
$return = preg_replace_callback( $return = preg_replace_callback(
"/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism", "/(.*?)\[share(.*?)\](.*)\[\/share\]/ism",
function ($match) use ($callback) { function ($match) use ($callback) {
$attribute_string = $match[2]; $attribute_string = $match[2];
$attributes = []; $attributes = [];
foreach (['author', 'profile', 'avatar', 'link', 'posted'] as $field) { foreach (['author', 'profile', 'avatar', 'link', 'posted'] as $field) {
preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches); preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches);

View file

@ -3833,7 +3833,7 @@ class Item extends BaseObject
$body = $shared_item['body']; $body = $shared_item['body'];
} }
$item['body'] = preg_replace("/(.*?\[share.*?\]\s?).*?(\s?\[\/share\]\s?)/ism", '$1' . $body . '$2', $item['body']); $item['body'] = preg_replace("/\[share ([^\[\]]*)\].*\[\/share\]/ism", '[share $1]' . $body . '[/share]', $item['body']);
unset($shared_item['body']); unset($shared_item['body']);
return array_merge($item, $shared_item); return array_merge($item, $shared_item);