Make WordPress Core

Opened 7 weeks ago

Closed 5 weeks ago

Last modified 5 weeks ago

#64764 closed defect (bug) (fixed)

Incorrect documented return type for bookmark functions add_link(), edit_link(), and wp_update_link()

Reported by: marian1's profile marian1 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 7.0 Priority: normal
Severity: minor Version:
Component: Administration Keywords: has-patch
Focuses: docs, administration Cc:

Description

The functions add_link(), edit_link(), and wp_update_link() are documented as returning int|WP_Error.

In practice, they never return a WP_Error instance. All three ultimately call wp_insert_link(), whose second parameter ($wp_error) controls whether failures are returned as WP_Error or as 0. The parameter defaults to false, and none of these wrapper functions passes true (nor do they expose a parameter to allow it).

As a result, these functions return an integer in all cases: 0 on failure, and the link ID on success. Their @return tags should therefore be updated to int.

Change History (4)

This ticket was mentioned in PR #11094 on WordPress/wordpress-develop by @marian1.


7 weeks ago
#1

  • Keywords has-patch added

Trac ticket: https://core.trac.wordpress.org/ticket/64764

## Use of AI Tools

#2 @SergeyBiryukov
5 weeks ago

  • Milestone changed from Awaiting Review to 7.0

#3 @SergeyBiryukov
5 weeks ago

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

In 62024:

Docs: Correct return type for add_link(), edit_link(), and wp_update_link().

Follow-up to [8758], [15564].

Props marian1.
Fixes #64764.

@westonruter commented on PR #11094:


5 weeks ago
#4

Added props for @apermo and myself in Core Props.

Note: See TracTickets for help on using tickets.