We have some custom code that updates an existing file in certain circumstances. Our custom code runs this fairly normal Drupal code:
$file = file_save_data($content, $uri, FILE_EXISTS_REPLACE);
When this gets run the first time, a record for the file is added to acquia_contenthub_publisher's acquia_contenthub_publisher_export_tracking
table. The second time this runs, the acquia_contenthub_module throws an SQL error:
The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Core\Entity\EntityStorageException</em>: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'file-376' for key 'entity': INSERT INTO {acquia_contenthub_publisher_export_tracking} (entity_type, entity_id, entity_uuid, status, created, modified, hash) 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); Array
(
[:db_insert_placeholder_0] => file
[:db_insert_placeholder_1] => 376
[:db_insert_placeholder_2] => 4320e516-22a7-49f1-8fe3-2b45c1fb5933
[:db_insert_placeholder_3] => queued
[:db_insert_placeholder_4] => 2019-08-14T14:04:25-05:00
[:db_insert_placeholder_5] => 2019-08-14T14:04:25-05:00
[:db_insert_placeholder_6] =>
)
in <em class="placeholder">Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()</em> (line <em class="placeholder">783</em> of <em class="placeholder">core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php</em>).
The acquia_contenthub_publisher module reacts to the file_save_data()
call as if a new file is being created each time each time, resulting in the above SQL error.
I'm attaching a patch that fixes the issue by merging rather than inserting when adding entries to the tracking table.
Closed: outdated
2.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.