{"action":"created","comment":{"url":"https://api.github.com/repos/DoSomething/phoenix/pulls/comments/42999708","id":42999708,"diff_hunk":"@@ -162,8 +162,11 @@ private function build($data, $full = false) {\n \n     if ($full) {\n       $northstar_user = dosomething_northstar_get_northstar_user($data->uid);\n-      $northstar_user = json_decode($northstar_user, true);\n-      $northstar_user = (object) $northstar_user['data'][0];\n+\n+      if (!empty($northstar_user)) {\n+        $northstar_user = json_decode($northstar_user, true);\n+        $northstar_user = (object) $northstar_user['data'][0];\n+      }\n \n       $this->user = [","path":"lib/modules/dosomething/dosomething_reportback/includes/Reportback.php","position":12,"original_position":12,"commit_id":"7eccf1e7b1a74c1ef6d743fc485a2ae1ff3b44a8","original_commit_id":"7eccf1e7b1a74c1ef6d743fc485a2ae1ff3b44a8","user":{"login":"weerd","id":105849,"avatar_url":"https://avatars.githubusercontent.com/u/105849?v=3","gravatar_id":"","url":"https://api.github.com/users/weerd","html_url":"https://github.com/weerd","followers_url":"https://api.github.com/users/weerd/followers","following_url":"https://api.github.com/users/weerd/following{/other_user}","gists_url":"https://api.github.com/users/weerd/gists{/gist_id}","starred_url":"https://api.github.com/users/weerd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weerd/subscriptions","organizations_url":"https://api.github.com/users/weerd/orgs","repos_url":"https://api.github.com/users/weerd/repos","events_url":"https://api.github.com/users/weerd/events{/privacy}","received_events_url":"https://api.github.com/users/weerd/received_events","type":"User","site_admin":false},"body":"Actually, scratch my suggestion above... it would make the returned data inconsistent and remove properties if `null` so wouldn't be as reliable... \r\n\r\ninstead, maybe just wrap the calls when assigning the properties on the user array to use the `dosomething_helpers_isset()`:\r\n\r\n```\r\n...\r\n  'first_name' => dosomething_helpers_isset($northstar_user->first_name),\r\n...","created_at":"2015-10-26T14:30:49Z","updated_at":"2015-10-26T14:30:49Z","html_url":"https://github.com/DoSomething/phoenix/pull/5616#discussion_r42999708","pull_request_url":"https://api.github.com/repos/DoSomething/phoenix/pulls/5616","_links":{"self":{"href":"https://api.github.com/repos/DoSomething/phoenix/pulls/comments/42999708"},"html":{"href":"https://github.com/DoSomething/phoenix/pull/5616#discussion_r42999708"},"pull_request":{"href":"https://api.github.com/repos/DoSomething/phoenix/pulls/5616"}}},"pull_request":{"url":"https://api.github.com/repos/DoSomething/phoenix/pulls/5616","id":48627861,"html_url":"https://github.com/DoSomething/phoenix/pull/5616","diff_url":"https://github.com/DoSomething/phoenix/pull/5616.diff","patch_url":"https://github.com/DoSomething/phoenix/pull/5616.patch","issue_url":"https://api.github.com/repos/DoSomething/phoenix/issues/5616","number":5616,"state":"open","locked":false,"title":"Adds !empty check before json_decode","user":{"login":"chloealee","id":9019452,"avatar_url":"https://avatars.githubusercontent.com/u/9019452?v=3","gravatar_id":"","url":"https://api.github.com/users/chloealee","html_url":"https://github.com/chloealee","followers_url":"https://api.github.com/users/chloealee/followers","following_url":"https://api.github.com/users/chloealee/following{/other_user}","gists_url":"https://api.github.com/users/chloealee/gists{/gist_id}","starred_url":"https://api.github.com/users/chloealee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chloealee/subscriptions","organizations_url":"https://api.github.com/users/chloealee/orgs","repos_url":"https://api.github.com/users/chloealee/repos","events_url":"https://api.github.com/users/chloealee/events{/privacy}","received_events_url":"https://api.github.com/users/chloealee/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\n\r\nAdds a check to see if ns user is null and if so, do not try to json_decode to prevent error:\r\n```\r\nif (!empty($northstar_user_info->error)) {\r\n        $error = sprintf(\"Error fetching Northstar user data, uid=%d: '%s'\", $id, $northstar_user_info->error);\r\n        watchdog_exception('northstar', new Exception($error));\r\n      } else {\r\n        cache_set('northstar_user_info_' . $id, $northstar_user_info, 'cache_northstar_user_info', REQUEST_TIME + 60*60*24);\r\n}\r\n```\r\n\r\n#### How should this be manually tested?\r\n\r\nendpoint: `/api/v1/reportbacks.json?load_user=true` should return user info. and not break. Works on local - tested by hard coding `$northstar_user_info == NULL` before new check and it by passed this correctly, return null for all user info in the api response. How do we test if this works with staging without merging?\r\n\r\nRight now, the request to ns to get user information remains the same as what's in this code, so we know that it's successfully getting user info. on staging.\r\n\r\n#### What are the relevant tickets?\r\n\r\n#5408","created_at":"2015-10-23T20:44:04Z","updated_at":"2015-10-26T14:30:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02db0eee6a90ce4b26657a58662d2973ca9ae5a3","assignee":{"login":"weerd","id":105849,"avatar_url":"https://avatars.githubusercontent.com/u/105849?v=3","gravatar_id":"","url":"https://api.github.com/users/weerd","html_url":"https://github.com/weerd","followers_url":"https://api.github.com/users/weerd/followers","following_url":"https://api.github.com/users/weerd/following{/other_user}","gists_url":"https://api.github.com/users/weerd/gists{/gist_id}","starred_url":"https://api.github.com/users/weerd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weerd/subscriptions","organizations_url":"https://api.github.com/users/weerd/orgs","repos_url":"https://api.github.com/users/weerd/repos","events_url":"https://api.github.com/users/weerd/events{/privacy}","received_events_url":"https://api.github.com/users/weerd/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/DoSomething/phoenix/pulls/5616/commits","review_comments_url":"https://api.github.com/repos/DoSomething/phoenix/pulls/5616/comments","review_comment_url":"https://api.github.com/repos/DoSomething/phoenix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DoSomething/phoenix/issues/5616/comments","statuses_url":"https://api.github.com/repos/DoSomething/phoenix/statuses/7eccf1e7b1a74c1ef6d743fc485a2ae1ff3b44a8","head":{"label":"chloealee:fix-reportback","ref":"fix-reportback","sha":"7eccf1e7b1a74c1ef6d743fc485a2ae1ff3b44a8","user":{"login":"chloealee","id":9019452,"avatar_url":"https://avatars.githubusercontent.com/u/9019452?v=3","gravatar_id":"","url":"https://api.github.com/users/chloealee","html_url":"https://github.com/chloealee","followers_url":"https://api.github.com/users/chloealee/followers","following_url":"https://api.github.com/users/chloealee/following{/other_user}","gists_url":"https://api.github.com/users/chloealee/gists{/gist_id}","starred_url":"https://api.github.com/users/chloealee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chloealee/subscriptions","organizations_url":"https://api.github.com/users/chloealee/orgs","repos_url":"https://api.github.com/users/chloealee/repos","events_url":"https://api.github.com/users/chloealee/events{/privacy}","received_events_url":"https://api.github.com/users/chloealee/received_events","type":"User","site_admin":false},"repo":{"id":38055093,"name":"dosomething","full_name":"chloealee/dosomething","owner":{"login":"chloealee","id":9019452,"avatar_url":"https://avatars.githubusercontent.com/u/9019452?v=3","gravatar_id":"","url":"https://api.github.com/users/chloealee","html_url":"https://github.com/chloealee","followers_url":"https://api.github.com/users/chloealee/followers","following_url":"https://api.github.com/users/chloealee/following{/other_user}","gists_url":"https://api.github.com/users/chloealee/gists{/gist_id}","starred_url":"https://api.github.com/users/chloealee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chloealee/subscriptions","organizations_url":"https://api.github.com/users/chloealee/orgs","repos_url":"https://api.github.com/users/chloealee/repos","events_url":"https://api.github.com/users/chloealee/events{/privacy}","received_events_url":"https://api.github.com/users/chloealee/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chloealee/dosomething","description":"A Drupal 7 distribution that powers the DoSomething.org web platform.","fork":true,"url":"https://api.github.com/repos/chloealee/dosomething","forks_url":"https://api.github.com/repos/chloealee/dosomething/forks","keys_url":"https://api.github.com/repos/chloealee/dosomething/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chloealee/dosomething/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chloealee/dosomething/teams","hooks_url":"https://api.github.com/repos/chloealee/dosomething/hooks","issue_events_url":"https://api.github.com/repos/chloealee/dosomething/issues/events{/number}","events_url":"https://api.github.com/repos/chloealee/dosomething/events","assignees_url":"https://api.github.com/repos/chloealee/dosomething/assignees{/user}","branches_url":"https://api.github.com/repos/chloealee/dosomething/branches{/branch}","tags_url":"https://api.github.com/repos/chloealee/dosomething/tags","blobs_url":"https://api.github.com/repos/chloealee/dosomething/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chloealee/dosomething/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chloealee/dosomething/git/refs{/sha}","trees_url":"https://api.github.com/repos/chloealee/dosomething/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chloealee/dosomething/statuses/{sha}","languages_url":"https://api.github.com/repos/chloealee/dosomething/languages","stargazers_url":"https://api.github.com/repos/chloealee/dosomething/stargazers","contributors_url":"https://api.github.com/repos/chloealee/dosomething/contributors","subscribers_url":"https://api.github.com/repos/chloealee/dosomething/subscribers","subscription_url":"https://api.github.com/repos/chloealee/dosomething/subscription","commits_url":"https://api.github.com/repos/chloealee/dosomething/commits{/sha}","git_commits_url":"https://api.github.com/repos/chloealee/dosomething/git/commits{/sha}","comments_url":"https://api.github.com/repos/chloealee/dosomething/comments{/number}","issue_comment_url":"https://api.github.com/repos/chloealee/dosomething/issues/comments{/number}","contents_url":"https://api.github.com/repos/chloealee/dosomething/contents/{+path}","compare_url":"https://api.github.com/repos/chloealee/dosomething/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chloealee/dosomething/merges","archive_url":"https://api.github.com/repos/chloealee/dosomething/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chloealee/dosomething/downloads","issues_url":"https://api.github.com/repos/chloealee/dosomething/issues{/number}","pulls_url":"https://api.github.com/repos/chloealee/dosomething/pulls{/number}","milestones_url":"https://api.github.com/repos/chloealee/dosomething/milestones{/number}","notifications_url":"https://api.github.com/repos/chloealee/dosomething/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chloealee/dosomething/labels{/name}","releases_url":"https://api.github.com/repos/chloealee/dosomething/releases{/id}","created_at":"2015-06-25T14:43:06Z","updated_at":"2015-06-25T14:43:08Z","pushed_at":"2015-10-23T20:40:10Z","git_url":"git://github.com/chloealee/dosomething.git","ssh_url":"git@github.com:chloealee/dosomething.git","clone_url":"https://github.com/chloealee/dosomething.git","svn_url":"https://github.com/chloealee/dosomething","homepage":"http://www.dosomething.org/","size":15007,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"DoSomething:dev","ref":"dev","sha":"0165865f993a63f772b5c6b8982796168c864145","user":{"login":"DoSomething","id":731685,"avatar_url":"https://avatars.githubusercontent.com/u/731685?v=3","gravatar_id":"","url":"https://api.github.com/users/DoSomething","html_url":"https://github.com/DoSomething","followers_url":"https://api.github.com/users/DoSomething/followers","following_url":"https://api.github.com/users/DoSomething/following{/other_user}","gists_url":"https://api.github.com/users/DoSomething/gists{/gist_id}","starred_url":"https://api.github.com/users/DoSomething/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DoSomething/subscriptions","organizations_url":"https://api.github.com/users/DoSomething/orgs","repos_url":"https://api.github.com/users/DoSomething/repos","events_url":"https://api.github.com/users/DoSomething/events{/privacy}","received_events_url":"https://api.github.com/users/DoSomething/received_events","type":"Organization","site_admin":false},"repo":{"id":13592927,"name":"phoenix","full_name":"DoSomething/phoenix","owner":{"login":"DoSomething","id":731685,"avatar_url":"https://avatars.githubusercontent.com/u/731685?v=3","gravatar_id":"","url":"https://api.github.com/users/DoSomething","html_url":"https://github.com/DoSomething","followers_url":"https://api.github.com/users/DoSomething/followers","following_url":"https://api.github.com/users/DoSomething/following{/other_user}","gists_url":"https://api.github.com/users/DoSomething/gists{/gist_id}","starred_url":"https://api.github.com/users/DoSomething/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DoSomething/subscriptions","organizations_url":"https://api.github.com/users/DoSomething/orgs","repos_url":"https://api.github.com/users/DoSomething/repos","events_url":"https://api.github.com/users/DoSomething/events{/privacy}","received_events_url":"https://api.github.com/users/DoSomething/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DoSomething/phoenix","description":"A Drupal 7 distribution that powers the DoSomething.org web platform.","fork":false,"url":"https://api.github.com/repos/DoSomething/phoenix","forks_url":"https://api.github.com/repos/DoSomething/phoenix/forks","keys_url":"https://api.github.com/repos/DoSomething/phoenix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DoSomething/phoenix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DoSomething/phoenix/teams","hooks_url":"https://api.github.com/repos/DoSomething/phoenix/hooks","issue_events_url":"https://api.github.com/repos/DoSomething/phoenix/issues/events{/number}","events_url":"https://api.github.com/repos/DoSomething/phoenix/events","assignees_url":"https://api.github.com/repos/DoSomething/phoenix/assignees{/user}","branches_url":"https://api.github.com/repos/DoSomething/phoenix/branches{/branch}","tags_url":"https://api.github.com/repos/DoSomething/phoenix/tags","blobs_url":"https://api.github.com/repos/DoSomething/phoenix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DoSomething/phoenix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DoSomething/phoenix/git/refs{/sha}","trees_url":"https://api.github.com/repos/DoSomething/phoenix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DoSomething/phoenix/statuses/{sha}","languages_url":"https://api.github.com/repos/DoSomething/phoenix/languages","stargazers_url":"https://api.github.com/repos/DoSomething/phoenix/stargazers","contributors_url":"https://api.github.com/repos/DoSomething/phoenix/contributors","subscribers_url":"https://api.github.com/repos/DoSomething/phoenix/subscribers","subscription_url":"https://api.github.com/repos/DoSomething/phoenix/subscription","commits_url":"https://api.github.com/repos/DoSomething/phoenix/commits{/sha}","git_commits_url":"https://api.github.com/repos/DoSomething/phoenix/git/commits{/sha}","comments_url":"https://api.github.com/repos/DoSomething/phoenix/comments{/number}","issue_comment_url":"https://api.github.com/repos/DoSomething/phoenix/issues/comments{/number}","contents_url":"https://api.github.com/repos/DoSomething/phoenix/contents/{+path}","compare_url":"https://api.github.com/repos/DoSomething/phoenix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DoSomething/phoenix/merges","archive_url":"https://api.github.com/repos/DoSomething/phoenix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DoSomething/phoenix/downloads","issues_url":"https://api.github.com/repos/DoSomething/phoenix/issues{/number}","pulls_url":"https://api.github.com/repos/DoSomething/phoenix/pulls{/number}","milestones_url":"https://api.github.com/repos/DoSomething/phoenix/milestones{/number}","notifications_url":"https://api.github.com/repos/DoSomething/phoenix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DoSomething/phoenix/labels{/name}","releases_url":"https://api.github.com/repos/DoSomething/phoenix/releases{/id}","created_at":"2013-10-15T14:50:48Z","updated_at":"2015-07-23T19:32:25Z","pushed_at":"2015-10-26T14:19:33Z","git_url":"git://github.com/DoSomething/phoenix.git","ssh_url":"git@github.com:DoSomething/phoenix.git","clone_url":"https://github.com/DoSomething/phoenix.git","svn_url":"https://github.com/DoSomething/phoenix","homepage":"http://www.dosomething.org/","size":29111,"stargazers_count":25,"watchers_count":25,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":321,"forks":19,"open_issues":321,"watchers":25,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/DoSomething/phoenix/pulls/5616"},"html":{"href":"https://github.com/DoSomething/phoenix/pull/5616"},"issue":{"href":"https://api.github.com/repos/DoSomething/phoenix/issues/5616"},"comments":{"href":"https://api.github.com/repos/DoSomething/phoenix/issues/5616/comments"},"review_comments":{"href":"https://api.github.com/repos/DoSomething/phoenix/pulls/5616/comments"},"review_comment":{"href":"https://api.github.com/repos/DoSomething/phoenix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DoSomething/phoenix/pulls/5616/commits"},"statuses":{"href":"https://api.github.com/repos/DoSomething/phoenix/statuses/7eccf1e7b1a74c1ef6d743fc485a2ae1ff3b44a8"}}}}