CB Activity 6.x - bookmarks

1 month 3 weeks ago - 1 month 3 weeks ago #337497 by dg1
CB Activity 6.x - bookmarks was created by dg1
Hi,

In Joomla! 3.10 the ActivityTable::isBookmarked() function does not work properly. Always returns FALSE. I didn't notice this problem in J4.

A more detailed analysis of the problem (in J3) allowed us to determine that the problem is the use of the ?? operator

    public function isBookmarked(): bool
    {
        return ( $this->getBool( '_bookmarked' ) ?? \in_array( $this->getId(), BookmarkHelper::getBookmarks() ) );
    }


Since
$this->getBool( '_bookmarked' )
always returns FALSE and not NULL, the value returned by
in_array( $this->getId(), BookmarkHelper::getBookmarks() )
has no practical significance.

As a result, you cannot delete a specific bookmark because a submenu item for this action never appears.

The same problem occurs with ActivityTable::isFollowing().

I haven't looked into it further, so perhaps I don't fully understand the intent of this solution.
However, the error is real.

Regards,[/code]

Please Log in to join the conversation.

1 month 3 weeks ago - 1 month 3 weeks ago #337498 by krileon
Replied by krileon on topic CB Activity 6.x - bookmarks
Joomla version doesn't matter for 90% of CBs code. How are you confirming it doesn't work right? It works perfectly fine in my tests.

$this->getBool( '_bookmarked' )


That will return NULL if no value has been set for _bookmarked on the activity object. The purpose of this implementation is _bookmarked is a flag switch used during bookmarking and prefetching so it doesn't need to query for a state it's already aware of.

As a result, you cannot delete a specific bookmark because a submenu item for this action never appears.

This too appears to be working fine.

 

I believe you may have an issue coming from somewhere else. Maybe something is setting _bookmarked always to false for some reason? It should get set during prefetching behavior, but it certainly shouldn't always be false. The prefetcher state setting is handled by BookmarkHelper::getBookmarksByActivity. The main thing that could cause this to always be false is if the activity id doesn't exist or you've bookmarked your own post somehow, which isn't allowed and will ignore that.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Attachments:

Please Log in to join the conversation.

1 month 3 weeks ago #337502 by dg1
Replied by dg1 on topic CB Activity 6.x - bookmarks
I guess everything is clear now. Your tip was valuable.

BookmarkHelper::getBookmarksByActivity() 
self::$activity[$profileId][$id]    =    \in_array( $id, $bookmarked, true );

The $id variable is of type int. The elements of the $bookmarked array are of type string.
The in_array() function uses type checking (third argument TRUE).
In this situation, in_array() always returns FALSE.

I hope my reasoning is correct.

What do you think?
Regards,
 

Please Log in to join the conversation.

1 month 3 weeks ago - 1 month 3 weeks ago #337503 by krileon
Replied by krileon on topic CB Activity 6.x - bookmarks
Depends on where the activity array comes from as $id could be a string (this is why we need generics in PHP!). It's probably only failing when querying for the activity object directly outside of a stream. Inside of a stream like shown above it's working fine. Anyway, will add some stricter type enforcement to avoid type issues there.

forge.joomlapolis.com/issues/9383

Good catch! Thank you for letting us know! Should have it fixed tomorrow. Going to go through and replace any other usages still using the array key instead of the stricter id function as well as any missing query results not being passed through int casting. Looks like this primarily only impacts bookmarks. I'm not seeing any problems with following, which strictly uses asset strings.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: dg1

Please Log in to join the conversation.

1 month 3 weeks ago #337505 by krileon
Replied by krileon on topic CB Activity 6.x - bookmarks
Ok, this is now fixed in latest CB Activity build release. Fixed all potential type juggling issues where arrays of activity rows were handled. Confirmed isBookmarked and isFollowing were working with all prefetchers and caching disabled as well. Please let me know if you're still having issues after updating.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: dg1

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.203 seconds

Facebook Twitter LinkedIn