Bug #82851

Race condition in Icon JS API

Added by Tymoteusz Motylewski about 2 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
-
Start date:
2017-10-24
Due date:
% Done:

100%

TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.

Associated revisions

Revision c81efca2 (diff)
Added by Tymoteusz Motylewski about 2 years ago

[BUGFIX] Avoid race condition in JS Icon API

Now promise is cached instead of promise result, to avoid race condition
when requesting the same icon multiple times.
Now API will do just one ajax call per icon, even if the other API call
is made before the first one finishes.

Resolves: #82851
Releases: master, 8.7
Change-Id: I4110f84d32c7f1856c1664a02d3c9a2ba59168a6
Reviewed-on: https://review.typo3.org/54470
Tested-by: TYPO3com <>
Reviewed-by: Andreas Wolf <>
Reviewed-by: Andreas Fernandez <>
Reviewed-by: Stefan Neufeind <>
Tested-by: Stefan Neufeind <>
Reviewed-by: Frank Naegler <>
Tested-by: Frank Naegler <>

Revision ebb10866 (diff)
Added by Tymoteusz Motylewski about 2 years ago

[BUGFIX] Avoid race condition in JS Icon API

Now promise is cached instead of promise result, to avoid race condition
when requesting the same icon multiple times.
Now API will do just one ajax call per icon, even if the other API call
is made before the first one finishes.

Resolves: #82851
Releases: master, 8.7
Change-Id: I4110f84d32c7f1856c1664a02d3c9a2ba59168a6
Reviewed-on: https://review.typo3.org/54486
Tested-by: TYPO3com <>
Tested-by: Stefan Neufeind <>
Reviewed-by: Frank Naegler <>
Tested-by: Frank Naegler <>

History

#1 Updated by Gerrit Code Review about 2 years ago

  • Status changed from Accepted to Under Review

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54470

#3 Updated by Gerrit Code Review about 2 years ago

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54486

#4 Updated by Tymoteusz Motylewski about 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#5 Updated by Benni Mack about 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF