Problem/Motivation

#2678332: Merge normal and continuous job overviews fixes the problem with left-overs from translation providers. However, we still need to update the status to "Aborted" of the jobs where uninstalled translator was used.

Proposed resolution

Providing some sort of uninstall hook that should update all dependent jobs to status "Aborted".

Comments

mbovan created an issue. See original summary.

miro_dietiker’s picture

Title: Abort open jobs after uninstalling a translator provider » Abort open jobs when uninstalling a translator provider

Yeah, the uninstallation should clean up open jobs and set them to aborted. :-)

Dunno about the uninstall message... Can we add a statement there such as "All pending jobs are aborted"?

berdir’s picture

Note that #2678332: Merge normal and continuous job overviews now adds the config dependency, so uninstalling a module *will* delete those translators.

mbovan’s picture

Assigned: Unassigned » mbovan
Issue summary: View changes

#2678332: Merge normal and continuous job overviews fixes the Exception problem. We still need to update the status to "Aborted".

mbovan’s picture

Status: Active » Needs review
StatusFileSize
new1.25 KB

Implemented hook_modules_uninstalled() where I check if uninstalled modules are in the list of possible translators.
In that case, all active (active, continuous or unprocessed) jobs will be aborted. I don't check jobs in the state of review, finished, rejected or continuous inactive.

berdir’s picture

Why don't we just rely on translators that are being deleted? We prevent that in the UI, but it can still happen.

E.g. you could delete a translator through config deployment, then this should also happen. So translator post/pre delete, not module based.

mbovan’s picture

I thought we are preventing it using API as well... There is a check for busy translators in Translator::preDelete().

I added my code to "else" and to support "unprocessed" jobs. I'm not sure that Translator::preDelete() works like it's documented?

berdir’s picture

Status: Needs review » Needs work

Yes, that's in presave, which is an array that's not passed by reference. that's definitely broken.

What we should do is move that logic to TranslatorAccessControlHandler and prevent delete access for busy translators.

That won't prevent them from being deleted, which we have to allow as an API call and in that case, we do want to abort the jobs.

mbovan’s picture

Status: Needs work » Needs review
StatusFileSize
new4.53 KB
new5.02 KB

Moved the logic to TranslatorAccessControlHandler::checkAccess(). We don't need TranslatorDeleteForm anymore I guess, so removed.

berdir’s picture

+++ /dev/null
@@ -1,29 +0,0 @@
-  public function validateForm(array &$form, FormStateInterface $form_state) {
-    parent::validateForm($form, $form_state);
-    if (tmgmt_translator_busy($this->entity->id())) {
-      $form_state->setErrorByName('tmgmt', t('This provider cannot be deleted as long as there are active jobs using it.'));
-    }
-  }

ah, that's how we did it. Not showing delete without explanation is always a bit tricky but yes, I think this makes sense, it's also annoying when it tells you you can but then not really ;)

A test that deleting through the API does this would be nice.

mbovan’s picture

Updated tests.

  • Berdir committed 57190bd on 8.x-1.x authored by mbovan
    Issue #2679595 by mbovan: Abort open jobs when uninstalling a translator...
berdir’s picture

Status: Needs review » Fixed

Nice, committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.