Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#47965 closed defect (bug) (fixed)

Missing strict comparison check in REST Autosaves Controller

Reported by: dkarfa's profile dkarfa Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: normal Version:
Component: REST API Keywords: has-patch dev-feedback commit
Focuses: rest-api Cc:

Description

Missing Yoda conditions check at wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php

Attachments (2)

47965.patch (1.4 KB) - added by dkarfa 5 years ago.
47965.1.diff (879 bytes) - added by itowhid06 5 years ago.

Download all attachments as: .zip

Change History (13)

@dkarfa
5 years ago

#1 @dkarfa
5 years ago

  • Component changed from General to REST API

#2 @mukesh27
5 years ago

  • Focuses rest-api added
  • Keywords has-patch added

#3 @TimothyBlynJacobs
5 years ago

  • Summary changed from Missing Yoda Conditions check to Missing strict comparison check in REST Autosaves Controller

Thanks for the patch @dkarfa!

I'm a bit worried about the $post->post_author === $user_id check. In the type doc it is listed as a string and accompanied by "A numeric string, for compatibility reasons."

#4 @itowhid06
5 years ago

I completely agree with @TimothyBlynJacobs about $post->post_author === $user_id check. Also the patch doesn't apply properly and I've refreshed it. I hope @dkarfa is OK with it :)

@itowhid06
5 years ago

#5 @TimothyBlynJacobs
5 years ago

  • Keywords dev-feedback added

In other places this is used in core, a non-strict comparison check is used as well. For instance, wp_save_post_revision() or wp_create_post_autosave(). I think we'd want to be consistent, but I'm not sure.

Cc: @SergeyBiryukov

#6 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 5.4
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#7 @TimothyBlynJacobs
5 years ago

#49156 was marked as a duplicate.

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


5 years ago

This ticket was mentioned in Slack in #core by david.baumwald. View the logs.


5 years ago

#10 @SergeyBiryukov
5 years ago

  • Keywords commit added

#11 @SergeyBiryukov
5 years ago

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

In 47372:

Coding Standards: Use strict comparison for normalize_whitespace() checks when comparing revisions or autosaves.

Props dkarfa, itowhid06, TimothyBlynJacobs.
Fixes #47965.

Note: See TracTickets for help on using tickets.