{"action":"created","comment":{"url":"https://api.github.com/repos/humanitarianresponse/site/pulls/comments/40919974","id":40919974,"diff_hunk":"@@ -67,71 +79,70 @@ function hid_profiles_settings_form($form, &$form_state) {\n  * @param boolean $extended\n  *  Option to return extended information about organizations.\n  *\n- * @return\n- *  JSON output of the matching Organizations array.\n+ * @TODO: Convert this to an endpoint for HID.\n  */\n function hid_organizations_autocomplete($org_names, $extended = FALSE) {\n   $matches = array();\n-\n-  // Get the vocabulary for the Organizations to limit the term query by VID.\n-  $vocabulary = taxonomy_vocabulary_machine_name_load('hr_organization');\n+  if (empty($org_names)) {\n+    _hid_profiles_json_helper($matches);\n+  }\n \n   // Determine the max number of Organizations to return per request.\n   $limit = variable_get('hid_organizations_autocomplete_limit', 30);\n-\n-  // Limit the query to \"begins with\" or \"contains\"\n+  // Limit the query to \"starts with\" or \"contains\"\n   $contains = variable_get('hid_organizations_autocomplete_true', TRUE);\n-  $contains_delimiter = ($contains) ? '%' : '';\n-\n-  // Search for hr_organization taxonomy terms, where the term name or\n-  // organization field value match the given search string.\n-  $query = db_select('taxonomy_term_data', 't');\n-  $query->leftJoin('field_data_field_acronym', 'fdfa', '(t.tid = fdfa.entity_id AND fdfa.entity_type = :fdfa_type)', array(':fdfa_type' => 'taxonomy_term'));\n-  $query->leftJoin('field_data_field_organization_type', 'fot', 't.tid = fot.entity_id');\n-  $query->leftJoin('field_data_name_field', 'fnf', 'fot.field_organization_type_target_id = fnf.entity_id');\n-\n-  $query\n-    ->fields('t')\n-    ->fields('fdfa')\n-    ->fields('fot')\n-    ->fields('fnf')\n-    ->condition('t.vid', $vocabulary->vid)\n-    ->condition('fnf.language', 'en')\n-    ->condition('fdfa.language', 'en');\n-\n-  $or = db_or();\n-  $or->condition('t.name', $contains_delimiter . db_like($org_names) . '%', 'LIKE');\n-  $or->condition('fdfa.field_acronym_value', $contains_delimiter . db_like($org_names) . '%', 'LIKE');\n-\n-  $return = $query\n-    ->condition($or)\n+  $operator = ($contains) ? 'CONTAINS' : 'STARTS_WITH';\n+\n+  // Query the terms by name.\n+  $query = new EntityFieldQuery();\n+  $results = $query\n+    ->entityCondition('entity_type', 'taxonomy_term')\n+    ->entityCondition('bundle', 'hr_organization')\n+    ->propertyCondition('name', db_like($org_names), $operator)\n     ->range(0, $limit)\n     ->execute();\n+  $data = reset($results);\n+\n+  // If there are not enough results, look for acronyms as well.\n+  if (count($data) < $limit) {\n+    $query = new EntityFieldQuery();\n+    $results = $query\n+      ->entityCondition('entity_type', 'taxonomy_term')\n+      ->entityCondition('bundle', 'hr_organization')\n+      ->fieldCondition('field_acronym', 'value', db_like($org_names), $operator)\n+      ->propertyCondition('tid', array_keys($data), 'NOT IN')\n+      ->range(0, $limit)\n+      ->execute();\n+    $data += reset($results);","path":"sites/all/modules/hid/hid_profiles/hid_profiles.pages.inc","position":88,"original_position":88,"commit_id":"4e2622b22b6b6ae7d0faadfec384f3d6bc872970","original_commit_id":"4e2622b22b6b6ae7d0faadfec384f3d6bc872970","user":{"login":"guillaumev","id":90224,"avatar_url":"https://avatars.githubusercontent.com/u/90224?v=3","gravatar_id":"","url":"https://api.github.com/users/guillaumev","html_url":"https://github.com/guillaumev","followers_url":"https://api.github.com/users/guillaumev/followers","following_url":"https://api.github.com/users/guillaumev/following{/other_user}","gists_url":"https://api.github.com/users/guillaumev/gists{/gist_id}","starred_url":"https://api.github.com/users/guillaumev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guillaumev/subscriptions","organizations_url":"https://api.github.com/users/guillaumev/orgs","repos_url":"https://api.github.com/users/guillaumev/repos","events_url":"https://api.github.com/users/guillaumev/events{/privacy}","received_events_url":"https://api.github.com/users/guillaumev/received_events","type":"User","site_admin":false},"body":"@pcambra I'm getting an \"unsupported operand types\" on this line. Did you test it in your env ? If so and if it works, which version of PHP are you running ?","created_at":"2015-10-01T14:35:13Z","updated_at":"2015-10-01T14:35:13Z","html_url":"https://github.com/humanitarianresponse/site/pull/106#discussion_r40919974","pull_request_url":"https://api.github.com/repos/humanitarianresponse/site/pulls/106","_links":{"self":{"href":"https://api.github.com/repos/humanitarianresponse/site/pulls/comments/40919974"},"html":{"href":"https://github.com/humanitarianresponse/site/pull/106#discussion_r40919974"},"pull_request":{"href":"https://api.github.com/repos/humanitarianresponse/site/pulls/106"}}},"pull_request":{"url":"https://api.github.com/repos/humanitarianresponse/site/pulls/106","id":45636653,"html_url":"https://github.com/humanitarianresponse/site/pull/106","diff_url":"https://github.com/humanitarianresponse/site/pull/106.diff","patch_url":"https://github.com/humanitarianresponse/site/pull/106.patch","issue_url":"https://api.github.com/repos/humanitarianresponse/site/issues/106","number":106,"state":"open","locked":false,"title":"#105: fixed issue with organizations with no acronym not being pulled…","user":{"login":"guillaumev","id":90224,"avatar_url":"https://avatars.githubusercontent.com/u/90224?v=3","gravatar_id":"","url":"https://api.github.com/users/guillaumev","html_url":"https://github.com/guillaumev","followers_url":"https://api.github.com/users/guillaumev/followers","following_url":"https://api.github.com/users/guillaumev/following{/other_user}","gists_url":"https://api.github.com/users/guillaumev/gists{/gist_id}","starred_url":"https://api.github.com/users/guillaumev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guillaumev/subscriptions","organizations_url":"https://api.github.com/users/guillaumev/orgs","repos_url":"https://api.github.com/users/guillaumev/repos","events_url":"https://api.github.com/users/guillaumev/events{/privacy}","received_events_url":"https://api.github.com/users/guillaumev/received_events","type":"User","site_admin":false},"body":"… from HRinfo into HID","created_at":"2015-09-22T08:17:06Z","updated_at":"2015-10-01T14:35:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cac666567483c531dc0aacfac0cbb97a8fe76755","assignee":{"login":"pcambra","id":104912,"avatar_url":"https://avatars.githubusercontent.com/u/104912?v=3","gravatar_id":"","url":"https://api.github.com/users/pcambra","html_url":"https://github.com/pcambra","followers_url":"https://api.github.com/users/pcambra/followers","following_url":"https://api.github.com/users/pcambra/following{/other_user}","gists_url":"https://api.github.com/users/pcambra/gists{/gist_id}","starred_url":"https://api.github.com/users/pcambra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pcambra/subscriptions","organizations_url":"https://api.github.com/users/pcambra/orgs","repos_url":"https://api.github.com/users/pcambra/repos","events_url":"https://api.github.com/users/pcambra/events{/privacy}","received_events_url":"https://api.github.com/users/pcambra/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/humanitarianresponse/site/pulls/106/commits","review_comments_url":"https://api.github.com/repos/humanitarianresponse/site/pulls/106/comments","review_comment_url":"https://api.github.com/repos/humanitarianresponse/site/pulls/comments{/number}","comments_url":"https://api.github.com/repos/humanitarianresponse/site/issues/106/comments","statuses_url":"https://api.github.com/repos/humanitarianresponse/site/statuses/4e2622b22b6b6ae7d0faadfec384f3d6bc872970","head":{"label":"humanitarianresponse:hrinfo-105","ref":"hrinfo-105","sha":"4e2622b22b6b6ae7d0faadfec384f3d6bc872970","user":{"login":"humanitarianresponse","id":2563984,"avatar_url":"https://avatars.githubusercontent.com/u/2563984?v=3","gravatar_id":"","url":"https://api.github.com/users/humanitarianresponse","html_url":"https://github.com/humanitarianresponse","followers_url":"https://api.github.com/users/humanitarianresponse/followers","following_url":"https://api.github.com/users/humanitarianresponse/following{/other_user}","gists_url":"https://api.github.com/users/humanitarianresponse/gists{/gist_id}","starred_url":"https://api.github.com/users/humanitarianresponse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/humanitarianresponse/subscriptions","organizations_url":"https://api.github.com/users/humanitarianresponse/orgs","repos_url":"https://api.github.com/users/humanitarianresponse/repos","events_url":"https://api.github.com/users/humanitarianresponse/events{/privacy}","received_events_url":"https://api.github.com/users/humanitarianresponse/received_events","type":"Organization","site_admin":false},"repo":{"id":39127839,"name":"site","full_name":"humanitarianresponse/site","owner":{"login":"humanitarianresponse","id":2563984,"avatar_url":"https://avatars.githubusercontent.com/u/2563984?v=3","gravatar_id":"","url":"https://api.github.com/users/humanitarianresponse","html_url":"https://github.com/humanitarianresponse","followers_url":"https://api.github.com/users/humanitarianresponse/followers","following_url":"https://api.github.com/users/humanitarianresponse/following{/other_user}","gists_url":"https://api.github.com/users/humanitarianresponse/gists{/gist_id}","starred_url":"https://api.github.com/users/humanitarianresponse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/humanitarianresponse/subscriptions","organizations_url":"https://api.github.com/users/humanitarianresponse/orgs","repos_url":"https://api.github.com/users/humanitarianresponse/repos","events_url":"https://api.github.com/users/humanitarianresponse/events{/privacy}","received_events_url":"https://api.github.com/users/humanitarianresponse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/humanitarianresponse/site","description":"","fork":false,"url":"https://api.github.com/repos/humanitarianresponse/site","forks_url":"https://api.github.com/repos/humanitarianresponse/site/forks","keys_url":"https://api.github.com/repos/humanitarianresponse/site/keys{/key_id}","collaborators_url":"https://api.github.com/repos/humanitarianresponse/site/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/humanitarianresponse/site/teams","hooks_url":"https://api.github.com/repos/humanitarianresponse/site/hooks","issue_events_url":"https://api.github.com/repos/humanitarianresponse/site/issues/events{/number}","events_url":"https://api.github.com/repos/humanitarianresponse/site/events","assignees_url":"https://api.github.com/repos/humanitarianresponse/site/assignees{/user}","branches_url":"https://api.github.com/repos/humanitarianresponse/site/branches{/branch}","tags_url":"https://api.github.com/repos/humanitarianresponse/site/tags","blobs_url":"https://api.github.com/repos/humanitarianresponse/site/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/humanitarianresponse/site/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/humanitarianresponse/site/git/refs{/sha}","trees_url":"https://api.github.com/repos/humanitarianresponse/site/git/trees{/sha}","statuses_url":"https://api.github.com/repos/humanitarianresponse/site/statuses/{sha}","languages_url":"https://api.github.com/repos/humanitarianresponse/site/languages","stargazers_url":"https://api.github.com/repos/humanitarianresponse/site/stargazers","contributors_url":"https://api.github.com/repos/humanitarianresponse/site/contributors","subscribers_url":"https://api.github.com/repos/humanitarianresponse/site/subscribers","subscription_url":"https://api.github.com/repos/humanitarianresponse/site/subscription","commits_url":"https://api.github.com/repos/humanitarianresponse/site/commits{/sha}","git_commits_url":"https://api.github.com/repos/humanitarianresponse/site/git/commits{/sha}","comments_url":"https://api.github.com/repos/humanitarianresponse/site/comments{/number}","issue_comment_url":"https://api.github.com/repos/humanitarianresponse/site/issues/comments{/number}","contents_url":"https://api.github.com/repos/humanitarianresponse/site/contents/{+path}","compare_url":"https://api.github.com/repos/humanitarianresponse/site/compare/{base}...{head}","merges_url":"https://api.github.com/repos/humanitarianresponse/site/merges","archive_url":"https://api.github.com/repos/humanitarianresponse/site/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/humanitarianresponse/site/downloads","issues_url":"https://api.github.com/repos/humanitarianresponse/site/issues{/number}","pulls_url":"https://api.github.com/repos/humanitarianresponse/site/pulls{/number}","milestones_url":"https://api.github.com/repos/humanitarianresponse/site/milestones{/number}","notifications_url":"https://api.github.com/repos/humanitarianresponse/site/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/humanitarianresponse/site/labels{/name}","releases_url":"https://api.github.com/repos/humanitarianresponse/site/releases{/id}","created_at":"2015-07-15T09:22:04Z","updated_at":"2015-09-21T08:48:34Z","pushed_at":"2015-10-01T12:19:31Z","git_url":"git://github.com/humanitarianresponse/site.git","ssh_url":"git@github.com:humanitarianresponse/site.git","clone_url":"https://github.com/humanitarianresponse/site.git","svn_url":"https://github.com/humanitarianresponse/site","homepage":null,"size":45935,"stargazers_count":3,"watchers_count":3,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":49,"forks":1,"open_issues":49,"watchers":3,"default_branch":"dev"}},"base":{"label":"humanitarianresponse:dev","ref":"dev","sha":"26611d8ba0d9a6696728ad328e15f54771c7a13d","user":{"login":"humanitarianresponse","id":2563984,"avatar_url":"https://avatars.githubusercontent.com/u/2563984?v=3","gravatar_id":"","url":"https://api.github.com/users/humanitarianresponse","html_url":"https://github.com/humanitarianresponse","followers_url":"https://api.github.com/users/humanitarianresponse/followers","following_url":"https://api.github.com/users/humanitarianresponse/following{/other_user}","gists_url":"https://api.github.com/users/humanitarianresponse/gists{/gist_id}","starred_url":"https://api.github.com/users/humanitarianresponse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/humanitarianresponse/subscriptions","organizations_url":"https://api.github.com/users/humanitarianresponse/orgs","repos_url":"https://api.github.com/users/humanitarianresponse/repos","events_url":"https://api.github.com/users/humanitarianresponse/events{/privacy}","received_events_url":"https://api.github.com/users/humanitarianresponse/received_events","type":"Organization","site_admin":false},"repo":{"id":39127839,"name":"site","full_name":"humanitarianresponse/site","owner":{"login":"humanitarianresponse","id":2563984,"avatar_url":"https://avatars.githubusercontent.com/u/2563984?v=3","gravatar_id":"","url":"https://api.github.com/users/humanitarianresponse","html_url":"https://github.com/humanitarianresponse","followers_url":"https://api.github.com/users/humanitarianresponse/followers","following_url":"https://api.github.com/users/humanitarianresponse/following{/other_user}","gists_url":"https://api.github.com/users/humanitarianresponse/gists{/gist_id}","starred_url":"https://api.github.com/users/humanitarianresponse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/humanitarianresponse/subscriptions","organizations_url":"https://api.github.com/users/humanitarianresponse/orgs","repos_url":"https://api.github.com/users/humanitarianresponse/repos","events_url":"https://api.github.com/users/humanitarianresponse/events{/privacy}","received_events_url":"https://api.github.com/users/humanitarianresponse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/humanitarianresponse/site","description":"","fork":false,"url":"https://api.github.com/repos/humanitarianresponse/site","forks_url":"https://api.github.com/repos/humanitarianresponse/site/forks","keys_url":"https://api.github.com/repos/humanitarianresponse/site/keys{/key_id}","collaborators_url":"https://api.github.com/repos/humanitarianresponse/site/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/humanitarianresponse/site/teams","hooks_url":"https://api.github.com/repos/humanitarianresponse/site/hooks","issue_events_url":"https://api.github.com/repos/humanitarianresponse/site/issues/events{/number}","events_url":"https://api.github.com/repos/humanitarianresponse/site/events","assignees_url":"https://api.github.com/repos/humanitarianresponse/site/assignees{/user}","branches_url":"https://api.github.com/repos/humanitarianresponse/site/branches{/branch}","tags_url":"https://api.github.com/repos/humanitarianresponse/site/tags","blobs_url":"https://api.github.com/repos/humanitarianresponse/site/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/humanitarianresponse/site/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/humanitarianresponse/site/git/refs{/sha}","trees_url":"https://api.github.com/repos/humanitarianresponse/site/git/trees{/sha}","statuses_url":"https://api.github.com/repos/humanitarianresponse/site/statuses/{sha}","languages_url":"https://api.github.com/repos/humanitarianresponse/site/languages","stargazers_url":"https://api.github.com/repos/humanitarianresponse/site/stargazers","contributors_url":"https://api.github.com/repos/humanitarianresponse/site/contributors","subscribers_url":"https://api.github.com/repos/humanitarianresponse/site/subscribers","subscription_url":"https://api.github.com/repos/humanitarianresponse/site/subscription","commits_url":"https://api.github.com/repos/humanitarianresponse/site/commits{/sha}","git_commits_url":"https://api.github.com/repos/humanitarianresponse/site/git/commits{/sha}","comments_url":"https://api.github.com/repos/humanitarianresponse/site/comments{/number}","issue_comment_url":"https://api.github.com/repos/humanitarianresponse/site/issues/comments{/number}","contents_url":"https://api.github.com/repos/humanitarianresponse/site/contents/{+path}","compare_url":"https://api.github.com/repos/humanitarianresponse/site/compare/{base}...{head}","merges_url":"https://api.github.com/repos/humanitarianresponse/site/merges","archive_url":"https://api.github.com/repos/humanitarianresponse/site/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/humanitarianresponse/site/downloads","issues_url":"https://api.github.com/repos/humanitarianresponse/site/issues{/number}","pulls_url":"https://api.github.com/repos/humanitarianresponse/site/pulls{/number}","milestones_url":"https://api.github.com/repos/humanitarianresponse/site/milestones{/number}","notifications_url":"https://api.github.com/repos/humanitarianresponse/site/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/humanitarianresponse/site/labels{/name}","releases_url":"https://api.github.com/repos/humanitarianresponse/site/releases{/id}","created_at":"2015-07-15T09:22:04Z","updated_at":"2015-09-21T08:48:34Z","pushed_at":"2015-10-01T12:19:31Z","git_url":"git://github.com/humanitarianresponse/site.git","ssh_url":"git@github.com:humanitarianresponse/site.git","clone_url":"https://github.com/humanitarianresponse/site.git","svn_url":"https://github.com/humanitarianresponse/site","homepage":null,"size":45935,"stargazers_count":3,"watchers_count":3,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":49,"forks":1,"open_issues":49,"watchers":3,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/humanitarianresponse/site/pulls/106"},"html":{"href":"https://github.com/humanitarianresponse/site/pull/106"},"issue":{"href":"https://api.github.com/repos/humanitarianresponse/site/issues/106"},"comments":{"href":"https://api.github.com/repos/humanitarianresponse/site/issues/106/comments"},"review_comments":{"href":"https://api.github.com/repos/humanitarianresponse/site/pulls/106/comments"},"review_comment":{"href":"https://api.github.com/repos/humanitarianresponse/site/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/humanitarianresponse/site/pulls/106/commits"},"statuses":{"href":"https://api.github.com/repos/humanitarianresponse/site/statuses/4e2622b22b6b6ae7d0faadfec384f3d6bc872970"}}}}