Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#63249 reviewing defect (bug)

Minor code and inline docs improvements in class-wp-rest-server.php

Reported by: dilipbheda's profile dilipbheda Owned by: audrasjb's profile audrasjb
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: REST API Keywords: has-patch
Focuses: docs Cc:

Description

Inline Documentation Improvement

Some @param tags are missing default value annotations. e.g:

  • @param string|null — the default value should be specified when applicable.
  • @param false|null — missing mention of the default value.

Conditional Logic Adjustment

Function: get_json_last_error()

The current condition:

if ( JSON_ERROR_NONE === $last_error_code || empty( $last_error_code ) ) {

Proposed change:

if ( empty( $last_error_code ) || JSON_ERROR_NONE === $last_error_code ) {

This change reorders the condition to check for an empty value first, which is a common best practice. It improves readability and slightly optimizes performance by short-circuiting sooner when $last_error_code is empty.

Change History (3)

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


5 weeks ago
#1

#2 @audrasjb
5 weeks ago

  • Milestone changed from Awaiting Review to 6.9
  • Owner set to audrasjb
  • Status changed from new to reviewing

#3 @SergeyBiryukov
5 weeks ago

In 60151:

Coding Standards: Remove extra check in WP_REST_Server::get_json_last_error().

json_last_error() can only return an integer, and the JSON_ERROR_NONE constant has the value of 0, so the empty() check is redundant here.

Follow-up to [34928], [46206].

Props dilipbheda, audrasjb, SergeyBiryukov.
See #63249.

Note: See TracTickets for help on using tickets.