Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Conversation

@westonruter
Copy link
Member

If attempting to submit a password consisting of an empty string while also submitting true value for sticky, the API is returning an error:

A post can not be sticky and have a password.

I believe it should be considering an empty string to be as if the value was not set.

@danielbachhuber
Copy link
Member

@westonruter Can you update the tests to fix the build?

@joehoyle
Copy link
Member

joehoyle commented Jan 5, 2016

I'm not sure why this is required - this means I can't set a password to string "0".

@danielbachhuber
Copy link
Member

So the most precise check would be to ensure password is either:

  1. Not set.
  2. An empty string.

@westonruter westonruter force-pushed the bugfix/use-empty-check-for-post-password branch from eb4db30 to b6a349d Compare January 5, 2016 17:06
@westonruter
Copy link
Member Author

Right, my choice of empty was short-sighted.

So instead of:

if ( ! empty( $request['password'] ) ) {

It should be:

if ( isset( $request['password'] ) && '' !== $request['password'] ) {

Amended commit in b6a349d.

@danielbachhuber
Copy link
Member

@westonruter can you add to the test_create_post_with_password_and_sticky_fails test to include a condition where the password is an empty string?

danielbachhuber added a commit that referenced this pull request Jan 5, 2016
…sword

Flag sticky if password not empty instead of isset
@danielbachhuber danielbachhuber merged commit dfb0488 into WP-API:develop Jan 5, 2016
@danielbachhuber danielbachhuber added this to the 2.0 Beta 10 milestone Jan 5, 2016
@danielbachhuber danielbachhuber changed the title Flag sticky if password not empty instead of isset Permit making a post sticky when also supplying an empty password Jan 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants