Skip to Content Skip to Menu

🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

CB Activity 6.x - bookmarks

  • dg1
  • dg1
  • OFFLINE
  • Posts: 27
  • Thanks: 1
  • Karma: 1
9 months 2 weeks ago - 9 months 2 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

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


Since
Code:
$this->getBool( '_bookmarked' )
always returns FALSE and not NULL, the value returned by
Code:
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]
Last edit: 9 months 2 weeks ago by dg1.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48622
  • Thanks: 8302
  • Karma: 1446
9 months 2 weeks ago - 9 months 2 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.

Code:
$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.
Last edit: 9 months 2 weeks ago by krileon.

Please Log in or Create an account to join the conversation.

  • dg1
  • dg1
  • OFFLINE
  • Posts: 27
  • Thanks: 1
  • Karma: 1
9 months 2 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() 
Code:
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 or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48622
  • Thanks: 8302
  • Karma: 1446
9 months 2 weeks ago - 9 months 2 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.
Last edit: 9 months 2 weeks ago by krileon.
The following user(s) said Thank You: dg1

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48622
  • Thanks: 8302
  • Karma: 1446
9 months 2 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 or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum