Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-72442

Customfield Cache Management is sensitive to Administrator's Locale

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Low Low
    • None
    • 7.4.0, 8.15.1
    • Java API
    • None

      Issue Summary

      Performing any UPM update will flush & rebuild the caches (as expected); however, it will rebuild the caches using the locale of the admin that triggered the flush. Querying against the caches will then result in unexpected translation issues.

      Steps to Reproduce

      We can reproduce the problem using the Jira API. To simplify steps, we use a ScriptRunner script for this below;
      1) Create to users admin_en and admin_fr and add them the jira-administrators group
      2) Either during the user's first login or later using Profile/preferences screen, set admin_fr user's language to French
      3) Login using admin_en, and create a new custom field named my.customfield
      4) Add two translations to this custom field using translate context menu item;
      4.1) for English, My Custom Field
      4.2) for French, Mon Champ Personnalisé
       5. Run the following script using ScriptRunner console

      import com.atlassian.jira.component.ComponentAccessor;
      import com.atlassian.jira.issue.CustomFieldManager;
      import com.atlassian.jira.issue.fields.CustomField;
      
      CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
      
      String CF_MYCUSTOMFILELD = "my.customfield"
      String CF_MYCUSTOMFILELD_ENGLISH_TRANSLATION = "My Custom Field"
      String CF_MYCUSTOMFILELD_FRENCH_TRANSLATION = "Mon Champ Personnalisé"
      
      CustomField cf = null;
      
      cf = customFieldManager.getCustomFieldObjectByName(CF_MYCUSTOMFILELD); 
      log.warn("untranslated: " + cf)
      
      cf = customFieldManager.getCustomFieldObjectByName(CF_MYCUSTOMFILELD_ENGLISH_TRANSLATION); 
      log.warn("english: " + cf)
      
      cf = customFieldManager.getCustomFieldObjectByName(CF_MYCUSTOMFILELD_FRENCH_TRANSLATION); 
      log.warn("french: " + cf)
      

      5) the output is like below

      untranslated: My Custom Field
      english: null
      french: null
      

      6) use script runner built-in script to flush all Jira internal caches and run the script again, the result is now as below

      untranslated: null
      english: My Custom Field
      french: null
      

      7) Logout and login as user admin_fr. Run the script again using this user. The result is now

      untranslated: null  
      english: Mon Champ Personnalisé  
      french: null
      

      8) While still logged in as user admin_fr, clear caches like above and run the script again. The result is now

      untranslated: null 
      english: null 
      french: Mon Champ Personnalisé
      

      9) Logout and login back with user admin_en again, and run the script again. The result is now

      untranslated: null
      english: null
      french: My Custom Field
      

      Expected Results

      We expect consistent outputs, the cache will be rebuilt using untranslated names.

      Actual Results

      The cache is rebuilt according to the language of the administrator who triggered the flush.

      Workaround

      As a workaround, it is possible to get the full list of custom fields and check their 'untranslated name' one by one to find the correct custom field:

      cf = customFieldManager.getCustomFieldObjects().find { it.getUntranslatedName() == CF_MYCUSTOMFILELD}

      Please note that this may be inefficient with larger sets of custom fields.

              Unassigned Unassigned
              shoornaert@atlassian.com Scott Hoornaert
              Votes:
              9 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated: