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

Exception when an entity reference field is empty on programmatic creation

$
0
0

This happens with feeds, feed items and custom blocks, couldnt reproduce it with nodes

Attach an entity reference field that references and entity without items..eg tags and make sure there are no available terms
run this code

<?php
entity_create
('custom_block', array('info'=> 'test', 'type'=> 'basic'))->save();
?>

This leads to:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'field_test_target_id' cannot be null: INSERT INTO {field_data_field_test} (entity_type, entity_id, revision_id, bundle, delta, langcode, field_test_target_id, field_test_revision_id) 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); Array ( [:db_insert_placeholder_0] => custom_block [:db_insert_placeholder_1] => 2 [:db_insert_placeholder_2] => 2 [:db_insert_placeholder_3] => basic [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => ) in Drupal\Core\Entity\DatabaseStorageControllerNG->save() (line 342 of /var/www/d8/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php).


Viewing all articles
Browse latest Browse all 296263

Trending Articles



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