Skip to:
Content

BuddyPress.org

Opened 3 weeks ago

Closed 25 hours ago

#8490 closed enhancement (fixed)

Helper to get a REST API object URL from a component.

Reported by: espellcaste Owned by: espellcaste
Milestone: 9.0.0 Priority: normal
Severity: normal Version: 8.0.0
Component: REST API Keywords: has-patch commit
Cc:

Description

This is a little helper to grab a REST API url from a specific object. Currently we have bp_rest_get_user_url but for other components, we need to build the url every single time.

We are doing lots of code duplication in the REST API plugin that could be improved using a more improved helper function.

Attachments (2)

8490.diff (978 bytes) - added by espellcaste 3 weeks ago.
8490-2.diff (2.0 KB) - added by espellcaste 2 weeks ago.

Download all attachments as: .zip

Change History (11)

@espellcaste
3 weeks ago

#1 @imath
2 weeks ago

  • Keywords needs-refresh added

Thanks @espellcaste

Could you improve the patch a bit to "fully" deprecate bp_rest_get_user_url() and make it use bp_rest_get_object_url(). See /src/deprecated/8.0.php` for examples.

eg:

function bp_rest_get_user_url( $user_id ) {
	_deprecated_function( __FUNCTION__, '9.0.0', 'bp_rest_get_object_url( $user_id, \'members\' )' );
	return bp_rest_get_object_url( $user_id, 'members' );
}
Last edited 2 weeks ago by imath (previous) (diff)

#2 @espellcaste
2 weeks ago

@imath Do I create a new file for the 9.0 version?

require( $this->plugin_dir . 'bp-core/deprecated/9.0.php' );

I don't the see the 8.0 version being loaded anywhere so I'm confused if this was added in the previous version.

#3 @imath
2 weeks ago

@espellcaste Good catch! You're absolutely right. I've just committed the fix r12975

@espellcaste
2 weeks ago

#4 @espellcaste
2 weeks ago

  • Keywords needs-refresh removed

#5 @imath
2 weeks ago

  • Keywords commit added

Looks good!

#6 @espellcaste
6 days ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 12985:

Introducing a new helper function bp_rest_get_object_url, used to grab a REST API endpoint url from a specific component.

We are also deprecating the legacy version bp_rest_get_user_url

Props imath

Fixes #8490

#7 @imath
4 days ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The $this->plugin_dir . 'bp-core/deprecated/9.0.php' file is missing in r12985. I'm reopening the ticket just to be sure we don't forget to add it 😉

#8 @espellcaste
25 hours ago

In 12986:

Introducing a file with deprecated functions for the 9.0 version of BuddyPress.

see #8490

#9 @espellcaste
25 hours ago

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.