Problem/Motivation

For certain site configurations, you can end up with errors on the Google Translator UI form (/admin/tmgmt/translators/manage/google_v3). We have sites that are configured with this file setting:

$config['file.settings']['make_unused_managed_files_temporary'] = TRUE;

See the change record for information on that setting.

When your site is configured this way, you end up with the following error message when you attempt to update your GCP credentials JSON:

The file used in the Google API Credentials field may not be referenced.

The issue here is that the module is not registering file usage for the JSON file uploaded, so when make_unused_managed_files_temporary is set, Drupal wants to downgrade the file to termporary b/c it doesn't see any file usage.

Steps to reproduce

Add this to your settings.php:

$config['file.settings']['make_unused_managed_files_temporary'] = TRUE;

Attempt to upload your GCP credentials JSON at /admin/tmgmt/translators/manage/google_v3

Proposed resolution

Use the file.usage service to register use of the uploaded GCP credentials JSON file.

Remaining tasks

Patch.

  • Delete file usage when the JSON credentials file is removed

User interface changes

None.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

m4olivei created an issue. See original summary.

m4olivei’s picture

Status: Active » Needs work

Opened an MR with a fix. This will work, but be aware that it doesn't take care to clean up file usage. Left as an exercise for the reader for now.

kallado’s picture

Thanks m4olivei kind of busy at the moment I'll check this as soon as possible.

m4olivei’s picture

Issue summary: View changes
kallado’s picture

@m4olivei sorry about the time I also want to fix coding standards and avoid static calls inside the GoogleV3TranslatorUi so the idea would be to use dependency injection and injec the file.usage service and also the language_manager and entity_type.manager let's see if I can find time to fix this soon.

kallado’s picture

Seams dependency njection inside TranslatorUi is still an issue (Support dependency injection for Translator plugins UI class) so not worring about that for now.

  • kallado committed 7ecbedeb on 1.0.x
    Issue #3519748 by m4olivei: File usage of Google Credentials JSON file...
kallado’s picture

@m4olivei pushed to 1.0.x will be fixed on a new release