API page: https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...

The 'entity keys' is optional, and should be marked as such.

Furthermore, some of its array items get filled by entity_get_info() with defaults:

      foreach ($entity_info as $name => $data) {
        $entity_info[$name] += array(
          'fieldable' => FALSE,
          'controller class' => 'DrupalDefaultEntityController',
          'static cache' => TRUE,
          'field cache' => TRUE,
          'load hook' => $name . '_load',
          'bundles' => array(),
          'view modes' => array(),
          'entity keys' => array(),
          'translation' => array(),
        );
        $entity_info[$name]['entity keys'] += array(
          'revision' => '',
          'bundle' => '',
        );

This should be documented too. (See https://api.drupal.org/api/drupal/includes!common.inc/function/entity_ge...)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vbouchet’s picture

Please find a first patch, not sure it covers the entire issue.

joachim’s picture

Status: Active » Needs work

I think this might be a patch for another issue... :)

vbouchet’s picture

Yeah, by reading the issue now I understand the issue was only about 'entity keys'. I initially thought part of the issue was about 'entity keys' and another part was about some default value for other fields was not properly documented.

talhaparacha’s picture

Status: Needs work » Needs review
FileSize
2.03 KB

Patch applies cleanly at commit # 731dfac.

joachim’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch. Looks good to me.

jhodgdon’s picture

Status: Reviewed & tested by the community » Needs work

Thanks! I don't think this patch addresses everything in the issue summary though. The summary says that we should document the defaults for all of the entity keys that have defaults, and this patch only addresses a few of them.

talhaparacha’s picture

Yes but I think only 'revision' and 'bundle' elements from entity keys get default values in entity_get_info().

jhodgdon’s picture

Looking at the issue summary, there are several keys in the entity info that get defaults (there are only two inside the 'entity keys' portion). Not all of the keys in the outer entity info have their defaults documented. Is that out of scope for this issue?

joachim’s picture

It's out of scope for the issue as I filed it, yes. But you're the docs maintainer, so if you want to widen the scope... :)

jhodgdon’s picture

Status: Needs work » Reviewed & tested by the community

Either way. I'll go ahead and mark the current patch RTBC then. If someone wants to either file another (very minor) issue about putting in the defaults for the other keys, or make another patch here, feel free. I am kind of past caring a lot about 7.x docs at this point enough to push for that update.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x - thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.