Add error handler when there's no Drupal entity to be created

Created on 23 October 2019, about 5 years ago
Updated 28 May 2024, 7 months ago

I'm debugging this for nearly two days now already. And maybe I'm missing something. But all I get are fatal integrity constraint violation about the title can not be null when trying to pull from Salesforce and creating entities.

Mapping looks good. Pulling Salesforce campaigns and mapped the campaign ID to node title. Campaign ID never is null. Should actually work. Digging around a bit with Xdebug the results returned from Salesforce look good as well. All mapped field values in there. But then there are these lines in salesforce/modules/salesforce_pull/src/Plugin/QueueWorker/PullBase.php's createEntity method which really make me wonder how this is actually supposed to be working at all. I must miss something.

      $values = [];
      if (isset($entity_keys['bundle'])
          && !empty($entity_keys['bundle'])) {
        $values[$entity_keys['bundle']] = $mapping->getDrupalBundle();
      }

      // See note above about flag.
      $values['salesforce_pull'] = TRUE;

      // Create entity.
      $entity = $this->etm
        ->getStorage($entity_type)
        ->create($values);

I mean, there's an empty $values array being initiated and only populated with the bundle string and the salesforce_pull Boolean. And then the entity gets created from these values. No wonder I'm getting these errors. But now what? As this seems to be in the codebase for quite some time already. So it seems it's supposed to be like that.

Settings an automatic entity label for the mapped node type or setting a fixed title inside the above code fixes the fatal. But still the mapped values are not being filled in their assigned fields. What's wrong? What am I missing?

The website encountered an unexpected error. Please try again later.Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null: INSERT INTO {node_field_data} (nid, vid, type, langcode, status, title, uid, created, changed, promote, sticky, default_langcode, revision_translation_affected, rh_action, rh_redirect, rh_redirect_response, content_translation_source, content_translation_outdated) 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, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17); Array
(
[:db_insert_placeholder_0] => 2668
[:db_insert_placeholder_1] => 7133
[:db_insert_placeholder_2] => event
[:db_insert_placeholder_3] => und
[:db_insert_placeholder_4] => 1
[:db_insert_placeholder_5] =>
[:db_insert_placeholder_6] => 127
[:db_insert_placeholder_7] => 1571837238
[:db_insert_placeholder_8] => 1571837238
[:db_insert_placeholder_9] => 0
[:db_insert_placeholder_10] => 0
[:db_insert_placeholder_11] => 1
[:db_insert_placeholder_12] => 1
[:db_insert_placeholder_13] =>
[:db_insert_placeholder_14] =>
[:db_insert_placeholder_15] =>
[:db_insert_placeholder_16] => und
[:db_insert_placeholder_17] => 0
)
in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 847 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Drupal\Core\Database\Statement->execute(Array, Array) (Line: 631)
Drupal\Core\Database\Connection->query('INSERT INTO {node_field_data} (nid, vid, type, langcode, status, title, uid, created, changed, promote, sticky, default_langcode, revision_translation_affected, rh_action, rh_redirect, rh_redirect_response, content_translation_source, content_translation_outdated) 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, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17)', Array, Array) (Line: 358)
Drupal\Core\Database\Driver\mysql\Connection->query('INSERT INTO {node_field_data} (nid, vid, type, langcode, status, title, uid, created, changed, promote, sticky, default_langcode, revision_translation_affected, rh_action, rh_redirect, rh_redirect_response, content_translation_source, content_translation_outdated) 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, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17)', Array, Array) (Line: 32)
Drupal\Core\Database\Driver\mysql\Insert->execute() (Line: 1048)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->saveToSharedTables(Object) (Line: 986)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->doSaveFieldItems(Object) (Line: 657)
Drupal\Core\Entity\ContentEntityStorageBase->doSave(NULL, Object) (Line: 457)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 838)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 394)
Drupal\Core\Entity\EntityBase->save() (Line: 573)
Drupal\salesforce_mapping\Entity\MappedObject->pull() (Line: 269)
Drupal\salesforce_pull\Plugin\QueueWorker\PullBase->createEntity(Object, Object) (Line: 122)
Drupal\salesforce_pull\Plugin\QueueWorker\PullBase->processItem(Object) (Line: 198)
Drupal\salesforce_pull\Controller\PullController->processQueue() (Line: 160)
Drupal\salesforce_pull\Controller\PullController->endpoint(Object, 'ZhvI61IwzEJef2hjPNPyp1cQMzeIpFKQ_0tHnGuJqzoNy7IDcOQwZygFd1ueJo3n2TF0g5CVrw', NULL)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
✨ Feature request
Status

Needs review

Version

5.0

Component

salesforce_pull.module

Created by

leymannx Berlin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024