{"action":"created","comment":{"url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls/comments/29034882","id":29034882,"diff_hunk":"@@ -30,11 +32,124 @@\n      *\n      * @param \\eZ\\Publish\\Core\\Persistence\\Database\\DatabaseHandler $dbHandler\n      * @param \\eZ\\Publish\\SPI\\Persistence\\Content\\Type\\Handler $contentTypeHandler\n+     * @param \\eZ\\Publish\\SPI\\Persistence\\Content\\Language\\Handler $languageHandler\n      */\n-    public function __construct( DatabaseHandler $dbHandler, ContentTypeHandler $contentTypeHandler )\n+    public function __construct(\n+        DatabaseHandler $dbHandler,\n+        ContentTypeHandler $contentTypeHandler,\n+        LanguageHandler $languageHandler\n+    )\n     {\n         parent::__construct( $dbHandler );\n \n         $this->contentTypeHandler = $contentTypeHandler;\n+        $this->languageHandler = $languageHandler;\n+    }\n+\n+    /**\n+     * Returns the bitmask for the list languages in given $fieldFilters\n+     *\n+     * The method will return null if no languages are contained in $fieldFilters.\n+     * Note: 'useAlwaysAvailable' filter is ignored here.\n+     *\n+     * @param array $fieldFilters\n+     *\n+     * @return null|int\n+     */\n+    protected function getFieldFiltersLanguageMask( array $fieldFilters )\n+    {\n+        if ( empty( $fieldFilters[\"languages\"] ) )\n+        {\n+            return null;\n+        }\n+\n+        $mask = 0;\n+\n+        foreach ( $fieldFilters[\"languages\"] as $languageCode )\n+        {\n+            $mask |= $this->languageHandler->loadByLanguageCode( $languageCode )->id;\n+        }\n+\n+        return $mask;\n+    }\n+\n+    /**\n+     * Adds filed filters condition to the WHERE clause of the given $query.","path":"eZ/Publish/Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/FieldBase.php","position":null,"original_position":56,"commit_id":"c4d33cd4dd6f289dbc9a551c9ce96edf7e4aceb1","original_commit_id":"ef563b5cccfb81388a29de5aab4c491a37e25355","user":{"login":"pspanja","id":1135425,"avatar_url":"https://avatars.githubusercontent.com/u/1135425?v=3","gravatar_id":"","url":"https://api.github.com/users/pspanja","html_url":"https://github.com/pspanja","followers_url":"https://api.github.com/users/pspanja/followers","following_url":"https://api.github.com/users/pspanja/following{/other_user}","gists_url":"https://api.github.com/users/pspanja/gists{/gist_id}","starred_url":"https://api.github.com/users/pspanja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pspanja/subscriptions","organizations_url":"https://api.github.com/users/pspanja/orgs","repos_url":"https://api.github.com/users/pspanja/repos","events_url":"https://api.github.com/users/pspanja/events{/privacy}","received_events_url":"https://api.github.com/users/pspanja/received_events","type":"User","site_admin":false},"body":"Fixed in https://github.com/ezsystems/ezpublish-kernel/commit/c4d33cd4dd6f289dbc9a551c9ce96edf7e4aceb1.","created_at":"2015-04-24T09:16:12Z","updated_at":"2015-04-24T09:16:12Z","html_url":"https://github.com/ezsystems/ezpublish-kernel/pull/1222#discussion_r29034882","pull_request_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls/1222","_links":{"self":{"href":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls/comments/29034882"},"html":{"href":"https://github.com/ezsystems/ezpublish-kernel/pull/1222#discussion_r29034882"},"pull_request":{"href":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls/1222"}}},"pull_request":{"url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls/1222","id":32944796,"html_url":"https://github.com/ezsystems/ezpublish-kernel/pull/1222","diff_url":"https://github.com/ezsystems/ezpublish-kernel/pull/1222.diff","patch_url":"https://github.com/ezsystems/ezpublish-kernel/pull/1222.patch","issue_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/issues/1222","number":1222,"state":"open","locked":false,"title":"EZP-23524: Implement field filters for Legacy Search Engine","user":{"login":"pspanja","id":1135425,"avatar_url":"https://avatars.githubusercontent.com/u/1135425?v=3","gravatar_id":"","url":"https://api.github.com/users/pspanja","html_url":"https://github.com/pspanja","followers_url":"https://api.github.com/users/pspanja/followers","following_url":"https://api.github.com/users/pspanja/following{/other_user}","gists_url":"https://api.github.com/users/pspanja/gists{/gist_id}","starred_url":"https://api.github.com/users/pspanja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pspanja/subscriptions","organizations_url":"https://api.github.com/users/pspanja/orgs","repos_url":"https://api.github.com/users/pspanja/repos","events_url":"https://api.github.com/users/pspanja/events{/privacy}","received_events_url":"https://api.github.com/users/pspanja/received_events","type":"User","site_admin":false},"body":"This PR resolves https://jira.ez.no/browse/EZP-23524\r\n\r\n#### What are field filters?\r\n\r\nBasically, a second parameter of the [`SearchService::find()`](https://github.com/ezsystems/ezpublish-kernel/blob/master/eZ/Publish/API/Repository/SearchService.php#L50) method. That is similar to what is available on some of the `ContentService:loadContent*` methods, which optionally accept a list of languages and always available indicator.\r\n\r\nContrary to the requirements for loading Content, in search implementation field filters conditions need to be added to the search backend query. That is needed in order to limit matching to specific languages and avoid `NotFound` exceptions when loading matched Content in `SearchService`.\r\n\r\n#### Implementation\r\n\r\nIdeally implementation would cover following criteria:\r\n\r\n1. Field\r\n2. MapLocationDistance\r\n3. FieldRelation\r\n4. FullText\r\n\r\nHowever field filters support is here implemented only for `Field` and `MapLocationDistance` criteria.\r\n\r\n`FieldRelation` can't support it as the required data does not exist in `ezcontentobject_link` table. In addition to `contentclassattribute_id` column that would require `contentobjectattribute_id`, so that `ezcontentobject_attribute` can be joined and field filter conditions applied.\r\n\r\n`FullText` criterion can't support it as it relies on Legacy Stack's `eZSearchEngine` implementation, which does not support language filtering with fulltext search.","created_at":"2015-04-09T10:53:53Z","updated_at":"2015-04-24T09:16:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a707a23c19ee3925e27079ff155decb23ab339b1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls/1222/commits","review_comments_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls/1222/comments","review_comment_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/issues/1222/comments","statuses_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/statuses/c4d33cd4dd6f289dbc9a551c9ce96edf7e4aceb1","head":{"label":"ezsystems:impl-EZP-23524-legacy-field-filters","ref":"impl-EZP-23524-legacy-field-filters","sha":"c4d33cd4dd6f289dbc9a551c9ce96edf7e4aceb1","user":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"repo":{"id":1663890,"name":"ezpublish-kernel","full_name":"ezsystems/ezpublish-kernel","owner":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ezsystems/ezpublish-kernel","description":"eZ Publish 6.x kernel","fork":false,"url":"https://api.github.com/repos/ezsystems/ezpublish-kernel","forks_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/forks","keys_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/teams","hooks_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/hooks","issue_events_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/issues/events{/number}","events_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/events","assignees_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/assignees{/user}","branches_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/branches{/branch}","tags_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/tags","blobs_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/git/refs{/sha}","trees_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/statuses/{sha}","languages_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/languages","stargazers_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/stargazers","contributors_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/contributors","subscribers_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/subscribers","subscription_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/subscription","commits_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/commits{/sha}","git_commits_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/git/commits{/sha}","comments_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/comments{/number}","issue_comment_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/issues/comments{/number}","contents_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/contents/{+path}","compare_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/merges","archive_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/downloads","issues_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/issues{/number}","pulls_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls{/number}","milestones_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/milestones{/number}","notifications_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/labels{/name}","releases_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/releases{/id}","created_at":"2011-04-26T08:54:24Z","updated_at":"2015-04-21T04:40:55Z","pushed_at":"2015-04-24T09:15:54Z","git_url":"git://github.com/ezsystems/ezpublish-kernel.git","ssh_url":"git@github.com:ezsystems/ezpublish-kernel.git","clone_url":"https://github.com/ezsystems/ezpublish-kernel.git","svn_url":"https://github.com/ezsystems/ezpublish-kernel","homepage":"http://ez.no","size":58746,"stargazers_count":96,"watchers_count":96,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":114,"mirror_url":null,"open_issues_count":52,"forks":114,"open_issues":52,"watchers":96,"default_branch":"master"}},"base":{"label":"ezsystems:master","ref":"master","sha":"18fb32505a47e9a6dfcbc11cfe1ed5341002dc8d","user":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"repo":{"id":1663890,"name":"ezpublish-kernel","full_name":"ezsystems/ezpublish-kernel","owner":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ezsystems/ezpublish-kernel","description":"eZ Publish 6.x kernel","fork":false,"url":"https://api.github.com/repos/ezsystems/ezpublish-kernel","forks_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/forks","keys_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/teams","hooks_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/hooks","issue_events_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/issues/events{/number}","events_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/events","assignees_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/assignees{/user}","branches_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/branches{/branch}","tags_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/tags","blobs_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/git/refs{/sha}","trees_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/statuses/{sha}","languages_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/languages","stargazers_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/stargazers","contributors_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/contributors","subscribers_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/subscribers","subscription_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/subscription","commits_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/commits{/sha}","git_commits_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/git/commits{/sha}","comments_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/comments{/number}","issue_comment_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/issues/comments{/number}","contents_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/contents/{+path}","compare_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/merges","archive_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/downloads","issues_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/issues{/number}","pulls_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls{/number}","milestones_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/milestones{/number}","notifications_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/labels{/name}","releases_url":"https://api.github.com/repos/ezsystems/ezpublish-kernel/releases{/id}","created_at":"2011-04-26T08:54:24Z","updated_at":"2015-04-21T04:40:55Z","pushed_at":"2015-04-24T09:15:54Z","git_url":"git://github.com/ezsystems/ezpublish-kernel.git","ssh_url":"git@github.com:ezsystems/ezpublish-kernel.git","clone_url":"https://github.com/ezsystems/ezpublish-kernel.git","svn_url":"https://github.com/ezsystems/ezpublish-kernel","homepage":"http://ez.no","size":58746,"stargazers_count":96,"watchers_count":96,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":114,"mirror_url":null,"open_issues_count":52,"forks":114,"open_issues":52,"watchers":96,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls/1222"},"html":{"href":"https://github.com/ezsystems/ezpublish-kernel/pull/1222"},"issue":{"href":"https://api.github.com/repos/ezsystems/ezpublish-kernel/issues/1222"},"comments":{"href":"https://api.github.com/repos/ezsystems/ezpublish-kernel/issues/1222/comments"},"review_comments":{"href":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls/1222/comments"},"review_comment":{"href":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ezsystems/ezpublish-kernel/pulls/1222/commits"},"statuses":{"href":"https://api.github.com/repos/ezsystems/ezpublish-kernel/statuses/c4d33cd4dd6f289dbc9a551c9ce96edf7e4aceb1"}}}}