Check Content\Item::replaceTag return for false return value before using it
- Address https://github.com/friendica/friendica/issues/10169#issuecomment-835547443 - Remove unused code in Content\Item::replaceTag
This commit is contained in:
parent
e42a9254c0
commit
303c9d4a54
3 changed files with 17 additions and 28 deletions
|
@ -410,7 +410,7 @@ function item_post(App $a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$success = ItemHelper::replaceTag($body, $inform, local_user() ? local_user() : $profile_uid, $tag, $network);
|
if ($success = ItemHelper::replaceTag($body, $inform, local_user() ? local_user() : $profile_uid, $tag, $network)) {
|
||||||
if ($success['replaced']) {
|
if ($success['replaced']) {
|
||||||
$tagged[] = $tag;
|
$tagged[] = $tag;
|
||||||
}
|
}
|
||||||
|
@ -427,6 +427,7 @@ function item_post(App $a) {
|
||||||
$forum_contact = $success['contact'];
|
$forum_contact = $success['contact'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $body;
|
return $body;
|
||||||
});
|
});
|
||||||
|
|
|
@ -127,16 +127,6 @@ class Item
|
||||||
$tag_type = substr($tag, 0, 1);
|
$tag_type = substr($tag, 0, 1);
|
||||||
//is it already replaced?
|
//is it already replaced?
|
||||||
if (strpos($tag, '[url=')) {
|
if (strpos($tag, '[url=')) {
|
||||||
// Checking for the alias that is used for OStatus
|
|
||||||
$pattern = '/[@!]\[url\=(.*?)\](.*?)\[\/url\]/ism';
|
|
||||||
if (preg_match($pattern, $tag, $matches)) {
|
|
||||||
$data = Contact::getByURL($matches[1], false, ['alias', 'nick']);
|
|
||||||
|
|
||||||
if ($data['alias'] != '') {
|
|
||||||
$newtag = '@[url=' . $data['alias'] . ']' . $data['nick'] . '[/url]';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $replaced;
|
return $replaced;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2196,9 +2196,7 @@ class BBCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$success = Item::replaceTag($body, $inform, $profile_uid, $tag, $network);
|
if (($success = Item::replaceTag($body, $inform, $profile_uid, $tag, $network)) && $success['replaced']) {
|
||||||
|
|
||||||
if ($success['replaced']) {
|
|
||||||
$tagged[] = $tag;
|
$tagged[] = $tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue