Make WordPress Core

Opened 9 months ago

Closed 7 months ago

#63622 closed defect (bug) (fixed)

Warning on inline-save AJAX

Reported by: bor0's profile bor0 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Quick/Bulk Edit Keywords: has-patch reporter-feedback
Focuses: Cc:

Description

Our servers reported the following warning:

Undefined array key "_status"

After digging deeper, I found that we're assuming this is always going to be set here: https://github.com/WordPress/WordPress/blob/d4d9284/wp-admin/includes/ajax-actions.php#L2118

To reproduce, you can either use curl and populate all the necessary information (auth token, nonce, etc.), but I found an easier way:

$ wp shell
wp> wp_set_current_user( 1 )
wp> require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
wp> $_POST = []; // Note: We will intentionally omit '_status' to trigger the warning
wp> $_POST['action'] = 'inline-save'
wp> $_POST['post_ID'] = current( get_posts() )->ID
wp> $_POST['post_type'] = 'post'
wp> $_POST['_inline_edit'] = wp_create_nonce( 'inlineeditnonce' )
wp> $_POST['screen'] = 'edit-post'
wp> $_POST['post_view'] = 'list'
wp> $_REQUEST = $_POST // need this for referer check function
wp> wp_ajax_inline_save();
PHP Warning:  Undefined array key "_status" in /opt/homebrew/var/www/wp-admin/includes/ajax-actions.php on line 2118
Warning: Undefined array key "_status" in /opt/homebrew/var/www/wp-admin/includes/ajax-actions.php on line 2118
...

Attachments (1)

63622.patch (513 bytes) - added by bor0 9 months ago.

Download all attachments as: .zip

Change History (6)

@bor0
9 months ago

#1 @bor0
9 months ago

  • Keywords has-patch added

@SergeyBiryukov would appreciate your 👀

#2 @jorbin
9 months ago

  • Keywords reporter-feedback added

How would an end user encounter this issue? This feels like something that is coming from a plugin trying to use the core endpoint and doing so incorrectly or from a plugin removing a field from quick edit which both seem like things that should be fixed by the plugin causing the issue.

#3 @bor0
7 months ago

I don't think an end-user can encounter it, but looking at that file, all $data references have a corresponding isset/! empty check, so I thought being more defensive made sense.

#4 @SergeyBiryukov
7 months ago

  • Component changed from General to Quick/Bulk Edit
  • Milestone changed from Awaiting Review to 6.9
  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

#5 @SergeyBiryukov
7 months ago

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

In 60639:

Quick/Bulk Edit: Check if post status is set in wp_ajax_inline_save().

This aims to avoid a PHP warning if the status value is missing in the request.

Follow-up to [8951], [9083].

Props bor0, jorbin, SergeyBiryukov.
Fixes #63622.

Note: See TracTickets for help on using tickets.