{"action":"created","comment":{"url":"https://api.github.com/repos/WP-API/WP-API/pulls/comments/25561361","id":25561361,"diff_hunk":"@@ -638,6 +638,19 @@ public function dispatch( $request ) {\n \t\t\t\t\t$response = json_ensure_response( $response );\n \t\t\t\t}\n \n+\t\t\t\t$data = $response->get_data();\n+\t\t\t\t$properties = ! empty( $handler['schema']['properties'] ) ? $handler['schema']['properties'] : array();\n+\t\t\t\tforeach( $properties as $key => $field_args ) {\n+\t\t\t\t\tif ( ! isset( $field_args['context'] ) ) {\n+\t\t\t\t\t\tcontinue;\n+\t\t\t\t\t}\n+\t\t\t\t\t$context = (array) $field_args['context'];\n+\t\t\t\t\tif ( ! in_array( $request['context'], $context ) ) {","path":"lib/infrastructure/class-wp-json-server.php","position":11,"original_position":11,"commit_id":"d2360f6a712ae0e30ff0d2a785c79ac144672ef8","original_commit_id":"d2360f6a712ae0e30ff0d2a785c79ac144672ef8","user":{"login":"danielbachhuber","id":36432,"avatar_url":"https://avatars.githubusercontent.com/u/36432?v=3","gravatar_id":"","url":"https://api.github.com/users/danielbachhuber","html_url":"https://github.com/danielbachhuber","followers_url":"https://api.github.com/users/danielbachhuber/followers","following_url":"https://api.github.com/users/danielbachhuber/following{/other_user}","gists_url":"https://api.github.com/users/danielbachhuber/gists{/gist_id}","starred_url":"https://api.github.com/users/danielbachhuber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielbachhuber/subscriptions","organizations_url":"https://api.github.com/users/danielbachhuber/orgs","repos_url":"https://api.github.com/users/danielbachhuber/repos","events_url":"https://api.github.com/users/danielbachhuber/events{/privacy}","received_events_url":"https://api.github.com/users/danielbachhuber/received_events","type":"User","site_admin":false},"body":"There's a problem with this code in that, for create / update requests, the `$request['context']` is set within the controller's method, and not exposed back to the server:\r\n\r\n```\r\nNULL\r\nstatus\r\narray (\r\n  0 => 'embed',\r\n  1 => 'view',\r\n  2 => 'edit',\r\n)\r\nNULL\r\ntype\r\narray (\r\n  0 => 'embed',\r\n  1 => 'view',\r\n  2 => 'edit',\r\n)\r\n```\r\n\r\nFor create / update requests, we should probably have `context=edit` by default. And it would be nice to get some final context from the response object.","created_at":"2015-02-28T21:22:31Z","updated_at":"2015-02-28T21:22:31Z","html_url":"https://github.com/WP-API/WP-API/pull/949#discussion_r25561361","pull_request_url":"https://api.github.com/repos/WP-API/WP-API/pulls/949","_links":{"self":{"href":"https://api.github.com/repos/WP-API/WP-API/pulls/comments/25561361"},"html":{"href":"https://github.com/WP-API/WP-API/pull/949#discussion_r25561361"},"pull_request":{"href":"https://api.github.com/repos/WP-API/WP-API/pulls/949"}}},"pull_request":{"url":"https://api.github.com/repos/WP-API/WP-API/pulls/949","id":30230887,"html_url":"https://github.com/WP-API/WP-API/pull/949","diff_url":"https://github.com/WP-API/WP-API/pull/949.diff","patch_url":"https://github.com/WP-API/WP-API/pull/949.patch","issue_url":"https://api.github.com/repos/WP-API/WP-API/issues/949","number":949,"state":"open","locked":false,"title":"POC Use schema to limit returned fields for context","user":{"login":"danielbachhuber","id":36432,"avatar_url":"https://avatars.githubusercontent.com/u/36432?v=3","gravatar_id":"","url":"https://api.github.com/users/danielbachhuber","html_url":"https://github.com/danielbachhuber","followers_url":"https://api.github.com/users/danielbachhuber/followers","following_url":"https://api.github.com/users/danielbachhuber/following{/other_user}","gists_url":"https://api.github.com/users/danielbachhuber/gists{/gist_id}","starred_url":"https://api.github.com/users/danielbachhuber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielbachhuber/subscriptions","organizations_url":"https://api.github.com/users/danielbachhuber/orgs","repos_url":"https://api.github.com/users/danielbachhuber/repos","events_url":"https://api.github.com/users/danielbachhuber/events{/privacy}","received_events_url":"https://api.github.com/users/danielbachhuber/received_events","type":"User","site_admin":false},"body":"See #894, #893, #605","created_at":"2015-02-28T20:56:32Z","updated_at":"2015-02-28T21:22:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb88a88820370e7184e0d828e7c87effef15a9af","assignee":null,"milestone":{"url":"https://api.github.com/repos/WP-API/WP-API/milestones/10","html_url":"https://github.com/WP-API/WP-API/milestones/2.0","labels_url":"https://api.github.com/repos/WP-API/WP-API/milestones/10/labels","id":844496,"number":10,"title":"2.0","description":null,"creator":{"login":"danielbachhuber","id":36432,"avatar_url":"https://avatars.githubusercontent.com/u/36432?v=3","gravatar_id":"","url":"https://api.github.com/users/danielbachhuber","html_url":"https://github.com/danielbachhuber","followers_url":"https://api.github.com/users/danielbachhuber/followers","following_url":"https://api.github.com/users/danielbachhuber/following{/other_user}","gists_url":"https://api.github.com/users/danielbachhuber/gists{/gist_id}","starred_url":"https://api.github.com/users/danielbachhuber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielbachhuber/subscriptions","organizations_url":"https://api.github.com/users/danielbachhuber/orgs","repos_url":"https://api.github.com/users/danielbachhuber/repos","events_url":"https://api.github.com/users/danielbachhuber/events{/privacy}","received_events_url":"https://api.github.com/users/danielbachhuber/received_events","type":"User","site_admin":false},"open_issues":93,"closed_issues":148,"state":"open","created_at":"2014-10-29T00:12:18Z","updated_at":"2015-02-28T21:18:22Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/WP-API/WP-API/pulls/949/commits","review_comments_url":"https://api.github.com/repos/WP-API/WP-API/pulls/949/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/949/comments","statuses_url":"https://api.github.com/repos/WP-API/WP-API/statuses/d2360f6a712ae0e30ff0d2a785c79ac144672ef8","head":{"label":"WP-API:894-context-schema","ref":"894-context-schema","sha":"d2360f6a712ae0e30ff0d2a785c79ac144672ef8","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}","created_at":"2013-06-01T10:52:43Z","updated_at":"2015-02-28T21:09:31Z","pushed_at":"2015-02-28T21:20:46Z","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://wp-api.org","size":8374,"stargazers_count":1616,"watchers_count":1616,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":291,"mirror_url":null,"open_issues_count":194,"forks":291,"open_issues":194,"watchers":1616,"default_branch":"develop"}},"base":{"label":"WP-API:develop","ref":"develop","sha":"bb79d5bacdf38f4a97d4842386d214deae6d67f1","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}","created_at":"2013-06-01T10:52:43Z","updated_at":"2015-02-28T21:09:31Z","pushed_at":"2015-02-28T21:20:46Z","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://wp-api.org","size":8374,"stargazers_count":1616,"watchers_count":1616,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":291,"mirror_url":null,"open_issues_count":194,"forks":291,"open_issues":194,"watchers":1616,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/WP-API/WP-API/pulls/949"},"html":{"href":"https://github.com/WP-API/WP-API/pull/949"},"issue":{"href":"https://api.github.com/repos/WP-API/WP-API/issues/949"},"comments":{"href":"https://api.github.com/repos/WP-API/WP-API/issues/949/comments"},"review_comments":{"href":"https://api.github.com/repos/WP-API/WP-API/pulls/949/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/949/commits"},"statuses":{"href":"https://api.github.com/repos/WP-API/WP-API/statuses/d2360f6a712ae0e30ff0d2a785c79ac144672ef8"}}}}