Skip to content

Commit

Permalink
[BUGFIX] Fix requirejs-loader config and error handling
Browse files Browse the repository at this point in the history
Adapt the fetch-configuration URL query string, to account for the
backend url change in #93048, in order to use a questionmark
to concatenate the query string instead of an ampersand.
But allow for both, base URLs with and without question mark,
as frontend context via eID would still require an ampersand
for concatenation.

Also fix a error callback name clash and properly propagate
fetchConfiguration errors through the requirejs error handling,
for requirejs errbacks to be invoked.

Resolves: #93227
Related: #93048
Releases: master, 10.4
Change-Id: If843db529e19e6af2681871a2d6307d67acbea56
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67346
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Richard Haeser <richard@richardhaeser.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Benjamin Franzke <bfr@qbus.de>
Reviewed-by: Richard Haeser <richard@richardhaeser.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Benjamin Franzke <bfr@qbus.de>
  • Loading branch information
bnf committed Jan 6, 2021
1 parent f4fac8d commit 205df90
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions typo3/sysext/core/Resources/Public/JavaScript/requirejs-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
if (this.status === 200) {
success(JSON.parse(xhr.responseText));
} else {
error(this.status, xhr.statusText);
error(this.status, new Error(xhr.statusText));
}
} catch (error) {
error(this.status, error);
} catch (err) {
error(this.status, err);
}
};
xhr.open('GET', config.typo3BaseUrl + '&name=' + encodeURIComponent(name));
xhr.open('GET', config.typo3BaseUrl + (config.typo3BaseUrl.indexOf('?') === -1 ? '?' : '&' ) + 'name=' + encodeURIComponent(name));
xhr.send();
};

Expand Down Expand Up @@ -128,7 +128,13 @@
// result cannot be returned since nested in two asynchronous calls
originalLoad.call(req, context, name, url);
},
function() {}
function(status, err) {
var error = new Error('requirejs fetchConfiguration for ' + name + ' failed [' + status + ']');
error.contextName = context.contextName;
error.requireModules = [name];
error.originalError = err;
context.onError(error);
}
);
};
})(requirejs);

0 comments on commit 205df90

Please sign in to comment.