Skip to content

Commit

Permalink
fix(bookmarks): unable to save bookmark on PHP 8
Browse files Browse the repository at this point in the history
fixes #13637
  • Loading branch information
jeabakker committed Aug 25, 2021
1 parent 21bbd3b commit 8139241
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions mod/bookmarks/actions/bookmarks/save.php
Expand Up @@ -6,36 +6,37 @@
$title = elgg_get_title_input();
$description = get_input('description');
$address = get_input('address');
$access_id = get_input('access_id');
$access_id = (int) get_input('access_id');
$tags = get_input('tags');
$guid = get_input('guid');
$guid = (int) get_input('guid');
$container_guid = (int) get_input('container_guid', elgg_get_logged_in_user_guid());

elgg_make_sticky_form('bookmarks');

// don't use elgg_normalize_url() because we don't want
// relative links resolved to this site.
if ($address && !preg_match("#^((ht|f)tps?:)?//#i", $address)) {
$address = "http://$address";
$address = "http://{$address}";
}

if (!$title || !$address) {
if (empty($title) || empty($address)) {
return elgg_error_response(elgg_echo('bookmarks:save:failed'));
}

if (!filter_var($address, FILTER_VALIDATE_URL)) {
return elgg_error_response(elgg_echo('bookmarks:save:failed'));
}

if ($guid == 0) {
$new = true;
if (empty($guid)) {
$bookmark = new ElggBookmark;
$bookmark->container_guid = $container_guid;
$new = true;
} else {
$bookmark = get_entity($guid);
if (!$bookmark instanceof ElggBookmark || !$bookmark->canEdit()) {
return elgg_error_response(elgg_echo('bookmarks:save:failed'));
}
$new = false;
}

$bookmark->title = $title;
Expand All @@ -55,7 +56,7 @@
elgg_create_river_item([
'view' => 'river/object/bookmarks/create',
'action_type' => 'create',
'object_guid' => $bookmark->getGUID(),
'object_guid' => $bookmark->guid,
]);
}

Expand Down

0 comments on commit 8139241

Please sign in to comment.