Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#47578 closed defect (bug) (fixed)

Call static methods the right way

Reported by: andizer's profile andizer Owned by: sergeybiryukov's profile 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 5 years ago.
47578-2.diff (1.2 KB) - added by andizer 5 years ago.
Fixes other occurrences of calling this static method not the static way.

Download all attachments as: .zip

Change History (7)

5 years ago

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

5 years ago

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

5 years ago

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

#3 @andizer
5 years ago

@TimothyBlynJacobs I've fixes these occurrences as well.

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