Skip to:
Content

bbPress.org

Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#3603 closed enhancement (wontfix)

Prefer get_post_permalink() over get_permalink()

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: API - Rewrite Rules Keywords:
Cc:

Description

There are quite a few places where get_permalink() is called on one of the 3 bbPress custom post types, and some unnecessary PHP processing can be eliminated by simply calling get_post_permalink() instead.

This is because get_permalink() does some post_type checks internally, and in our case then just returns the results of get_post_permalink() anyways.

Since we always know our own post types will always make those calls, we can safely call them directly.

Change History (2)

#1 @johnjamesjacoby
7 months ago

  • Keywords needs-patch good-first-bug removed
  • Milestone 2.7 deleted
  • Resolution set to wontfix
  • Status changed from new to closed
  • Version 2.0 deleted

After a bit more review & research, I'm opting to close this as wontfix for the following reasons:

  1. Challenging my own statement of "we always know our own post types will always make those calls" it is also possible that a third-party plugin could be using Posts, Pages, or Attachments as a "Forum", and swapping out get_permalink() may cause unintended breakage.
  2. It adds extra complexity to the code for not a whole lot of gain.
  3. It is just easier and most flexible to trust get_permalink() to figure things out.

#2 @johnjamesjacoby
7 months ago

In 7279:

Common: prefer bbp_get_topic_permalink() over get_permalink()

This change ensures that features like Subscriptions & Pagination (inside of topics list loops) have: an opportunity to use the anticipated function path, and access to the right filters when including links back to them.

This fixes a potential bug where filtering a topic permalink would not happen inside of emails or pagination in the loop-topic template part.

See #3603.

Note: See TracTickets for help on using tickets.