mautic / mautic-typo3

Add-on TYPO3 extension that enhances the "EXT:marketing_automation" TYPO3 extension by connecting it to the Mautic Marketing Automation platform: Determine "Persona" from Mautic segments. Also provides additional services e.g. language synchronisation between Mautic and TYPO3.
https://www.Leuchtfeuer.com
GNU General Public License v2.0
22 stars 19 forks source link

Create Mautic tag in TYPO3 results in error "Record with UID x from table tx_mautic_domain_model_tag not found" #82

Closed Moongazer closed 1 year ago

Moongazer commented 1 year ago

Describe the bug In certain cases it can happen, that adding Mautic tags in TYPO3 resulting in the following errors after saving the tag:

Record with UID x from table tx_mautic_domain_model_tag not found

Edit form could not be loaded: The edit form could not be loaded for the requested records. This might be due to insufficient permissions.

Regardless, the tag is created in Mautic. The reason is a different AUTO_INCREMENT counter-value of the tag-tables on both systems (tx_mautic_domain_model_tag for TYPO3, lead_tags for Mautic). For example adding a new "TestTag" this is what happens:

  1. The new tag record is added to tx_mautic_domain_model_tag, e.g. with UID 10
  2. The new tag is created in Mautic via TCEmainHook, e.g. with ID 5
  3. TYPO3 calls TagRepository->synchronizeTags() which fetches all tags from Mautic (including their IDs), deletes all tags in tx_mautic_domain_model_tag and adds each Mautic tag with their ID as UID.
  4. TYPO3 tries to re-display the created record in edit-mode by its UID 10, which is marked as deleted=1 now. The form-framework doesn't know that in the background the UID was changed to 5 in this example, leading to the error above.

To Reproduce Steps to reproduce the behavior:

  1. Manually change the AUTO_INCREMENT counters for both tables (tx_mautic_domain_model_tag for TYPO3, lead_tags for Mautic) to differnt values.
  2. In TYPO3, open a page or content-element, go to the "Mautic" tab and create a new tag
  3. Saving the tag results in the errors mentioned above

Expected behavior After saving the new created tag, the tag edit-form is displayed like for any other TYPO3 record.

Environment TYPO3 v10, v11 EXT:mautic (any version)

Additional context This issue is the result of a conceptual software-design decision, which expects the tag-tables to be always equal in both databases (TYPO3 and Mautic). Therefor the sync-process between both tables also syncronizes the IDs which leads to the behaviour described here.

The best solution would be, if we're able to change/overwrite the UID which the form-framework tries to open (edit-form) after the sync-process. If this is not possible, we should document this error as "known issue", so database administrators must make sure that both tag-tables always having the equal AUTO_INCREMENT value.