When installing Drupal 8 in the Dutch language, i get the following error message:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_picture_target_id' cannot be null: INSERT INTO {user__user_picture} (entity_id, revision_id, bundle, delta, langcode, user_picture_target_id, user_picture_alt, user_picture_title, user_picture_width, user_picture_height) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => user [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => und [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => [:db_insert_placeholder_9] => )

Installation details:
- Language: Dutch. If I install in English, no errors. Therefore tagging with D8MI.
- Standard profile.
- Step where this error occurs: "Site instellen" (Configure site), when pressing "Save and Continue" (after having filled in the details for the "Site maintenance account").

Files: 
CommentFileSizeAuthor
#22 install_foreign_language-2091523-22-test-only.patch905 bytesyched
FAILED: [[SimpleTest]]: [MySQL] 59,021 pass(es), 5 fail(s), and 1 exception(s).
[ View ]
#22 install_foreign_language-2091523-22.patch2.51 KByched
PASSED: [[SimpleTest]]: [MySQL] 58,699 pass(es).
[ View ]
#17 install_foreign_language-2091523-17.patch2.51 KBpfrenssen
PASSED: [[SimpleTest]]: [MySQL] 58,557 pass(es).
[ View ]
#14 install_foreign_language-2091523-14.patch2.52 KByched
PASSED: [[SimpleTest]]: [MySQL] 58,973 pass(es).
[ View ]
#14 interdiff.txt920 bytesyched
#9 install_foreign_language-2091523-9.patch2.5 KByched
FAILED: [[SimpleTest]]: [MySQL] Setup environment: Test cancelled by admin prior to completion.
[ View ]
#9 interdiff.txt931 bytesyched
#7 install_foreign_language-2091523-7.patch2.53 KByched
FAILED: [[SimpleTest]]: [MySQL] Setup environment: Test cancelled by admin prior to completion.
[ View ]

Comments

Same error observed with installation in German. Git checkout after: Tue Sep 17 10:12:09 2013 +0100

Confirmed after trying to install Head on simplytest.me in german.

Some debugging:
File drupal\core\lib\Drupal\Core\Entity\DatabaseStorageController.php
Method: doSaveFieldItems

<?php
 
protected function doSaveFieldItems(EntityInterface $entity, $update) {
    ...
    foreach (
$this->fieldInfo->getBundleInstances($entity_type, $bundle) as $field_name => $instance) {
       ..
     
$langcodes = $field['translatable'] ? array_keys($entity->getTranslationLanguages()) : array(Language::LANGCODE_NOT_SPECIFIED);
      foreach (
$langcodes as $langcode) {
       
$items = $entity->getTranslation($langcode)->{$field_name}->getValue();
        if (!isset(
$items)) {
          continue;
        }
?>

The User entity passed in does not have a field user_picture, but after executing the $entity->getTranslation($langcode)->{$field_name} part, there is a 'user_picture' entry in the fields property. So _get()ing a {field_name} creates one if it does not yet exist (I guess it has to, otherwise getValue() will fail).

(Simple) solutions (for this problem:
- Have the property {field_name} on an entity return NULL and split the statement
- First check if the field is set, before getting it and also continue if not set
- Have getValue() return something that evaluates to !isset
- Have getValue() return something that evaluates to empty and change the check below

File: drupal\core\lib\Drupal\Core\Entity\Field\Field.php

<?php
 
/**
   * {@inheritdoc}
   * @todo Revisit the need when all entity types are converted to NG entities.
   */
 
public function getValue($include_computed = FALSE) {
    if (isset(
$this->list)) {
     
$values = array();
      foreach (
$this->list as $delta => $item) {
       
$values[$delta] = $item->getValue($include_computed);
      }
      return
$values;
    }
  }
?>

To have getValue() return something that evaluates to empty or !isset we could first do the $item->getValue(...) and only add that to the $values array if it is not empty . But fields already do so at a higher level using their isEmpty() method. Why not here?

Notes:
- This was just some thinking out loud, but as we are so deep in the "entity field kernel" here, I cannot oversee the impact of any of the above suggested changes.
- I also do not understand, if it is indeed flawed at this level, why it would only be discovered now and only during install.
- Nor do I understand why it does not occur in English. I thought that English was now just one of the languages and not special anymore.

It seems that the issue appears on all languages except from English.

Title:Install fails with Integrity constraint violation: 1048 Column 'user_picture_target_id' cannot be nullInstall in foreign language fails with integrity constraint violation on 'user_picture_target_id'
Priority:Major» Critical
Issue tags:+sprint, +language-base

Elevating to critical because you cannot install Drupal 8 in a foreign language anymore.

It seems that the problem is in the user_picture field attachment.

Also, it doesn't fail with minimal profile (because it doesn't have the field).

Status:Active» Needs review
StatusFileSize
new2.53 KB
FAILED: [[SimpleTest]]: [MySQL] Setup environment: Test cancelled by admin prior to completion.
[ View ]

Crossposting the folks in #1983554: Remove BC-mode from EntityNG .

Temptative patch, might break other stuff.
Also, let's try to have the installation of 'standard' profile in a non-english language tested (current test only tests the 'default' profile)

Still failing with:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_picture_target_id' cannot be null: INSERT INTO {user__user_picture} (entity_id, revision_id, bundle, delta, langcode, user_picture_target_id, user_picture_alt, user_picture_title, user_picture_width, user_picture_height) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => user [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => und [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => [:db_insert_placeholder_9] => )

StatusFileSize
new931 bytes
new2.5 KB
FAILED: [[SimpleTest]]: [MySQL] Setup environment: Test cancelled by admin prior to completion.
[ View ]

Thanks for testing :-)
How about this ?

When testing patch from #9 I get:
Warning: Invalid argument supplied for foreach() in Drupal\Core\Entity\DatabaseStorageController->doSaveFieldItems() (line 658 of core/lib/Drupal/Core/Entity/DatabaseStorageController.php)
and install finishes this time.

When updating config translations, I get a warning:

Warning: Invalid argument supplied for foreach() in Drupal\Core\Entity\DatabaseStorageController->doSaveFieldItems() (line 658 of core/lib/Drupal/Core/Entity/DatabaseStorageController.php).

But at the end, Drupal is installed with a foreign language. Yay!!

Status:Needs review» Needs work
Issue tags:-D8MI, -sprint, -language-base

The last submitted patch, install_foreign_language-2091523-9.patch, failed testing.

Status:Needs work» Needs review
Issue tags:+D8MI, +sprint, +language-base

StatusFileSize
new920 bytes
new2.52 KB
PASSED: [[SimpleTest]]: [MySQL] 58,973 pass(es).
[ View ]

Silly me. filterEmptyValues() has no return value.

#14 works like a charm, manually tested it. I didn't run the tests, so waiting for results before RTBCing.

+++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.phpundefined
@@ -670,9 +668,8 @@ protected function doSaveFieldItems(EntityInterface $entity, $update) {
-            $record[$column_name] = (!empty($attributes['serialize'])) ? serialize($value) : $value;
+            $record[$column_name] = (!empty($attributes['serialize'])) ? serialize($item->$column) : $item->$column;

The parentheses around the !empty() are not needed.

Status:Reviewed & tested by the community» Needs review
StatusFileSize
new2.51 KB
PASSED: [[SimpleTest]]: [MySQL] 58,557 pass(es).
[ View ]

Fixed my little niggle from #16.

Interdiff:

+++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.phpundefined
@@ -670,9 +668,8 @@ protected function doSaveFieldItems(EntityInterface $entity, $update) {
-            $record[$column_name] = (!empty($attributes['serialize'])) ? serialize($item->$column) : $item->$column;
+            $record[$column_name] = !empty($attributes['serialize']) ? serialize($item->$column) : $item->$column;

Status:Needs review» Needs work

The last submitted patch, install_foreign_language-2091523-17.patch, failed testing.

Status:Needs work» Needs review

Status:Needs review» Reviewed & tested by the community

Tested this installing in Spanish and works like a charm.

@pfrenssen, please, next time you could provide interdiffs that makes easier to review: https://drupal.org/node/1488712. Thanks for the nitpick and the patch!

Status:Needs review» Reviewed & tested by the community

@penyaskito, you're right I forgot to include the interdiff, I've now pasted it in my comment #17. Thanks!

StatusFileSize
new2.51 KB
PASSED: [[SimpleTest]]: [MySQL] 58,699 pass(es).
[ View ]
new905 bytes
FAILED: [[SimpleTest]]: [MySQL] 59,021 pass(es), 5 fail(s), and 1 exception(s).
[ View ]

Just re-uploading with a test-only patch to make sure that the test catches the failure.

Status:Reviewed & tested by the community» Fixed

Committed/pushed to 8.x, thanks!

Status:Fixed» Closed (fixed)

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

Issue tags:-sprint

Superb, thanks!