{"action":"closed","issue":{"url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/2905","repository_url":"https://api.github.com/repos/backdrop/backdrop-issues","labels_url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/2905/labels{/name}","comments_url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/2905/comments","events_url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/2905/events","html_url":"https://github.com/backdrop/backdrop-issues/issues/2905","id":273157967,"number":2905,"title":"Entity queries assume entities to be defined with ['entity keys']['id']","user":{"login":"oadaeh","id":376249,"avatar_url":"https://avatars0.githubusercontent.com/u/376249?v=4","gravatar_id":"","url":"https://api.github.com/users/oadaeh","html_url":"https://github.com/oadaeh","followers_url":"https://api.github.com/users/oadaeh/followers","following_url":"https://api.github.com/users/oadaeh/following{/other_user}","gists_url":"https://api.github.com/users/oadaeh/gists{/gist_id}","starred_url":"https://api.github.com/users/oadaeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oadaeh/subscriptions","organizations_url":"https://api.github.com/users/oadaeh/orgs","repos_url":"https://api.github.com/users/oadaeh/repos","events_url":"https://api.github.com/users/oadaeh/events{/privacy}","received_events_url":"https://api.github.com/users/oadaeh/received_events","type":"User","site_admin":false},"labels":[{"id":159653712,"url":"https://api.github.com/repos/backdrop/backdrop-issues/labels/pr%20-%20reviewed%20&%20tested%20by%20the%20community","name":"pr - reviewed & tested by the community","color":"F1FFE8","default":false},{"id":56422526,"url":"https://api.github.com/repos/backdrop/backdrop-issues/labels/type%20-%20documentation","name":"type - documentation","color":"0052cc","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-11-11T16:39:49Z","updated_at":"2018-04-10T03:04:55Z","closed_at":"2018-04-10T03:04:54Z","author_association":"NONE","body":"## Describe your issue or idea\r\nIn the core/modules/entity/entity.api.php file is this snippet of documentation (at lines 41-42):\r\n```\r\n *   - entity keys: (optional) An array describing how the Field API can extract\r\n *     the information it needs from the objects of the type. Elements:\r\n```\r\nWhich means that this is only necessary if the entity being defined is fieldable. Also, the 'fieldable' element defaults to FALSE (even though that part is not documented - see line 36 of core/modules/entity/entity.api.php and lines 173-186 of core/modules/entity/entity.module).\r\n\r\nHowever, in core/modules/entity/entity.query.inc at about lines 815-822, it is assumed that $entity_info['entity keys']['id'] (and therefore $entity_info['entity keys']) will always exist:\r\n```\r\n    // Process the four possible entity condition.\r\n    // The id field is always present in entity keys.\r\n    $sql_field = $entity_info['entity keys']['id'];\r\n    $id_map['entity_id'] = $sql_field;\r\n    $select_query->addField($base_table, $sql_field, 'entity_id');\r\n    if (isset($this->entityConditions['entity_id'])) {\r\n      $this->addCondition($select_query, $base_table . '.' . $sql_field, $this->entityConditions['entity_id']);\r\n    }\r\n```\r\n\r\nSo, one of two things needs to happen:\r\n1. The documentation needs to be corrected, or\r\n2. The code needs to be modified to not assume that neither ['entity keys']['id'] or ['entity keys'] are present (and it may be that there are other places where that change might need to be made).\r\n\r\nI believe it should be the second, but I don't know if the future way of things with entities in Backdrop is to assume that all entities are fieldable or not.\r\n\r\n### Steps to reproduce (if reporting a bug)\r\nI found this by creating a basic, custom entity with as few options defined as possible, enabling the Entity UI module (https://github.com/backdrop-contrib/entity_ui) and attempting to view the entity's admin UI page.\r\n\r\n### Actual behavior (if reporting a bug)\r\n2 PHP notices like this:\r\n> Notice: Undefined index: id in EntityFieldQuery->propertyQuery() (line 817 of /backdrop/core/modules/entity/entity.query.inc).\r\n\r\na PDOException, and the page did not load.\r\n\r\n### Expected behavior (if reporting a bug)\r\nThe page loads without any errors in the log.\r\n\r\n### Relevant version/system information (if applicable)\r\nThe downloadable copy of Backdrop 1.8.0 (though the code is currently the same in 1.x) and the current (at the time of this writing) Entity UI module.\r\n"}}
{"actor":{"display_login":"quicksketch"}}