Glpi: GLPI 9.4.1 - locales caching issue after a plugin upgrade

Created on 22 Mar 2019  路  3Comments  路  Source: glpi-project/glpi

Describe the bug

Hi

I encounteer caching problems in a specific case with locales, causung an unhandled exception.

If I upgrade a plugin, and the new version replaces a simple localized string with a localized array (singular / pluaral), then the cache in GLPI is not updated and when the lcoale is used a fatal error occurs

Page(s) URL

If applicable, page(s) URL where the bug happens.

To reproduce

Steps to reproduce the behavior:

  1. have a plugin installed
  2. upgrade the plugin, and replace a single locale, usually from __('my string', 'myplugin') to _n('my string', 'my strings', 1, 'myplugin')
  3. display the page which uses the locale
  4. See error

Expected behavior

No crash, and proper display of the locale.

Logs

PHP Fatal error:  Uncaught Zend\\I18n\\Exception\\OutOfBoundsException: Provided index 1 does not exist in plural array in /home/dethegeek/public_html/glpi-94/vendor/zendframework/zend-i18n/src/Translator/Translator.php:415\nStack trace:
#0 /home/dethegeek/public_html/glpi-94/inc/autoload.function.php(172): Zend\\I18n\\Translator\\Translator->translatePlural('Access type', 'Access types', 2, 'formcreator')
#1 /home/dethegeek/public_html/glpi-94/plugins/formcreator/inc/form_profile.class.php(44): _n('Access type', 'Access types', 2, 'formcreator')
#2 /home/dethegeek/public_html/glpi-94/plugins/formcreator/inc/form_profile.class.php(48): PluginFormcreatorForm_Profile::getTypeName(2)
#3 /home/dethegeek/public_html/glpi-94/inc/commonglpi.class.php(210): PluginFormcreatorForm_Profile->getTabNameForItem(Object(PluginFormcreatorForm), 0)
#4 /home/dethegeek/public_html/glpi-94/plugins/formcreator/inc/form.class.php(738): CommonGLPI->addStandardTab('PluginFormcreat...', Array, Array)
#5 /home/dethegeek/public_html/glpi-94/inc/commonglpi.class in /home/dethegeek/public_html/glpi-94/vendor/zendframework/zend-i18n/src/Translator/Translator.php on line 415, referer: http://localhost/~dethegeek/glpi-94/plugins/formcreator/front/form.form.php?id=3

Careful check on .pot, .po and .mo file, and rebuild when necessary was not enough to solve the bug. I had to delete the cache files in GLPI.

I think that GLPI should invalidate locales cache, if possible for the plugin's domain only, after call of Plugin::install().

Moreover, some plugins have a CLI installer. We may need to document that install or upgrade should / must be run via Plugin::install() method, tu ensure invalidation of the cache.

bug

Most helpful comment

I changed the fix. I clean translation cache on plugin update (but I have to clean it for everyone).

Cleaning the whole translation cache when a plugin is installed seems not a problem, as it should be a rare operation.

All 3 comments

@btry

Can you test #5672 ? It should do the trick.

Regards

@cedric-anne

it works for me, but I think this fix will decrease performance when GLPI generates notifications. I think we should locate the magic elsewhere (see my comment in the PR)

I changed the fix. I clean translation cache on plugin update (but I have to clean it for everyone).

Cleaning the whole translation cache when a plugin is installed seems not a problem, as it should be a rare operation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Aijt picture Aijt  路  6Comments

stonebuzz picture stonebuzz  路  3Comments

ymfinidori picture ymfinidori  路  5Comments

trasher picture trasher  路  6Comments

hypemonkey picture hypemonkey  路  5Comments