Support New DT-Import Non-Overwrite Setting#2668
Conversation
|
@kodinkat does
Does that sound right? |
|
I'm curious about adding this feature to the We'll also need to write some unit tests for this. AI should be good at this part. |
…ools-theme into dt-import-43-overwrite-support
This is correct, as new logic only updates/adds value if field does not already contain it. Therefore, ignoring any duplicates. |
Sounds good, maybe tackle as a new ticket, once functionality has been merged in? |
|
On this one lets go slower. |
…ools-theme into dt-import-43-overwrite-support
|
@corsacca pls see latest shape and let me know if this holds up for you... |
|
@kodinkat can you make sure there are tests for each field type? |
…ools-theme into dt-import-43-overwrite-support
|
A clarification. The results should be Because we have the "dont_overwrite_existing_fields" set to true. Right now the result is |
…disciple-tools-theme into dt-import-43-overwrite-support
…ple_Tools_Posts class
|
@corsacca see latest updates; which should now produce the desired shape. |
|
@kodinkat The same thing applies for all the other fields too. For example date is being updated even if original has a date. |
…ng revised requirements
|
@corsacca Below is a summary of the logic now adopted across the different field types, when The following field types, will only be allowed to update, if no existing values are detected.
The following field types, will only be allowed to update, if no matching options are detected. However, non-matching options could also exist.
Also, just to highlight, as the |
…lect fields are not overwritten during post creation
|
@kodinkat Missing tests for multi_select, user_select, connection. |
…nnection fields; update unit tests to ensure fields are not overwritten during creation and updates
|
Thank you @kodinkat! |
… format The dt_ignore_duplicated_post_fields function now correctly handles both direct array format [['value' => 'xxx']] and wrapped format ['values' => [['value' => 'xxx']]] for communication_channel fields. - Added logic to detect if field_value has a 'values' key and extract the correct array to iterate over - Preserves the original format (wrapped or direct) when returning updated fields - Fixes bug where wrapped format was not being processed correctly, leading to incorrect duplicate detection This ensures that duplicate detection works consistently regardless of the field format received.
All multi-value field types (tags, link, connection, multi_select, location, location_meta, communication_channel) now consistently: - Accept both direct array format [['value' => 'xxx']] and wrapped format ['values' => [['value' => 'xxx']]] - Always return wrapped format ['values' => ] for consistency This ensures uniform behavior across all field types and eliminates format inconsistencies that could cause issues when fields are provided in different formats.
…d formats Modified the unit tests for create and update post functionalities to use the new wrapped format for contact_phone and contact_email fields. This change ensures consistency with the recent updates to field handling across the codebase.
There was a problem hiding this comment.
Bug: Field Overwrite Bug in `dt_ignore_duplicated_post_fields`
The dt_ignore_duplicated_post_fields function incorrectly uses empty() to determine if existing field values should be preserved. This causes valid falsy values (e.g., boolean false, number 0, or string '0' for key_select fields) to be treated as empty and overwritten, even when do_not_overwrite_existing_fields is enabled. The check should verify if the field is unset or null instead.
dt-posts/posts.php#L3179-L3182
disciple-tools-theme/dt-posts/posts.php
Lines 3179 to 3182 in f2b999e
Was this report helpful? Give feedback by reacting with 👍 or 👎
No description provided.