{"action":"created","issue":{"url":"https://api.github.com/repos/api-platform/core/issues/1185","repository_url":"https://api.github.com/repos/api-platform/core","labels_url":"https://api.github.com/repos/api-platform/core/issues/1185/labels{/name}","comments_url":"https://api.github.com/repos/api-platform/core/issues/1185/comments","events_url":"https://api.github.com/repos/api-platform/core/issues/1185/events","html_url":"https://github.com/api-platform/core/issues/1185","id":236860423,"number":1185,"title":"Doctrine filters","user":{"login":"djoos","id":449510,"avatar_url":"https://avatars3.githubusercontent.com/u/449510?v=3","gravatar_id":"","url":"https://api.github.com/users/djoos","html_url":"https://github.com/djoos","followers_url":"https://api.github.com/users/djoos/followers","following_url":"https://api.github.com/users/djoos/following{/other_user}","gists_url":"https://api.github.com/users/djoos/gists{/gist_id}","starred_url":"https://api.github.com/users/djoos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djoos/subscriptions","organizations_url":"https://api.github.com/users/djoos/orgs","repos_url":"https://api.github.com/users/djoos/repos","events_url":"https://api.github.com/users/djoos/events{/privacy}","received_events_url":"https://api.github.com/users/djoos/received_events","type":"User","site_admin":false},"labels":[{"id":167973998,"url":"https://api.github.com/repos/api-platform/core/labels/bug","name":"bug","color":"fc2929","default":true},{"id":219315677,"url":"https://api.github.com/repos/api-platform/core/labels/unconfirmed","name":"unconfirmed","color":"cccccc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-06-19T11:28:16Z","updated_at":"2017-06-20T16:06:49Z","closed_at":null,"body":"Hi there,\r\n\r\nwhen implementing a Doctrine filter (eg. [UserAware](http://blog.michaelperrin.fr/2014/12/05/doctrine-filters/)), the results get filtered correctly (hydra:member), however the [paginator's query](https://github.com/api-platform/core/blob/020dbf21246bc7acbd8c417e0ab64bddafcadf3b/src/Bridge/Doctrine/Orm/Paginator.php#L51) doesn't seem to pick up the filter, so the hydra:totalItems and hydra:view are incorrect...\r\n\r\n```\r\n    \"hydra:member\": [],\r\n    \"hydra:totalItems\": 61,\r\n    \"hydra:view\": {\r\n        \"@id\": \"/foos?page=1\",\r\n        \"@type\": \"hydra:PartialCollectionView\",\r\n        \"hydra:first\": \"/foos?page=1\",\r\n        \"hydra:last\": \"/foos?page=6\",\r\n        \"hydra:next\": \"/foos?page=2\"\r\n    }\r\n```\r\n\r\nI'll dig deeper into the issue, but any heads up is appreciated - thanks in advance!\r\n\r\nKind regards,\r\nDavid"},"comment":{"url":"https://api.github.com/repos/api-platform/core/issues/comments/309807909","html_url":"https://github.com/api-platform/core/issues/1185#issuecomment-309807909","issue_url":"https://api.github.com/repos/api-platform/core/issues/1185","id":309807909,"user":{"login":"djoos","id":449510,"avatar_url":"https://avatars3.githubusercontent.com/u/449510?v=3","gravatar_id":"","url":"https://api.github.com/users/djoos","html_url":"https://github.com/djoos","followers_url":"https://api.github.com/users/djoos/followers","following_url":"https://api.github.com/users/djoos/following{/other_user}","gists_url":"https://api.github.com/users/djoos/gists{/gist_id}","starred_url":"https://api.github.com/users/djoos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djoos/subscriptions","organizations_url":"https://api.github.com/users/djoos/orgs","repos_url":"https://api.github.com/users/djoos/repos","events_url":"https://api.github.com/users/djoos/events{/privacy}","received_events_url":"https://api.github.com/users/djoos/received_events","type":"User","site_admin":false},"created_at":"2017-06-20T16:06:49Z","updated_at":"2017-06-20T16:06:49Z","body":"A quick update - after picking this up just now again...\r\n\r\nI spotted in the [PartialConnectionViewNormalizer](https://github.com/api-platform/core/blob/b88d975fa152d295ffeed332dab81dd8376722d1/src/Hydra/Serializer/PartialCollectionViewNormalizer.php#L48) that $data looked like:\r\n\r\n```\r\nArray\r\n(\r\n    [@context] => /contexts/Project\r\n    [@id] => /projects\r\n    [@type] => hydra:Collection\r\n    [hydra:member] => Array\r\n        (\r\n        )\r\n\r\n    [hydra:totalItems] => 61\r\n)\r\n```\r\n\r\nSo, hydra:member is correct while hydra:totalItems is incorrect.\r\n\r\nDigging deeper, I spotted in the [CollectionNormalizer](https://github.com/api-platform/core/blob/b88d975fa152d295ffeed332dab81dd8376722d1/src/Hydra/Serializer/CollectionNormalizer.php#L86) that the `$object->getTotalItems()` differs from `count($object)`: 61 (incorrect) vs. 0 (correct)\r\n\r\nThe paginator object used to instantiate the [Paginator](https://github.com/api-platform/core/blob/020dbf21246bc7acbd8c417e0ab64bddafcadf3b/src/Bridge/Doctrine/Orm/Paginator.php#L48) carries the issue with it already, as the $paginator->getQuery() doesn't respect the Doctrine filter, so the count($paginator) returns an incorrect (as in: unfiltered) count, causing the issues further downwards.\r\n\r\nNot sure yet where the src/Bridge/Doctrine/Orm/Paginator-object gets instantiated, but that'll be my next step.\r\n\r\nTBC!"}}
{"actor":{"display_login":"djoos"}}