Issue Bug Closed

#82851Race condition in Icon JS API

Tymoteusz Motylewski 10/24/17, 21:46 updated 10/02/18, 10:56

Description

When you require the same icon multiple times through Icon API in the same moment, API will make multiple calls to PHP backend, because it’s stores the cache only after the first request is back.

It should be changed in the way, that instead of caching the value, we cache the promise object.

How to test it:
Just run following js code in the browser console e.g. in the page module.

require(['TYPO3/CMS/Backend/Icons'], function(Icons) {
   ['mimetypes-x-sys_category', 'mimetypes-x-sys_category', 'mimetypes-x-sys_category', 'mimetypes-x-sys_category','mimetypes-x-sys_category'].forEach(function(item,index){
   Icons.getIcon(item, Icons.sizes.small, null, null, 'inline').done(function(icon) {
      console.log(icon);
   });
   });
});

You will see multiple requests being made for getting the same icon.

Reviews 2