{"action":"created","comment":{"url":"https://api.github.com/repos/shaarli/Shaarli/pulls/comments/51232080","id":51232080,"diff_hunk":"@@ -154,19 +159,33 @@ private function filterFulltext($searchterms, $privateonly = false)\n \n             // Iterate over searchable link fields.\n             foreach ($keys as $key) {\n-                // Search full expression.\n-                if (strpos(\n-                    mb_convert_case($link[$key], MB_CASE_LOWER, 'UTF-8'),\n-                    $search\n-                ) !== false) {\n-                    $found = true;\n-                }\n+                // Be optimistic\n+                $found = true;\n+                \n+                // FIXME: Find a better word for where you're searching in \n+                $haystack = mb_convert_case($link[$key], MB_CASE_LOWER, 'UTF-8');\n \n+                // When searching for the phrase, check if it's in the haystack...\n+                if ( $searchExactPhrase && strpos($haystack, $search) !== false) {\n+                    break;\n+                }\n+                else {","path":"application/LinkFilter.php","position":48,"original_position":48,"commit_id":"7692a7877296381c2465658e1efbb6d3f054517c","original_commit_id":"7692a7877296381c2465658e1efbb6d3f054517c","user":{"login":"joedemo42","id":5891103,"avatar_url":"https://avatars.githubusercontent.com/u/5891103?v=3","gravatar_id":"","url":"https://api.github.com/users/joedemo42","html_url":"https://github.com/joedemo42","followers_url":"https://api.github.com/users/joedemo42/followers","following_url":"https://api.github.com/users/joedemo42/following{/other_user}","gists_url":"https://api.github.com/users/joedemo42/gists{/gist_id}","starred_url":"https://api.github.com/users/joedemo42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedemo42/subscriptions","organizations_url":"https://api.github.com/users/joedemo42/orgs","repos_url":"https://api.github.com/users/joedemo42/repos","events_url":"https://api.github.com/users/joedemo42/events{/privacy}","received_events_url":"https://api.github.com/users/joedemo42/received_events","type":"User","site_admin":false},"body":"That's not how it works. Let's take the search string `\"new search\"` (with quotes). In line 146 - 150 I check, if were searching for the exact phrase. (If the string starts and ends with quotes). To do this only once I store the result in `$searchExactPhrase`. The quotes are then removed from the string since they're not actually part of what we're looking for. The If-Statement you mentioned could be rewritten as\r\n```\r\nif ( $searchExactPhrase ) {\r\n   if (strpos($haystack, $search) !== false) {\r\n        break;\r\n    }\r\n}\r\nelse {\r\n```\r\n\r\nFirst, I check if we're looking for the exact phrase. If that's the case - and only then - I check if the string is in our haystack (I plan on sticking with this name, btw.). If it's not found, fine. but the `else` does not get executed because of this.\r\nIf we're not searching for the exact phrase the `else` is executed. To me this is just what I intended","created_at":"2016-01-29T07:19:13Z","updated_at":"2016-01-29T07:19:13Z","html_url":"https://github.com/shaarli/Shaarli/pull/450#discussion_r51232080","pull_request_url":"https://api.github.com/repos/shaarli/Shaarli/pulls/450","_links":{"self":{"href":"https://api.github.com/repos/shaarli/Shaarli/pulls/comments/51232080"},"html":{"href":"https://github.com/shaarli/Shaarli/pull/450#discussion_r51232080"},"pull_request":{"href":"https://api.github.com/repos/shaarli/Shaarli/pulls/450"}}},"pull_request":{"url":"https://api.github.com/repos/shaarli/Shaarli/pulls/450","id":56996682,"html_url":"https://github.com/shaarli/Shaarli/pull/450","diff_url":"https://github.com/shaarli/Shaarli/pull/450.diff","patch_url":"https://github.com/shaarli/Shaarli/pull/450.patch","issue_url":"https://api.github.com/repos/shaarli/Shaarli/issues/450","number":450,"state":"open","locked":false,"title":"Implemented a little more sophisticated searching","user":{"login":"joedemo42","id":5891103,"avatar_url":"https://avatars.githubusercontent.com/u/5891103?v=3","gravatar_id":"","url":"https://api.github.com/users/joedemo42","html_url":"https://github.com/joedemo42","followers_url":"https://api.github.com/users/joedemo42/followers","following_url":"https://api.github.com/users/joedemo42/following{/other_user}","gists_url":"https://api.github.com/users/joedemo42/gists{/gist_id}","starred_url":"https://api.github.com/users/joedemo42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedemo42/subscriptions","organizations_url":"https://api.github.com/users/joedemo42/orgs","repos_url":"https://api.github.com/users/joedemo42/repos","events_url":"https://api.github.com/users/joedemo42/events{/privacy}","received_events_url":"https://api.github.com/users/joedemo42/received_events","type":"User","site_admin":false},"body":"This implements two ways of searching through Shaarlies link archives:\r\n\r\n- exact phrase enclosed in double-quotes, like `\"foo bar baz\"`\r\n- all words in no particular order, like `foo bar baz`\r\n\r\nIt is in reference to issue #435.\r\n\r\nThe following examples refer to the data in the [demo installation](http://shaarlidemo.tuxfamily.org/Shaarli/). The demo installation does not have this search enabled.\r\n\r\nExamples.\r\nSearching for `learn use` finds the \"Welcome to Shaarli!\" note. Think of this search as `learn AND use`.\r\nSearching for `\"learn use\"` finds nothing because it searches for this exact phrase, while `\"learn how to use\"` finds the very same note.\r\n\r\nSearching is still limited to individual fields of an item. Searching for `clone public` does not find the \"Welcome to Shaarli!\" note, since `clone` appears in the title, while `public` appears in the description.\r\n\r\nNote: This changes the default search behavior of Shaarli. Right now, Shaarli will always search for the exact phrase, no matter if the keywords are enclosed in double-quotes or not. With this patch, it will default to searching for all words in no particular order with the old way only happening when enclosing the keywords in double quotes.","created_at":"2016-01-24T06:39:26Z","updated_at":"2016-01-29T07:19:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2697842017c34a493099658dae8a74596abd1f91","assignee":null,"milestone":{"url":"https://api.github.com/repos/shaarli/Shaarli/milestones/16","html_url":"https://github.com/shaarli/Shaarli/milestones/0.6.4","labels_url":"https://api.github.com/repos/shaarli/Shaarli/milestones/16/labels","id":1472987,"number":16,"title":"0.6.4","description":"","creator":{"login":"virtualtam","id":1615162,"avatar_url":"https://avatars.githubusercontent.com/u/1615162?v=3","gravatar_id":"","url":"https://api.github.com/users/virtualtam","html_url":"https://github.com/virtualtam","followers_url":"https://api.github.com/users/virtualtam/followers","following_url":"https://api.github.com/users/virtualtam/following{/other_user}","gists_url":"https://api.github.com/users/virtualtam/gists{/gist_id}","starred_url":"https://api.github.com/users/virtualtam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/virtualtam/subscriptions","organizations_url":"https://api.github.com/users/virtualtam/orgs","repos_url":"https://api.github.com/users/virtualtam/repos","events_url":"https://api.github.com/users/virtualtam/events{/privacy}","received_events_url":"https://api.github.com/users/virtualtam/received_events","type":"User","site_admin":false},"open_issues":10,"closed_issues":0,"state":"open","created_at":"2015-12-23T19:55:30Z","updated_at":"2016-01-25T21:12:14Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/shaarli/Shaarli/pulls/450/commits","review_comments_url":"https://api.github.com/repos/shaarli/Shaarli/pulls/450/comments","review_comment_url":"https://api.github.com/repos/shaarli/Shaarli/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shaarli/Shaarli/issues/450/comments","statuses_url":"https://api.github.com/repos/shaarli/Shaarli/statuses/7692a7877296381c2465658e1efbb6d3f054517c","head":{"label":"joedemo42:search","ref":"search","sha":"7692a7877296381c2465658e1efbb6d3f054517c","user":{"login":"joedemo42","id":5891103,"avatar_url":"https://avatars.githubusercontent.com/u/5891103?v=3","gravatar_id":"","url":"https://api.github.com/users/joedemo42","html_url":"https://github.com/joedemo42","followers_url":"https://api.github.com/users/joedemo42/followers","following_url":"https://api.github.com/users/joedemo42/following{/other_user}","gists_url":"https://api.github.com/users/joedemo42/gists{/gist_id}","starred_url":"https://api.github.com/users/joedemo42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedemo42/subscriptions","organizations_url":"https://api.github.com/users/joedemo42/orgs","repos_url":"https://api.github.com/users/joedemo42/repos","events_url":"https://api.github.com/users/joedemo42/events{/privacy}","received_events_url":"https://api.github.com/users/joedemo42/received_events","type":"User","site_admin":false},"repo":{"id":50274729,"name":"Shaarli","full_name":"joedemo42/Shaarli","owner":{"login":"joedemo42","id":5891103,"avatar_url":"https://avatars.githubusercontent.com/u/5891103?v=3","gravatar_id":"","url":"https://api.github.com/users/joedemo42","html_url":"https://github.com/joedemo42","followers_url":"https://api.github.com/users/joedemo42/followers","following_url":"https://api.github.com/users/joedemo42/following{/other_user}","gists_url":"https://api.github.com/users/joedemo42/gists{/gist_id}","starred_url":"https://api.github.com/users/joedemo42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedemo42/subscriptions","organizations_url":"https://api.github.com/users/joedemo42/orgs","repos_url":"https://api.github.com/users/joedemo42/repos","events_url":"https://api.github.com/users/joedemo42/events{/privacy}","received_events_url":"https://api.github.com/users/joedemo42/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joedemo42/Shaarli","description":"The personal, minimalist, super-fast, no-database delicious clone - community repo","fork":true,"url":"https://api.github.com/repos/joedemo42/Shaarli","forks_url":"https://api.github.com/repos/joedemo42/Shaarli/forks","keys_url":"https://api.github.com/repos/joedemo42/Shaarli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joedemo42/Shaarli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joedemo42/Shaarli/teams","hooks_url":"https://api.github.com/repos/joedemo42/Shaarli/hooks","issue_events_url":"https://api.github.com/repos/joedemo42/Shaarli/issues/events{/number}","events_url":"https://api.github.com/repos/joedemo42/Shaarli/events","assignees_url":"https://api.github.com/repos/joedemo42/Shaarli/assignees{/user}","branches_url":"https://api.github.com/repos/joedemo42/Shaarli/branches{/branch}","tags_url":"https://api.github.com/repos/joedemo42/Shaarli/tags","blobs_url":"https://api.github.com/repos/joedemo42/Shaarli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joedemo42/Shaarli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joedemo42/Shaarli/git/refs{/sha}","trees_url":"https://api.github.com/repos/joedemo42/Shaarli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joedemo42/Shaarli/statuses/{sha}","languages_url":"https://api.github.com/repos/joedemo42/Shaarli/languages","stargazers_url":"https://api.github.com/repos/joedemo42/Shaarli/stargazers","contributors_url":"https://api.github.com/repos/joedemo42/Shaarli/contributors","subscribers_url":"https://api.github.com/repos/joedemo42/Shaarli/subscribers","subscription_url":"https://api.github.com/repos/joedemo42/Shaarli/subscription","commits_url":"https://api.github.com/repos/joedemo42/Shaarli/commits{/sha}","git_commits_url":"https://api.github.com/repos/joedemo42/Shaarli/git/commits{/sha}","comments_url":"https://api.github.com/repos/joedemo42/Shaarli/comments{/number}","issue_comment_url":"https://api.github.com/repos/joedemo42/Shaarli/issues/comments{/number}","contents_url":"https://api.github.com/repos/joedemo42/Shaarli/contents/{+path}","compare_url":"https://api.github.com/repos/joedemo42/Shaarli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joedemo42/Shaarli/merges","archive_url":"https://api.github.com/repos/joedemo42/Shaarli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joedemo42/Shaarli/downloads","issues_url":"https://api.github.com/repos/joedemo42/Shaarli/issues{/number}","pulls_url":"https://api.github.com/repos/joedemo42/Shaarli/pulls{/number}","milestones_url":"https://api.github.com/repos/joedemo42/Shaarli/milestones{/number}","notifications_url":"https://api.github.com/repos/joedemo42/Shaarli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joedemo42/Shaarli/labels{/name}","releases_url":"https://api.github.com/repos/joedemo42/Shaarli/releases{/id}","deployments_url":"https://api.github.com/repos/joedemo42/Shaarli/deployments","created_at":"2016-01-24T06:06:15Z","updated_at":"2016-01-24T06:06:16Z","pushed_at":"2016-01-24T11:37:59Z","git_url":"git://github.com/joedemo42/Shaarli.git","ssh_url":"git@github.com:joedemo42/Shaarli.git","clone_url":"https://github.com/joedemo42/Shaarli.git","svn_url":"https://github.com/joedemo42/Shaarli","homepage":"https://github.com/shaarli/Shaarli","size":1952,"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":"master"}},"base":{"label":"shaarli:master","ref":"master","sha":"db36b8812d30d2a1dcb1a5a0544893ee863f45dd","user":{"login":"shaarli","id":8275533,"avatar_url":"https://avatars.githubusercontent.com/u/8275533?v=3","gravatar_id":"","url":"https://api.github.com/users/shaarli","html_url":"https://github.com/shaarli","followers_url":"https://api.github.com/users/shaarli/followers","following_url":"https://api.github.com/users/shaarli/following{/other_user}","gists_url":"https://api.github.com/users/shaarli/gists{/gist_id}","starred_url":"https://api.github.com/users/shaarli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shaarli/subscriptions","organizations_url":"https://api.github.com/users/shaarli/orgs","repos_url":"https://api.github.com/users/shaarli/repos","events_url":"https://api.github.com/users/shaarli/events{/privacy}","received_events_url":"https://api.github.com/users/shaarli/received_events","type":"Organization","site_admin":false},"repo":{"id":22287975,"name":"Shaarli","full_name":"shaarli/Shaarli","owner":{"login":"shaarli","id":8275533,"avatar_url":"https://avatars.githubusercontent.com/u/8275533?v=3","gravatar_id":"","url":"https://api.github.com/users/shaarli","html_url":"https://github.com/shaarli","followers_url":"https://api.github.com/users/shaarli/followers","following_url":"https://api.github.com/users/shaarli/following{/other_user}","gists_url":"https://api.github.com/users/shaarli/gists{/gist_id}","starred_url":"https://api.github.com/users/shaarli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shaarli/subscriptions","organizations_url":"https://api.github.com/users/shaarli/orgs","repos_url":"https://api.github.com/users/shaarli/repos","events_url":"https://api.github.com/users/shaarli/events{/privacy}","received_events_url":"https://api.github.com/users/shaarli/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shaarli/Shaarli","description":"The personal, minimalist, super-fast, no-database delicious clone - community repo","fork":true,"url":"https://api.github.com/repos/shaarli/Shaarli","forks_url":"https://api.github.com/repos/shaarli/Shaarli/forks","keys_url":"https://api.github.com/repos/shaarli/Shaarli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shaarli/Shaarli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shaarli/Shaarli/teams","hooks_url":"https://api.github.com/repos/shaarli/Shaarli/hooks","issue_events_url":"https://api.github.com/repos/shaarli/Shaarli/issues/events{/number}","events_url":"https://api.github.com/repos/shaarli/Shaarli/events","assignees_url":"https://api.github.com/repos/shaarli/Shaarli/assignees{/user}","branches_url":"https://api.github.com/repos/shaarli/Shaarli/branches{/branch}","tags_url":"https://api.github.com/repos/shaarli/Shaarli/tags","blobs_url":"https://api.github.com/repos/shaarli/Shaarli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shaarli/Shaarli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shaarli/Shaarli/git/refs{/sha}","trees_url":"https://api.github.com/repos/shaarli/Shaarli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shaarli/Shaarli/statuses/{sha}","languages_url":"https://api.github.com/repos/shaarli/Shaarli/languages","stargazers_url":"https://api.github.com/repos/shaarli/Shaarli/stargazers","contributors_url":"https://api.github.com/repos/shaarli/Shaarli/contributors","subscribers_url":"https://api.github.com/repos/shaarli/Shaarli/subscribers","subscription_url":"https://api.github.com/repos/shaarli/Shaarli/subscription","commits_url":"https://api.github.com/repos/shaarli/Shaarli/commits{/sha}","git_commits_url":"https://api.github.com/repos/shaarli/Shaarli/git/commits{/sha}","comments_url":"https://api.github.com/repos/shaarli/Shaarli/comments{/number}","issue_comment_url":"https://api.github.com/repos/shaarli/Shaarli/issues/comments{/number}","contents_url":"https://api.github.com/repos/shaarli/Shaarli/contents/{+path}","compare_url":"https://api.github.com/repos/shaarli/Shaarli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shaarli/Shaarli/merges","archive_url":"https://api.github.com/repos/shaarli/Shaarli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shaarli/Shaarli/downloads","issues_url":"https://api.github.com/repos/shaarli/Shaarli/issues{/number}","pulls_url":"https://api.github.com/repos/shaarli/Shaarli/pulls{/number}","milestones_url":"https://api.github.com/repos/shaarli/Shaarli/milestones{/number}","notifications_url":"https://api.github.com/repos/shaarli/Shaarli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shaarli/Shaarli/labels{/name}","releases_url":"https://api.github.com/repos/shaarli/Shaarli/releases{/id}","deployments_url":"https://api.github.com/repos/shaarli/Shaarli/deployments","created_at":"2014-07-26T14:10:30Z","updated_at":"2016-01-26T14:49:59Z","pushed_at":"2016-01-24T11:37:59Z","git_url":"git://github.com/shaarli/Shaarli.git","ssh_url":"git@github.com:shaarli/Shaarli.git","clone_url":"https://github.com/shaarli/Shaarli.git","svn_url":"https://github.com/shaarli/Shaarli","homepage":"https://github.com/shaarli/Shaarli","size":2251,"stargazers_count":213,"watchers_count":213,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":37,"mirror_url":null,"open_issues_count":96,"forks":37,"open_issues":96,"watchers":213,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/shaarli/Shaarli/pulls/450"},"html":{"href":"https://github.com/shaarli/Shaarli/pull/450"},"issue":{"href":"https://api.github.com/repos/shaarli/Shaarli/issues/450"},"comments":{"href":"https://api.github.com/repos/shaarli/Shaarli/issues/450/comments"},"review_comments":{"href":"https://api.github.com/repos/shaarli/Shaarli/pulls/450/comments"},"review_comment":{"href":"https://api.github.com/repos/shaarli/Shaarli/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shaarli/Shaarli/pulls/450/commits"},"statuses":{"href":"https://api.github.com/repos/shaarli/Shaarli/statuses/7692a7877296381c2465658e1efbb6d3f054517c"}}}}