When only one plugin is available and "Allow quick checkout" is enabled, the following error occurs: The job has no provider assigned.

Steps to reproduce:

  1. Install Drupal 8.0.5 standard profile, tmgmt, tmgmt_microsoft
  2. Enable "Allow quick checkout" on admin/tmgmt/settings
  3. Configure Microsoft plugin (make sure there is only ONE plugin available)
  4. Add some languages
  5. Make article translatable
  6. Click translate tab
  7. Choose a language and click "Request translation"
  8. Error occurs: Drupal\tmgmt\TMGMTException: The job has no provider assigned. in Drupal\tmgmt\Entity\Job->getTranslator() (line 482 of /modules/tmgmt/src/Entity/Job.php).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mpp created an issue. See original summary.

miro_dietiker’s picture

Is this really that minor? ;-)

mpp’s picture

Priority: Minor » Normal

Good point, it is a fatal error so normally I'd go for critical as it breaks functionality. But you can easily circumvent it by disabling "Allow quick checkout" or by adding a second provider so it's not blocking.

How about "Normal"?

mbovan’s picture

Assigned: Unassigned » mbovan
mbovan’s picture

Status: Active » Needs review
FileSize
428 bytes

Debugged this, I can confirm that problem appears with Microsoft translator.

Providing a quick fix/patch here. It looks like this is a problem since we started to implement Continuous support for translators.

In case quick checkout setting is active, we are trying to find a translator with no-checkout-settings support and assigning it to a job. At that point, job isn't saved with a newly assigned translator. In order to not repeat code, we moved all the logic for requesting translation into MicrosoftTranslator::requestJobItemsTranslation() in #2680203: Implement ContinuousTranslatorInterface. As Job object from MicrosoftTranslator::requestTranslation() is not passed further to requestJobItemsTranslation() method, there we have to get/load a new Job instance which of course doesn't contain attached translator.

We can change ContinuousTranslatorInterface API too, and add Job as a second parameter of requestJobItemsTranslation(), but one more save() looks like a less-breakable solution.

I didn't manage to do this with test_translator, so maybe we can test this in tmgmt_microsoft module?

AmeXio’s picture

Status: Needs review » Reviewed & tested by the community

The patch prevents the error from occurring.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Needs work

The quick checkout offering is a core offering and needs test coverage in tmgmt core.
Sure it is possible that the test translator needs improvement to cover the case. We possibly need multiple test translators with varying support.

mpp’s picture

Not sure yet why but the patch in #5 no longer works for 8.x-1.4.

Berdir’s picture

Issue tags: +Needs tests

That's because the whole function is now deprecated and no longer used, there is a new one instead.

I might have seen a related problem caused by this, should have test coverage.

mpp’s picture

@Berdir, see #2942209 for steps to reproduce. You'll need 2 providers as it only occurs when changing the provider during checkout.

thalles’s picture

Hello everyone!
This problem has already occurred in a project I'm working on.
I noticed that they occur in Drupal Lightning, so it seems to me to be an incompatibility between TMGMT and some module of Drupal Lightning.

Drupal\tmgmt\TMGMTException: The job has no provider assigned. in Drupal\tmgmt\Entity\Job->getTranslator() (line 525 of /app/docroot/modules/contrib/tmgmt/src/Entity/Job.php).
Drupal\tmgmt\TMGMTException: The job has no provider assigned. in Drupal\tmgmt\Entity\Job->getTranslator() (line 526 of modules/contrib/tmgmt/src/Entity/Job.php).
Drupal\tmgmt\Entity\Job->canRequestTranslation() (Line: 731)
Drupal\tmgmt\Entity\Job->requestTranslation() (Line: 331)
Drupal\tmgmt\JobCheckoutManager->requestTranslation(Object) (Line: 661)
Drupal\tmgmt\Form\JobForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('tmgmt_job_edit_form', Array, Object) (Line: 144)
Drupal\autosave_form\Form\AutosaveFormBuilder->processForm('tmgmt_job_edit_form', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 97)
Drupal\autosave_form\Form\AutosaveFormBuilder->buildForm(Object, Object) (Line: 91)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 67)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 115)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Berdir’s picture

If it's the same problem then you need to reroll the patch above, as mentioned, that function has been deprecated, the new code is in a new place in a service.

thalles’s picture

I add the line $job->save(); in Drupal\tmgmt\JobCheckoutManager::needsCheckoutForm, but this don't works to me

thalles’s picture

In my case, entering this if:
in Drupal\tmgmt\JobCheckoutManager::needsCheckoutForm

if (empty($translators) || count($translators) > 1) {
   return TRUE;
}

if I comment this "if" works

Berdir’s picture

comment what exactly? and how many translators do you have?

Berdir’s picture

and what kind of translator.

thalles’s picture

I have three translators

  • Global link
  • Users
  • File export

When I comment on the pointed "if"

thalles’s picture

as a matter of fact looks that some data at form don't are being saved(translator).

thalles’s picture

Status: Needs work » Needs review
FileSize
744 bytes

Follow a patch that looks solve this issue

Berdir’s picture

Status: Needs review » Needs work

I don't understand the fix. This will interfere with certain features that we have, like allowing translators to control how things are saved. I've never seen a problem like this, so will need more details. What translators are you using, what exactly is the problem?

thalles’s picture

The translator is: https://globallink.translations.com/
The site use also Acquia site studio(Cohesion)