WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 8 months ago

#18632 closed defect (bug) (fixed)

wp_get_shortlink() Should Always Return a URL

Reported by: cais Owned by: ryan
Milestone: 3.7 Priority: normal
Severity: normal Version: 3.1
Component: Template Keywords: has-patch needs-testing
Focuses: Cc:

Description

Currently the code used in the link-template.php file causes the wp_get_shortcode function to return an empty result if the WordPress installation is using the default permalink structure. This causes at least issues with the_shortcode function and can be expected to cause issues any place that wp_get_shortcode is called when the default permalink structure is being used.

An alternative is to simply make the inline documentation state an empty result will be returned when the default permalink structure is used.

Attachments (1)

link-template-patch.diff (524 bytes) - added by cais 3 years ago.

Download all attachments as: .zip

Change History (8)

cais3 years ago

comment:1 chipbennett3 years ago

  • Cc chip@… added

+1

Cais beat me to the punch!

comment:2 chipbennett3 years ago

  • Keywords needs-testing added

comment:3 follow-up: johnbillion3 years ago

  • Component changed from Shortcodes to Template
  • Summary changed from wp_get_shortcode() Should Always Return a URL to wp_get_shortlink() Should Always Return a URL

comment:4 in reply to: ↑ 3 cais3 years ago

Replying to johnbillion: Good catch, I don't find many issues (and subsequent potential solutions) so I was a bit excited when I wrote up this ticket. Thanks.

comment:5 nacin2 years ago

  • Version changed from 3.3 to 3.1

To me it seems like the inline documentation should be updated.

Our shortlink API is designed to only provide a shortlink when one is available. If no shorter link is available, I'd rather not return something.

This patch would also be a change from its introduction. Not a backwards incompatible change, granted.

comment:6 ryan8 months ago

  • Milestone changed from Awaiting Review to 3.7

comment:7 ryan8 months ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In 25030:

wp_get_shortlink() improvements.

  • Return shortlinks for pages and public CPTs.
  • Return shortlinks even when cruft-free links are not enabled.
  • Unit tests

Props sillybean, layotte, cais
fixes #18632
see #14760

Note: See TracTickets for help on using tickets.