{"action":"created","comment":{"url":"https://api.github.com/repos/WP-API/WP-API/pulls/comments/53867502","id":53867502,"diff_hunk":"@@ -1367,7 +1370,7 @@ public function get_item_schema() {\n \t\t\t\t\t'type'        => 'string',\n \t\t\t\t\t'context'     => array( 'view', 'edit', 'embed' ),\n \t\t\t\t\t'arg_options' => array(\n-\t\t\t\t\t\t'sanitize_callback' => 'sanitize_title',\n+\t\t\t\t\t\t'sanitize_callback' => 'sanitize_key',","path":"lib/endpoints/class-wp-rest-posts-controller.php","position":23,"original_position":23,"commit_id":"8257f8d59924b6c9b8ebfbb486434f09ebb68f4f","original_commit_id":"8257f8d59924b6c9b8ebfbb486434f09ebb68f4f","user":{"login":"adamsilverstein","id":2676022,"avatar_url":"https://avatars.githubusercontent.com/u/2676022?v=3","gravatar_id":"","url":"https://api.github.com/users/adamsilverstein","html_url":"https://github.com/adamsilverstein","followers_url":"https://api.github.com/users/adamsilverstein/followers","following_url":"https://api.github.com/users/adamsilverstein/following{/other_user}","gists_url":"https://api.github.com/users/adamsilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/adamsilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamsilverstein/subscriptions","organizations_url":"https://api.github.com/users/adamsilverstein/orgs","repos_url":"https://api.github.com/users/adamsilverstein/repos","events_url":"https://api.github.com/users/adamsilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/adamsilverstein/received_events","type":"User","site_admin":false},"body":"Ok, I will try to dig in to see why this change resolves the issue I am seeing.","created_at":"2016-02-23T23:13:09Z","updated_at":"2016-02-23T23:13:09Z","html_url":"https://github.com/WP-API/WP-API/pull/2303#discussion_r53867502","pull_request_url":"https://api.github.com/repos/WP-API/WP-API/pulls/2303","_links":{"self":{"href":"https://api.github.com/repos/WP-API/WP-API/pulls/comments/53867502"},"html":{"href":"https://github.com/WP-API/WP-API/pull/2303#discussion_r53867502"},"pull_request":{"href":"https://api.github.com/repos/WP-API/WP-API/pulls/2303"}}},"pull_request":{"url":"https://api.github.com/repos/WP-API/WP-API/pulls/2303","id":60267745,"html_url":"https://github.com/WP-API/WP-API/pull/2303","diff_url":"https://github.com/WP-API/WP-API/pull/2303.diff","patch_url":"https://github.com/WP-API/WP-API/pull/2303.patch","issue_url":"https://api.github.com/repos/WP-API/WP-API/issues/2303","number":2303,"state":"open","locked":false,"title":"Fix slug and date validation for new, unpublished posts","user":{"login":"adamsilverstein","id":2676022,"avatar_url":"https://avatars.githubusercontent.com/u/2676022?v=3","gravatar_id":"","url":"https://api.github.com/users/adamsilverstein","html_url":"https://github.com/adamsilverstein","followers_url":"https://api.github.com/users/adamsilverstein/followers","following_url":"https://api.github.com/users/adamsilverstein/following{/other_user}","gists_url":"https://api.github.com/users/adamsilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/adamsilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamsilverstein/subscriptions","organizations_url":"https://api.github.com/users/adamsilverstein/orgs","repos_url":"https://api.github.com/users/adamsilverstein/repos","events_url":"https://api.github.com/users/adamsilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/adamsilverstein/received_events","type":"User","site_admin":false},"body":"When trying to save/update unpublished posts with the current validation in place, I am getting an error:\r\n\r\n> \"Invalid parameter(s): date_gmt (The date you provided is invalid.), slug (slug is not of type string)\"\r\n\r\n![screenshot](http://cl.ly/3t0d2u2N130y/TunedIn.net__random_musings_of_a_deferred_promise_2016-02-22_15-13-27.jpg)\r\n\r\nIn my testing, newly created posts (via api or wp-admin) get a `post_date_gmt` of `0000-00-00 00:00:00` - the js client can't parse that as a date and stores '`null`. Sending this value pack to the API via a PUT request results in a `rest_invalid_date` error before this patch. Checking for $value truthy before attempting to parse the date fixes the issue.\r\n\r\nNewly created, unpublished posts have a `post_name` aka `slug` that is empty. The API returns this as an empty string (`\"slug\": \"\"`) - sending an empty string back to the API before this PR results in the `rest_invalid_param` error.  I tracked this down to applying `sanitize_title` to the slug, this is somehow turning the empty string into an empty object. Changing the sanitization callback to `sanitize_key` fixes this issue and I believe thats the appropriate sanitization call to use here in any case. \r\n\r\nalso ensure the empty keys are not used in `handle_terms`\r\n","created_at":"2016-02-23T00:38:14Z","updated_at":"2016-02-23T23:13:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"00f62b8c7c48fc6a9f53970fdceff99d432d98b1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/WP-API/WP-API/pulls/2303/commits","review_comments_url":"https://api.github.com/repos/WP-API/WP-API/pulls/2303/comments","review_comment_url":"https://api.github.com/repos/WP-API/WP-API/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WP-API/WP-API/issues/2303/comments","statuses_url":"https://api.github.com/repos/WP-API/WP-API/statuses/8257f8d59924b6c9b8ebfbb486434f09ebb68f4f","head":{"label":"adamsilverstein:fixes/slug-and-date-validation","ref":"fixes/slug-and-date-validation","sha":"8257f8d59924b6c9b8ebfbb486434f09ebb68f4f","user":{"login":"adamsilverstein","id":2676022,"avatar_url":"https://avatars.githubusercontent.com/u/2676022?v=3","gravatar_id":"","url":"https://api.github.com/users/adamsilverstein","html_url":"https://github.com/adamsilverstein","followers_url":"https://api.github.com/users/adamsilverstein/followers","following_url":"https://api.github.com/users/adamsilverstein/following{/other_user}","gists_url":"https://api.github.com/users/adamsilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/adamsilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamsilverstein/subscriptions","organizations_url":"https://api.github.com/users/adamsilverstein/orgs","repos_url":"https://api.github.com/users/adamsilverstein/repos","events_url":"https://api.github.com/users/adamsilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/adamsilverstein/received_events","type":"User","site_admin":false},"repo":{"id":42492315,"name":"WP-API","full_name":"adamsilverstein/WP-API","owner":{"login":"adamsilverstein","id":2676022,"avatar_url":"https://avatars.githubusercontent.com/u/2676022?v=3","gravatar_id":"","url":"https://api.github.com/users/adamsilverstein","html_url":"https://github.com/adamsilverstein","followers_url":"https://api.github.com/users/adamsilverstein/followers","following_url":"https://api.github.com/users/adamsilverstein/following{/other_user}","gists_url":"https://api.github.com/users/adamsilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/adamsilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamsilverstein/subscriptions","organizations_url":"https://api.github.com/users/adamsilverstein/orgs","repos_url":"https://api.github.com/users/adamsilverstein/repos","events_url":"https://api.github.com/users/adamsilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/adamsilverstein/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adamsilverstein/WP-API","description":"WP REST API - a JSON-based REST API for WordPress.","fork":true,"url":"https://api.github.com/repos/adamsilverstein/WP-API","forks_url":"https://api.github.com/repos/adamsilverstein/WP-API/forks","keys_url":"https://api.github.com/repos/adamsilverstein/WP-API/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adamsilverstein/WP-API/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adamsilverstein/WP-API/teams","hooks_url":"https://api.github.com/repos/adamsilverstein/WP-API/hooks","issue_events_url":"https://api.github.com/repos/adamsilverstein/WP-API/issues/events{/number}","events_url":"https://api.github.com/repos/adamsilverstein/WP-API/events","assignees_url":"https://api.github.com/repos/adamsilverstein/WP-API/assignees{/user}","branches_url":"https://api.github.com/repos/adamsilverstein/WP-API/branches{/branch}","tags_url":"https://api.github.com/repos/adamsilverstein/WP-API/tags","blobs_url":"https://api.github.com/repos/adamsilverstein/WP-API/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adamsilverstein/WP-API/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adamsilverstein/WP-API/git/refs{/sha}","trees_url":"https://api.github.com/repos/adamsilverstein/WP-API/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adamsilverstein/WP-API/statuses/{sha}","languages_url":"https://api.github.com/repos/adamsilverstein/WP-API/languages","stargazers_url":"https://api.github.com/repos/adamsilverstein/WP-API/stargazers","contributors_url":"https://api.github.com/repos/adamsilverstein/WP-API/contributors","subscribers_url":"https://api.github.com/repos/adamsilverstein/WP-API/subscribers","subscription_url":"https://api.github.com/repos/adamsilverstein/WP-API/subscription","commits_url":"https://api.github.com/repos/adamsilverstein/WP-API/commits{/sha}","git_commits_url":"https://api.github.com/repos/adamsilverstein/WP-API/git/commits{/sha}","comments_url":"https://api.github.com/repos/adamsilverstein/WP-API/comments{/number}","issue_comment_url":"https://api.github.com/repos/adamsilverstein/WP-API/issues/comments{/number}","contents_url":"https://api.github.com/repos/adamsilverstein/WP-API/contents/{+path}","compare_url":"https://api.github.com/repos/adamsilverstein/WP-API/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adamsilverstein/WP-API/merges","archive_url":"https://api.github.com/repos/adamsilverstein/WP-API/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adamsilverstein/WP-API/downloads","issues_url":"https://api.github.com/repos/adamsilverstein/WP-API/issues{/number}","pulls_url":"https://api.github.com/repos/adamsilverstein/WP-API/pulls{/number}","milestones_url":"https://api.github.com/repos/adamsilverstein/WP-API/milestones{/number}","notifications_url":"https://api.github.com/repos/adamsilverstein/WP-API/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adamsilverstein/WP-API/labels{/name}","releases_url":"https://api.github.com/repos/adamsilverstein/WP-API/releases{/id}","deployments_url":"https://api.github.com/repos/adamsilverstein/WP-API/deployments","created_at":"2015-09-15T03:18:06Z","updated_at":"2015-09-15T03:18:07Z","pushed_at":"2016-02-23T05:23:38Z","git_url":"git://github.com/adamsilverstein/WP-API.git","ssh_url":"git@github.com:adamsilverstein/WP-API.git","clone_url":"https://github.com/adamsilverstein/WP-API.git","svn_url":"https://github.com/adamsilverstein/WP-API","homepage":"http://v2.wp-api.org","size":6850,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"WP-API:develop","ref":"develop","sha":"be1ee54c3d98e0b0e80d811ddf0c846380985758","user":{"login":"WP-API","id":5706008,"avatar_url":"https://avatars.githubusercontent.com/u/5706008?v=3","gravatar_id":"","url":"https://api.github.com/users/WP-API","html_url":"https://github.com/WP-API","followers_url":"https://api.github.com/users/WP-API/followers","following_url":"https://api.github.com/users/WP-API/following{/other_user}","gists_url":"https://api.github.com/users/WP-API/gists{/gist_id}","starred_url":"https://api.github.com/users/WP-API/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WP-API/subscriptions","organizations_url":"https://api.github.com/users/WP-API/orgs","repos_url":"https://api.github.com/users/WP-API/repos","events_url":"https://api.github.com/users/WP-API/events{/privacy}","received_events_url":"https://api.github.com/users/WP-API/received_events","type":"Organization","site_admin":false},"repo":{"id":10420996,"name":"WP-API","full_name":"WP-API/WP-API","owner":{"login":"WP-API","id":5706008,"avatar_url":"https://avatars.githubusercontent.com/u/5706008?v=3","gravatar_id":"","url":"https://api.github.com/users/WP-API","html_url":"https://github.com/WP-API","followers_url":"https://api.github.com/users/WP-API/followers","following_url":"https://api.github.com/users/WP-API/following{/other_user}","gists_url":"https://api.github.com/users/WP-API/gists{/gist_id}","starred_url":"https://api.github.com/users/WP-API/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WP-API/subscriptions","organizations_url":"https://api.github.com/users/WP-API/orgs","repos_url":"https://api.github.com/users/WP-API/repos","events_url":"https://api.github.com/users/WP-API/events{/privacy}","received_events_url":"https://api.github.com/users/WP-API/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WP-API/WP-API","description":"WP REST API - a JSON-based REST API for WordPress.","fork":false,"url":"https://api.github.com/repos/WP-API/WP-API","forks_url":"https://api.github.com/repos/WP-API/WP-API/forks","keys_url":"https://api.github.com/repos/WP-API/WP-API/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WP-API/WP-API/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WP-API/WP-API/teams","hooks_url":"https://api.github.com/repos/WP-API/WP-API/hooks","issue_events_url":"https://api.github.com/repos/WP-API/WP-API/issues/events{/number}","events_url":"https://api.github.com/repos/WP-API/WP-API/events","assignees_url":"https://api.github.com/repos/WP-API/WP-API/assignees{/user}","branches_url":"https://api.github.com/repos/WP-API/WP-API/branches{/branch}","tags_url":"https://api.github.com/repos/WP-API/WP-API/tags","blobs_url":"https://api.github.com/repos/WP-API/WP-API/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WP-API/WP-API/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WP-API/WP-API/git/refs{/sha}","trees_url":"https://api.github.com/repos/WP-API/WP-API/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WP-API/WP-API/statuses/{sha}","languages_url":"https://api.github.com/repos/WP-API/WP-API/languages","stargazers_url":"https://api.github.com/repos/WP-API/WP-API/stargazers","contributors_url":"https://api.github.com/repos/WP-API/WP-API/contributors","subscribers_url":"https://api.github.com/repos/WP-API/WP-API/subscribers","subscription_url":"https://api.github.com/repos/WP-API/WP-API/subscription","commits_url":"https://api.github.com/repos/WP-API/WP-API/commits{/sha}","git_commits_url":"https://api.github.com/repos/WP-API/WP-API/git/commits{/sha}","comments_url":"https://api.github.com/repos/WP-API/WP-API/comments{/number}","issue_comment_url":"https://api.github.com/repos/WP-API/WP-API/issues/comments{/number}","contents_url":"https://api.github.com/repos/WP-API/WP-API/contents/{+path}","compare_url":"https://api.github.com/repos/WP-API/WP-API/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WP-API/WP-API/merges","archive_url":"https://api.github.com/repos/WP-API/WP-API/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WP-API/WP-API/downloads","issues_url":"https://api.github.com/repos/WP-API/WP-API/issues{/number}","pulls_url":"https://api.github.com/repos/WP-API/WP-API/pulls{/number}","milestones_url":"https://api.github.com/repos/WP-API/WP-API/milestones{/number}","notifications_url":"https://api.github.com/repos/WP-API/WP-API/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WP-API/WP-API/labels{/name}","releases_url":"https://api.github.com/repos/WP-API/WP-API/releases{/id}","deployments_url":"https://api.github.com/repos/WP-API/WP-API/deployments","created_at":"2013-06-01T10:52:43Z","updated_at":"2016-02-23T17:42:08Z","pushed_at":"2016-02-23T05:23:38Z","git_url":"git://github.com/WP-API/WP-API.git","ssh_url":"git@github.com:WP-API/WP-API.git","clone_url":"https://github.com/WP-API/WP-API.git","svn_url":"https://github.com/WP-API/WP-API","homepage":"http://v2.wp-api.org","size":8062,"stargazers_count":3011,"watchers_count":3011,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":551,"mirror_url":null,"open_issues_count":83,"forks":551,"open_issues":83,"watchers":3011,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/WP-API/WP-API/pulls/2303"},"html":{"href":"https://github.com/WP-API/WP-API/pull/2303"},"issue":{"href":"https://api.github.com/repos/WP-API/WP-API/issues/2303"},"comments":{"href":"https://api.github.com/repos/WP-API/WP-API/issues/2303/comments"},"review_comments":{"href":"https://api.github.com/repos/WP-API/WP-API/pulls/2303/comments"},"review_comment":{"href":"https://api.github.com/repos/WP-API/WP-API/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WP-API/WP-API/pulls/2303/commits"},"statuses":{"href":"https://api.github.com/repos/WP-API/WP-API/statuses/8257f8d59924b6c9b8ebfbb486434f09ebb68f4f"}}}}