WordPress.org

Make WordPress Core

Opened 5 months ago

Closed 5 months ago

#47578 closed defect (bug) (fixed)

Call static methods the right way

Reported by: andizer Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 4.4
Component: REST API Keywords: needs-patch
Focuses: rest-api Cc:
PR Number:

Description

I saw there were to call to methods that are declared static but called accessed $this, so I've fixed these two.

Attachments (2)

47578.diff (957 bytes) - added by andizer 5 months ago.
47578-2.diff (1.2 KB) - added by andizer 5 months ago.
Fixes other occurrences of calling this static method not the static way.

Download all attachments as: .zip

Change History (7)

@andizer
5 months ago

This ticket was mentioned in Slack in #core-restapi by timothybjacobs. View the logs.


5 months ago

#2 @TimothyBlynJacobs
5 months ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from Awaiting Review to 5.3
  • Version set to 4.4

Good catch!

There are a couple of other places where this could be fixed as well. In rest_preload_api_request() and in WP_REST_Controller::prepare_response_for_collection()

@andizer
5 months ago

Fixes other occurrences of calling this static method not the static way.

#3 @andizer
5 months ago

@TimothyBlynJacobs I've fixes these occurrences as well.

#4 @TimothyBlynJacobs
5 months ago

Thanks for the updated patch, one last adjustment needed. Those replacements should use $server::get_compact_response_links() to ensure that a subclassed WP_REST_Server that replaces the get_compact_response_links method has its changes respected.

#5 @SergeyBiryukov
5 months ago

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

In 45566:

REST API: Call WP_REST_Server::get_compact_response_links() and ::get_raw_data() static methods the right way.

Props andizer, TimothyBlynJacobs.
Fixes #47578.

Note: See TracTickets for help on using tickets.