mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-27 17:01:07 +00:00
Use MultiHttpClient instead of VirtualRESTService.
This fixes the problems with If208753edfdb301 which was reverted and adds a new test. Bug: T335347 Co-Authored-By: <rrana-ctr@wikimedia.org> Change-Id: I7ddb7b294cbccc4dab42e286fc270f438385bee5
This commit is contained in:
parent
7a5f952a11
commit
8a589a161c
|
@ -219,8 +219,20 @@ class MathRestbaseInterface {
|
|||
$wgVisualEditorFullRestbaseURL;
|
||||
if ( $internal && $wgMathUseInternalRestbasePath && isset( $wgVirtualRestConfig['modules']['restbase'] ) ) {
|
||||
$restBaseUrl = $wgVirtualRestConfig['modules']['restbase']['url'];
|
||||
$restBaseDomain = $wgVirtualRestConfig['modules']['restbase']['domain'] ?? 'localhost';
|
||||
$restBaseUrl = rtrim( $restBaseUrl, '/' );
|
||||
|
||||
$restBaseDomain = $wgVirtualRestConfig['modules']['restbase']['domain'] ?? 'localhost';
|
||||
|
||||
// Ensure the correct domain format: strip protocol, port,
|
||||
// and trailing slash if present. This lets us use
|
||||
// $wgCanonicalServer as a default value, which is very convenient.
|
||||
// XXX: This was copied from RestbaseVirtualRESTService. Use UrlUtils::parse instead?
|
||||
$restBaseDomain = preg_replace(
|
||||
'/^((https?:)?\/\/)?([^\/:]+?)(:\d+)?\/?$/',
|
||||
'$3',
|
||||
$restBaseDomain
|
||||
);
|
||||
|
||||
return "$restBaseUrl/$restBaseDomain/v1/$path";
|
||||
}
|
||||
if ( $wgMathFullRestbaseURL ) {
|
||||
|
|
|
@ -381,6 +381,25 @@ class MathRestbaseInterfaceTest extends MediaWikiIntegrationTestCase {
|
|||
'http://restbase.test.internal/api/testDomain/v1/media/math/render/svg/2uejd9dj3jd'
|
||||
];
|
||||
|
||||
yield 'VirtualRestConfig case with full URL as domain' => [
|
||||
$path,
|
||||
true,
|
||||
[
|
||||
'MathUseInternalRestbasePath' => true,
|
||||
'VirtualRestConfig' => [
|
||||
'modules' => [
|
||||
'restbase' => [
|
||||
'url' => 'http://restbase.test.internal/api', // Should work with trailing slash '/'
|
||||
'domain' => 'https://testDomain:1234/' // domain name should be extracted from url
|
||||
]
|
||||
]
|
||||
],
|
||||
'MathFullRestbaseURL' => "https://myWiki.test/",
|
||||
'VisualEditorFullRestbaseURL' => 'VisualEditor/api/rest_' // This should be ignored
|
||||
],
|
||||
'http://restbase.test.internal/api/testDomain/v1/media/math/render/svg/2uejd9dj3jd'
|
||||
];
|
||||
|
||||
yield 'VisualEditor case' => [
|
||||
$path,
|
||||
true,
|
||||
|
|
Loading…
Reference in a new issue