Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#47013 closed defect (bug) (fixed)

Editor: Warning when creating new page: "implode(): Invalid arguments"

Reported by: aduth's profile aduth Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.2
Component: Editor Keywords: good-first-bug has-patch needs-testing
Focuses: Cc:

Description

Previously: https://github.com/WordPress/gutenberg/issues/13875

The file edit-form-blocks.php calls implode on the result of a call to wp_set_post_lock. Per the documentation of the function, it can return a value of false which, when passed to implode, could result in a warning.

https://github.com/WordPress/wordpress-develop/blob/7bdef3d/src/wp-admin/edit-form-blocks.php#L252
https://developer.wordpress.org/reference/functions/wp_set_post_lock/

While it was not personally reproduced, presumably it could occur under the condition "if the post does not exist, or there is no current user" (from the documentation of wp_set_post_lock).

In any case, given the return type of wp_set_post_lock allowing for a boolean return value, it should not be passed directly into implode without first checking the type returned.

Attachments (1)

47013.diff (535 bytes) - added by kakshak 6 years ago.

Download all attachments as: .zip

Change History (6)

#1 @johnbillion
6 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release

@kakshak
6 years ago

#2 @kakshak
6 years ago

  • Keywords has-patch added; needs-patch removed

@aduth I've created the patch for checking the return type of wp_set_post_lock

Last edited 6 years ago by kakshak (previous) (diff)

#3 @desrosj
6 years ago

  • Keywords needs-testing added

#4 @SergeyBiryukov
6 years ago

  • Milestone changed from Future Release to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#5 @SergeyBiryukov
6 years ago

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

In 45413:

Editor: In edit-form-blocks.php, check the result of wp_set_post_lock(), which may return false and cause a warning when passed to implode().

Props kakshak, aduth.
Fixes #47013.

Note: See TracTickets for help on using tickets.