{"action":"created","issue":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/19781","repository_url":"https://api.github.com/repos/joomla/joomla-cms","labels_url":"https://api.github.com/repos/joomla/joomla-cms/issues/19781/labels{/name}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/19781/comments","events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/19781/events","html_url":"https://github.com/joomla/joomla-cms/pull/19781","id":300022180,"number":19781,"title":"Avoid duplicate paths if path is not a directory","user":{"login":"Sophist-UK","id":3001893,"avatar_url":"https://avatars3.githubusercontent.com/u/3001893?v=4","gravatar_id":"","url":"https://api.github.com/users/Sophist-UK","html_url":"https://github.com/Sophist-UK","followers_url":"https://api.github.com/users/Sophist-UK/followers","following_url":"https://api.github.com/users/Sophist-UK/following{/other_user}","gists_url":"https://api.github.com/users/Sophist-UK/gists{/gist_id}","starred_url":"https://api.github.com/users/Sophist-UK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sophist-UK/subscriptions","organizations_url":"https://api.github.com/users/Sophist-UK/orgs","repos_url":"https://api.github.com/users/Sophist-UK/repos","events_url":"https://api.github.com/users/Sophist-UK/events{/privacy}","received_events_url":"https://api.github.com/users/Sophist-UK/received_events","type":"User","site_admin":false},"labels":[{"id":60721348,"url":"https://api.github.com/repos/joomla/joomla-cms/labels/PR-staging","name":"PR-staging","color":"c7def8","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-02-25T12:26:59Z","updated_at":"2018-03-25T17:21:56Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/joomla/joomla-cms/pulls/19781","html_url":"https://github.com/joomla/joomla-cms/pull/19781","diff_url":"https://github.com/joomla/joomla-cms/pull/19781.diff","patch_url":"https://github.com/joomla/joomla-cms/pull/19781.patch"},"body":"Form path arrays contain duplicates when they shouldn't.\r\n\r\nCurrent code:\r\n```\r\nforeach ($new as $path)\r\n{\r\n\tif (!in_array($path, $paths))\r\n\t{\r\n\t\tarray_unshift($paths, trim($path));\r\n\t}\r\n\r\n\tif (!is_dir($path))\r\n\t{\r\n\t\tarray_unshift($paths, trim($path));\r\n\t}\r\n}\r\n```\r\n\r\nProposed code:\r\n```\r\nforeach ($new as $path)\r\n{\r\n\t$path = trim($path);\r\n\tif (!in_array($path, $paths) && is_dir($path))\r\n\t{\r\n\t\tarray_unshift($paths, $path);\r\n\t}\r\n}\r\n```\r\n\r\n### Summary of Changes\r\n\r\nPath arrays currently have duplicate path in them - this PR removes the code which creates duplicates.\r\n\r\n### Testing Instructions\r\n```\r\n$form = new JForm('test');\r\nvar_dump($form->addFieldPath('/')); // Exists\r\nvar_dump($form->addFieldPath('/directory_doesnt_exist')); // Does not exist\r\n```\r\n### Existing result\r\n\r\nReturned array shows `/` and  `/directory_doesnt_exist` twice.\r\n\r\n### Fixed result\r\n\r\nReturned array shows `/` once and  `/directory_doesnt_exist` is omitted.\r\n\r\n### Documentation Changes Required\r\n\r\nNone."},"comment":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/comments/375987323","html_url":"https://github.com/joomla/joomla-cms/pull/19781#issuecomment-375987323","issue_url":"https://api.github.com/repos/joomla/joomla-cms/issues/19781","id":375987323,"user":{"login":"Sophist-UK","id":3001893,"avatar_url":"https://avatars3.githubusercontent.com/u/3001893?v=4","gravatar_id":"","url":"https://api.github.com/users/Sophist-UK","html_url":"https://github.com/Sophist-UK","followers_url":"https://api.github.com/users/Sophist-UK/followers","following_url":"https://api.github.com/users/Sophist-UK/following{/other_user}","gists_url":"https://api.github.com/users/Sophist-UK/gists{/gist_id}","starred_url":"https://api.github.com/users/Sophist-UK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sophist-UK/subscriptions","organizations_url":"https://api.github.com/users/Sophist-UK/orgs","repos_url":"https://api.github.com/users/Sophist-UK/repos","events_url":"https://api.github.com/users/Sophist-UK/events{/privacy}","received_events_url":"https://api.github.com/users/Sophist-UK/received_events","type":"User","site_admin":false},"created_at":"2018-03-25T17:21:56Z","updated_at":"2018-03-25T17:21:56Z","author_association":"CONTRIBUTOR","body":"This should now be mergable."}}
{"actor":{"display_login":"Sophist-UK"}}