{"action":"created","issue":{"url":"https://api.github.com/repos/dnadesign/silverstripe-elemental/issues/518","repository_url":"https://api.github.com/repos/dnadesign/silverstripe-elemental","labels_url":"https://api.github.com/repos/dnadesign/silverstripe-elemental/issues/518/labels{/name}","comments_url":"https://api.github.com/repos/dnadesign/silverstripe-elemental/issues/518/comments","events_url":"https://api.github.com/repos/dnadesign/silverstripe-elemental/issues/518/events","html_url":"https://github.com/dnadesign/silverstripe-elemental/issues/518","id":383442345,"node_id":"MDU6SXNzdWUzODM0NDIzNDU=","number":518,"title":"Elemental 4: Saving a Page triggers error","user":{"login":"bummzack","id":1006185,"node_id":"MDQ6VXNlcjEwMDYxODU=","avatar_url":"https://avatars1.githubusercontent.com/u/1006185?v=4","gravatar_id":"","url":"https://api.github.com/users/bummzack","html_url":"https://github.com/bummzack","followers_url":"https://api.github.com/users/bummzack/followers","following_url":"https://api.github.com/users/bummzack/following{/other_user}","gists_url":"https://api.github.com/users/bummzack/gists{/gist_id}","starred_url":"https://api.github.com/users/bummzack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bummzack/subscriptions","organizations_url":"https://api.github.com/users/bummzack/orgs","repos_url":"https://api.github.com/users/bummzack/repos","events_url":"https://api.github.com/users/bummzack/events{/privacy}","received_events_url":"https://api.github.com/users/bummzack/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-22T09:14:50Z","updated_at":"2018-11-22T10:11:42Z","closed_at":null,"author_association":"NONE","body":"When saving a Page that has elemental blocks in the CMS, an error will trigger: \r\n\r\n> E_WARNING: Invalid argument supplied for foreach()\r\n\r\nAnd in the CMS:\r\n\r\n![error message in cms](https://user-images.githubusercontent.com/1006185/48892904-65055a00-ee3f-11e8-983c-c0c61b59ccbd.png)\r\n\r\nThis happens, when `$this->Value()` in [`ElementalAreaField L:229`](https://github.com/dnadesign/silverstripe-elemental/blob/master/src/Forms/ElementalAreaField.php#L229) returns `null`.\r\n\r\nUsing `silverstripe/recipe-cms 4.3.x-dev` and `dnadesign/silverstripe-elemental 4.x-dev`. Same behavior can be observed with `ss 4.3.0-rc1` and `elemental 4.0.0-beta1`.\r\n\r\nI guess the easiest fix would be to check for `null` or non-array values before running it through a `foreach`?\r\n\r\nSteps to reproduce:\r\n\r\n- Create a page that has the `ElementalPageExtension`\r\n- Save the page. Most of the time, the error will trigger"},"comment":{"url":"https://api.github.com/repos/dnadesign/silverstripe-elemental/issues/comments/440979924","html_url":"https://github.com/dnadesign/silverstripe-elemental/issues/518#issuecomment-440979924","issue_url":"https://api.github.com/repos/dnadesign/silverstripe-elemental/issues/518","id":440979924,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDk3OTkyNA==","user":{"login":"robbieaverill","id":5170590,"node_id":"MDQ6VXNlcjUxNzA1OTA=","avatar_url":"https://avatars1.githubusercontent.com/u/5170590?v=4","gravatar_id":"","url":"https://api.github.com/users/robbieaverill","html_url":"https://github.com/robbieaverill","followers_url":"https://api.github.com/users/robbieaverill/followers","following_url":"https://api.github.com/users/robbieaverill/following{/other_user}","gists_url":"https://api.github.com/users/robbieaverill/gists{/gist_id}","starred_url":"https://api.github.com/users/robbieaverill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robbieaverill/subscriptions","organizations_url":"https://api.github.com/users/robbieaverill/orgs","repos_url":"https://api.github.com/users/robbieaverill/repos","events_url":"https://api.github.com/users/robbieaverill/events{/privacy}","received_events_url":"https://api.github.com/users/robbieaverill/received_events","type":"User","site_admin":false},"created_at":"2018-11-22T10:11:42Z","updated_at":"2018-11-22T10:11:42Z","author_association":"CONTRIBUTOR","body":"Yeah sounds good. We could also cast the value as an array before looping it. Would you like to make a PR?"}}
{"actor":{"display_login":"robbieaverill"}}