#107095All occurrences of "ajax_" are removed in route keys - inconsistent Ajax keys in TYPO3.settings.ajaxUrls
Description
In the current TYPO3 core implementation, when exporting Ajax routes to the backend JavaScript (TYPO3.settings.ajaxUrls), the string “ajax_” is removed from the route key using
str_replace(‘ajax_’, ‘’, $routeIdentifier) (File: PagerRenderer.php Method addAjaxUrlsToInlineSettings Line 1533).
Problem:
This removes all occurrences of “ajax_” from the key, not just the previously added prefix. As a result, the JavaScript key does not always match the PHP registration, e.g.:
| _.Route key | _.JS key in TYPO3.settings.ajaxUrls |
|---|---|
| myext_ajax_foo_ajax_bar | myext_foo_bar |
This behavior is unintuitive.
Better Solution:
if (strncmp($routeIdentifier, ‘ajax_’, 5) === 0) {
$routeIdentifier = substr($routeIdentifier, 5);
}