Make WordPress Core

#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:


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 18 months ago.
47578-2.diff (1.2 KB) - added by andizer 17 months ago.
Fixes other occurrences of calling this static method not the static way.

Download all attachments as: .zip

Change History (7)

18 months ago

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

17 months ago

#2 @TimothyBlynJacobs
17 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()

17 months ago

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

#3 @andizer
17 months ago

@TimothyBlynJacobs I've fixes these occurrences as well.

#4 @TimothyBlynJacobs
17 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
17 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.