- achap 🇦🇺
So I think this is actually a bug and not just with moderated entities. Initially I thought it was due to the referenced core bug (which is why marking revisions as outdated was hidden in the first place in core for moderated entities) but I was actually able to reproduce it for unmoderated entities too on a freshly installed site without any of my custom code.
Steps to reproduce:
- Setup a fresh ddev instance of Drupal https://ddev.readthedocs.io/en/latest/users/quickstart/#drupal
- Require tmgmt with composer and install via drush.
- Enable the tmgmt_test module via drush so the test translator is available.
- Enable German as a language.
- Enable Spanish as a language
- Make the default article bundle translatable along with all fields
- Setup a continuous job for the article in German using test translator
- Setup a continuous job for the article in Spanish using test translator
- Create an article and save it
- Run the following SQL and you should see two inactive continuous jobs
select tji.item_id, tji.tjiid, tj.target_language from tmgmt_job_item as tji join tmgmt_job as tj on tji.tjid = tj.tjid where tj.job_type = 'continuous' and tji.state = 'inactive';
- Run
ddev drush php-eval "tmgmt_cron();"
and then run the SQL above again and there should be no inactive job items. - Go to the article in the original language and click mark translation as outdated then save it.
- Now if you run the SQL again there should be two inactive items
- Now run
ddev drush php-eval "tmgmt_cron();"
again and when you run your SQL you will see one job item remaining.
Now matter how many times you run tmgmt_cron() via drush from there there is always one remaining inactive item and it alternates between de and es. It's like one is always marking the other as outdated.
Would appreciate if someone else can confirm my steps to reproduce. Would potentially think about marking this as major if it's confirmed as this can cause a huge amount of revisions/costs from re translation.
Versions: Drupal core 11.1.8, tmgmt 1.17.0
- Merge request !122Draft: Create a second continuous job to show the translation loop bug → (Open) created by achap
- achap 🇦🇺
When adding an additional continuous job in Spanish and duplicating the steps that were created in German I can replicate it in a test:
1) Drupal\Tests\tmgmt_content\Kernel\ContentEntitySourceUnitTest::testContinuousJobItems No continuous job item is automatically created when translation is accepted. Failed asserting that 4 matches expected 3. /builds/issue/tmgmt-3063378/vendor/phpunit/phpunit/src/Framework/Constraint/Equality/IsEqual.php:95 /builds/issue/tmgmt-3063378/sources/content/tests/src/Kernel/ContentEntitySourceUnitTest.php:834 /builds/issue/tmgmt-3063378/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
As best I can tell, when the translation is accepted and saved, tmgmt_content_entity_update() is called, at which point the untranslated entity is again sent to the continuous manager but at this point in shouldCreateContinuousItem the metadata returns that both of the translations are still outdated. For whatever reason, this doesn't occur with a single translation job. The German node was previously being marked as outdated correctly.
- achap 🇦🇺
Explicitly marking the translation as outdated when it is saved in ContentEntitySource means the test passes but I would have thought that would have been done automatically by Drupal? I'm not sure if this is the correct fix but it does stop the loop. I would appreciate if someone could review it and share their thoughts especially if they can figure out why this only occurs with a second job.