Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 300625

Default *content* entity languages are not set for entities created with the API

$
0
0

Updated: Comment #58

Problem/Motivation

The problem is caused when the language defaults for any content type is missing. Any entity that is created programmatically will not set the default language.

Steps to replicate

  1. Create a new content type.
  2. Specify the machine name for content type.
  3. Choose default language as Not Specified from language settings tabs.
  4. Programatically try to create the entity, the default language will be missing

Proposed resolution

  1. The correct place to set the default language for EntityNG would be LanguageItem::applyDefault().
  2. The easiest way would be a if language module exists check there
  3. if module exists then set language code from the entity using language_get_default_langcode else it will set the language code to LANGCODE_NOT_SPECIFIED.
  4. There is a possibilty of function setValue is getting moved into the language manager service defined under core/lib/Drupal/Core/Entity/Plugin/DataType/LanguageItem.php

Remaining tasks

  1. The patch is ready for review.
  2. also #122 needs addresses.

http://drupal.org/node/1869562#comment-7280616.

Original report by @fago

I just ran into a problem caused by language defaults missing, see http://drupal.org/node/1869562#comment-7280616.

I think that language module should use hook_entity_create() to set the default language, that way any programmatically created entity will get the usual defaults as well.


Viewing all articles
Browse latest Browse all 300625

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>