{"action":"created","issue":{"url":"https://api.github.com/repos/statamic/v2-hub/issues/2004","repository_url":"https://api.github.com/repos/statamic/v2-hub","labels_url":"https://api.github.com/repos/statamic/v2-hub/issues/2004/labels{/name}","comments_url":"https://api.github.com/repos/statamic/v2-hub/issues/2004/comments","events_url":"https://api.github.com/repos/statamic/v2-hub/issues/2004/events","html_url":"https://github.com/statamic/v2-hub/issues/2004","id":329618550,"node_id":"MDU6SXNzdWUzMjk2MTg1NTA=","number":2004,"title":"Locales tag causing error on search","user":{"login":"1stevengrant","id":112473,"node_id":"MDQ6VXNlcjExMjQ3Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/112473?v=4","gravatar_id":"","url":"https://api.github.com/users/1stevengrant","html_url":"https://github.com/1stevengrant","followers_url":"https://api.github.com/users/1stevengrant/followers","following_url":"https://api.github.com/users/1stevengrant/following{/other_user}","gists_url":"https://api.github.com/users/1stevengrant/gists{/gist_id}","starred_url":"https://api.github.com/users/1stevengrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1stevengrant/subscriptions","organizations_url":"https://api.github.com/users/1stevengrant/orgs","repos_url":"https://api.github.com/users/1stevengrant/repos","events_url":"https://api.github.com/users/1stevengrant/events{/privacy}","received_events_url":"https://api.github.com/users/1stevengrant/received_events","type":"User","site_admin":false},"labels":[{"id":955444586,"node_id":"MDU6TGFiZWw5NTU0NDQ1ODY=","url":"https://api.github.com/repos/statamic/v2-hub/labels/l10n","name":"l10n","color":"eff230","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-05T20:46:46Z","updated_at":"2018-06-19T15:58:42Z","closed_at":null,"author_association":"NONE","body":"I have a `locales` loop in my header to generate the nav\r\n\r\n```\r\n{{ locales }}\r\n\t<li><a href=\"{{ locale:url }}\">{{ locale:name }}</a></li>\r\n{{ /locales }}\r\n```\r\n\r\nbut anytime I use the search function, it errors out\r\n\r\n```\r\nCall to a member function in() on null\r\nin LocalesTags.php line 97\r\nat LocalesTags->getLocalizedData('en') in LocalesTags.php line 81\r\nat LocalesTags->Statamic\\Addons\\Locales\\{closure}(array('name' => 'English', 'full' => 'en', 'url' => '/', 'key' => 'en'), 'en')\r\nat array_map(object(Closure), array('en' => array('name' => 'English', 'full' => 'en', 'url' => '/', 'key' => 'en'), 'cy' => array('name' => 'Cymraeg', 'full' => 'cy', 'url' => '/cy', 'key' => 'cy')), array('en', 'cy')) in Collection.php line 469\r\nat Collection->map(object(Closure)) in LocalesTags.php line 86\r\nat LocalesTags->addData(object(Collection)) in LocalesTags.php line 56\r\nat LocalesTags->Statamic\\Addons\\Locales\\{closure}(object(Collection)) in CollectionsServiceProvider.php line 143\r\nat Collection->Statamic\\Providers\\{closure}(object(Closure))\r\nat call_user_func_array(object(Closure), array(object(Closure))) in Macroable.php line 75\r\nat Collection->__call('pipe', array(object(Closure))) in LocalesTags.php line 57\r\nat LocalesTags->getLocales() in LocalesTags.php line 25\r\nat LocalesTags->index()\r\n```\r\n\r\nIf I remove the locale loop, search works great."},"comment":{"url":"https://api.github.com/repos/statamic/v2-hub/issues/comments/398452054","html_url":"https://github.com/statamic/v2-hub/issues/2004#issuecomment-398452054","issue_url":"https://api.github.com/repos/statamic/v2-hub/issues/2004","id":398452054,"node_id":"MDEyOklzc3VlQ29tbWVudDM5ODQ1MjA1NA==","user":{"login":"jasonvarga","id":105211,"node_id":"MDQ6VXNlcjEwNTIxMQ==","avatar_url":"https://avatars1.githubusercontent.com/u/105211?v=4","gravatar_id":"","url":"https://api.github.com/users/jasonvarga","html_url":"https://github.com/jasonvarga","followers_url":"https://api.github.com/users/jasonvarga/followers","following_url":"https://api.github.com/users/jasonvarga/following{/other_user}","gists_url":"https://api.github.com/users/jasonvarga/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonvarga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonvarga/subscriptions","organizations_url":"https://api.github.com/users/jasonvarga/orgs","repos_url":"https://api.github.com/users/jasonvarga/repos","events_url":"https://api.github.com/users/jasonvarga/events{/privacy}","received_events_url":"https://api.github.com/users/jasonvarga/received_events","type":"User","site_admin":false},"created_at":"2018-06-19T15:58:42Z","updated_at":"2018-06-19T15:58:42Z","author_association":"MEMBER","body":"Thanks for sending over your site through email.\r\n\r\n**tl;dr here's a workaround:**\r\n\r\nAdd `id=\"id-of-your-homepage\"` to the `locales` loop.\r\n\r\n```\r\n{{ locales id=\"id-of-homepage\" }}\r\n    ...\r\n{{ /locales }}\r\n```\r\n\r\n**Why:**\r\n\r\nThe locales tag is meant for looping over locales for specific pieces of content. (eg. so `{{ url }}` in the loop might output `/fr/the-french-version-of-the-page`.)\r\n\r\nIt determines what content to target by getting the `id` from the context. If you're on an actual page or entry, the `id` will be in the context.\r\n\r\nYours is breaking because there's no id in the context.\r\n\r\n1. Since you're on a route (not a page or entry), there's no ID coming through there.\r\n2. You also don't have a `global.yaml` global file, which would normally mean _that_ `id` would be in the context.\r\n\r\nNext release will fall back to the homepage if there's no ID, but you can use the workaround above for now. Or, just loop over the locale config since you aren't really concerned with content-specific stuff.\r\n\r\n```\r\n{{ foreach:settings:system:locales as=\"locale\" }}\r\n    <li><a href=\"{{ locale:url }}\">{{ locale:name }}</a></li>\r\n{{ /foreach:settings:system:locales }}\r\n```"}}
{"actor":{"display_login":"jasonvarga"}}