{"action":"opened","issue":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/8808","repository_url":"https://api.github.com/repos/cakephp/cakephp","labels_url":"https://api.github.com/repos/cakephp/cakephp/issues/8808/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/8808/comments","events_url":"https://api.github.com/repos/cakephp/cakephp/issues/8808/events","html_url":"https://github.com/cakephp/cakephp/issues/8808","id":154173923,"number":8808,"title":"Generate warning if [associated=>[AssiciationName]] does not exists in newEntity","user":{"login":"Antoniossss","id":7877627,"avatar_url":"https://avatars.githubusercontent.com/u/7877627?v=3","gravatar_id":"","url":"https://api.github.com/users/Antoniossss","html_url":"https://github.com/Antoniossss","followers_url":"https://api.github.com/users/Antoniossss/followers","following_url":"https://api.github.com/users/Antoniossss/following{/other_user}","gists_url":"https://api.github.com/users/Antoniossss/gists{/gist_id}","starred_url":"https://api.github.com/users/Antoniossss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Antoniossss/subscriptions","organizations_url":"https://api.github.com/users/Antoniossss/orgs","repos_url":"https://api.github.com/users/Antoniossss/repos","events_url":"https://api.github.com/users/Antoniossss/events{/privacy}","received_events_url":"https://api.github.com/users/Antoniossss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-11T07:03:49Z","updated_at":"2016-05-11T07:03:49Z","closed_at":null,"body":"This is a (multiple allowed):\r\n* [ ] bug\r\n* [X] enhancement\r\n* [ ] feature-discussion (RFC)\r\n\r\n\r\nThis is little bit of enhancement for debugging purposes. \r\nI was strugling with not working belongsToMany assiciations save using following construct:\r\n` $payment = $table->newEntity($data, [\"associated\" => [\"Orders\"]]);`\r\n\r\nHowever something was not working. After some time, i have found out that other dev missed the plural form of Order in PaymentsTable definition. So basicly PaymentsTable is not associated with OrdersTable.\r\n\r\nIt took a while to find such a minor bug, but it was confusing because no warning/error is returned but the missing association is simply ignored.\r\n\r\nIn of Table::find()->contains() error is thrown if given association names are wrong. \r\n\r\nIt would be a life saver to include either warn level logging or php warning generation that given association name does not exists in current context.\r\n\r\nIt is ignored by the Cake\\ORM\\Marshaller in _buildPropertyMap($options)\r\n        if (empty($options['associated'])) {\r\n            return [];\r\n        }\r\n\r\n        $include = $options['associated'];\r\n        $map = [];\r\n        $include = $this->_normalizeAssociations($include);\r\n        foreach ($include as $key => $nested) {\r\n            if (is_int($key) && is_scalar($nested)) {\r\n                $key = $nested;\r\n                $nested = [];\r\n            }\r\n            $assoc = $this->_table->association($key);\r\n            if ($assoc) {\r\n                $map[$assoc->property()] = ['association' => $assoc] + $nested + ['associated' => []];\r\n            }\r\n        }\r\n        return $map;\r\n    }\r\n\r\nwould be nice for example to add logging if association does not exists and debug is on:\r\n\r\n            if ($assoc) {\r\n                $map[$assoc->property()] = ['association' => $assoc] + $nested + ['associated' => []];\r\n            }else if ($debug){\r\n              //Warning: Given association $key does not exist in table $this->_table and will be ignored\r\n            }"}}