Uploaded image for project: 'translate5'
  1. translate5
  2. TRANSLATE-4818

Prevent random import errors by removing self mutating data

XMLWordPrintable

    • High
    • Due a bug in the pricing preset context sometimes imports are broken without any valuable reason.

      problem

      Since the task_Meta::getPricingPresetId method is not only getting content but also setting the default one when it is not there, this is leading to import crashes: 

       2025-07-23 08:45:58 ERROR E9999 (# 6994228) plugin.across_hotfolder → PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '{de013e07-3a8a-4800-aec1-6502bdcab055}' for key 'ta
      skGuid'
      
       2025-07-23 08:45:58 ERROR E9999 (# 6994229) plugin.across_hotfolder → Zend_Db_Statement_Exception: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '{de013e07-3a8a-4800-aec1-6502bdcab05
      5}' for key 'taskGuid', query was: INSERT INTO `LEK_task_meta` (`taskGuid`, `bconfId`, `bconfInZip`, `pricingPresetId`, `perTaskExport`) VALUES (?, ?, ?, ?, ?)
      
       2025-07-23 08:45:58 ERROR E1015 (# 6994230) core.entity.editor_Models_Task_Meta → ZfExtended_Models_Entity_Exceptions_IntegrityDuplicateKey: Duplicate Key on saving editor_Models_Task_Meta 

      explanation

      1. Project is created and saved at the top of the \MittagQI\Translate5\Task\Import\ImportService::importProject method,
      2. then the tasks are generated and task imports scheduled,
      3. then at the end the project and project meta is saved again into DB.
        That final save crashes with the above errors. 

      This can happen due the implementation of getPricingPresetId method which is not only returning data, but also setting it into the DB. getPricingPresetId is implicitly called on task overview to add the pricingPresets to each task. If such a taskController::getAction is called while an import is in above step 2, the task meta of the project is saved implicitly what leads then to the duplicate key exception

      the one and only solution

      getPricingPresetId must return only the value. See https://en.wikipedia.org/wiki/Command%E2%80%93query_separation since "asking a question should not change the answer".

      The initialisation must be ensured by migration script (not needed anymore) and when projects / tasks are created by consuming the initTaskMeta event and populating the there passed DTO

            pavelperminov Pavel Perminov
            tlauria Thomas Lauria
            Thomas Lauria
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: