Problem/Motivation

In an event of rare conditions:
- create a job without a target language
- abort it (?)
- visit the job manage page

the TMGMT produces a fatal error:
Error: Call to a member function getName() on null in Drupal\tmgmt\Form\JobForm->form() (line 120 of /modules/contrib/tmgmt/src/Form/JobForm.php)

Proposed resolution

Implement a safe check for this specific use-case.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

mbovan created an issue. See original summary.

berdir’s picture

Yes, we can add a check here, but the snippet is this:

if (!$job->getTargetLangcode() || $job->getTargetLangcode() == LanguageInterface::LANGCODE_NOT_SPECIFIED) {
      $job->target_language = key($available['target_language']);
      $target = '?';
    }
    else {
      $target = $job->getTargetLanguage()->getName();
    }

So it only goes into the if if the target langcode is that is not empty and not UND. So unless I'm missing something, this can only happen if you create a job with a target language and then delete that language. Which I suppose is a valid scenario, especially if you're trying out things.

berdir’s picture

Status: Active » Needs review
StatusFileSize
new655 bytes

Confirmed and reproduced, this does fix that, but not sure what we're supposed to do with these jobs then.

berdir’s picture

The last submitted patch, 4: tmgmt-invalid-langcode-061416-4-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mbovan’s picture

Status: Needs review » Reviewed & tested by the community

Looks great!

berdir’s picture

Status: Reviewed & tested by the community » Fixed

  • Berdir committed c90a895 on 8.x-1.x
    Issue #3061416 by Berdir, mbovan: Managing a job without the target...

Status: Fixed » Closed (fixed)

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