Skip to:
Content

bbPress.org

Opened 4 years ago

Last modified 4 years ago

#3125 new enhancement

`bbp_get_topic_id()` might incorrectly return a reply_id or forum_id — at Version 2

Reported by: casiepa Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version:
Component: General Keywords: needs-patch needs-unit-tests
Cc: contato@…

Description (last modified by netweb)

Calling the bbp_get_topic_id() function will check if $id is a valid number by using ( ! empty( $topic_id ) && is_numeric( $topic_id ) ).
If function bbp_get_topic_id() is called with a forum_id or a reply_id, it will still accept the value.

This behaviour should be changed, but there might be 2 ways:
1) if $id is a topic, return $id, otherwise 0 (so add the logic of bbp_is_topic to make sure $id is indeed a topic)
or
2) if $id is an ID for a reply, return the corresponding ID for the topic this reply is part of (ID crawling)

Regardless of choosing 1) or 2) apply the same logic to bbp_get_forum_id() and bbp_get_reply_id().

Change History (2)

#1 @espellcaste
4 years ago

  • Cc contato@… added

I'm in favor of 1 and not 2. I see bbp_get_topic_id as a topic id catcher, not a catch, decides what it is and then returns what it comes with it.

bbp_is_topic was not used in the first place because of performance concerns, so unless a performant crawler is introduced, let's try to minimize the hit on a highly used function.

What do you think?

Last edited 4 years ago by espellcaste (previous) (diff)

#2 @netweb
4 years ago

  • Description modified (diff)
  • Keywords needs-patch needs-unit-tests added
  • Summary changed from bbp_get_topic_id might incorrectly give back a reply_id or forum_id to `bbp_get_topic_id()` might incorrectly return a reply_id or forum_id
Note: See TracTickets for help on using tickets.