Page MenuHomePhabricator

Pointing Vector 2022 search to another wiki ($wgVectorSearchHost) doesn't work on PatchDemo wikis
Closed, ResolvedPublicBUG REPORT


Steps to replicate the issue (include links if applicable):

  • Create a PatchDemo wiki and check the "Proxy articles from" checkbox (or use the wiki I created with this setting)
  • On this wiki, switch the skin to Vector-2022
  • Type something in the search bar

Credit to @EUdoh-WMF for finding this bug originally.

What happens?: No results appear. The following error message appears in the console:

Access to fetch at '' from origin '' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

What should have happened instead?: Results from Wikipedia (as opposed to from the local wiki) should appear

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):
The CORS error is misleading. What's really going wrong here is that the request URL is , but this should be , without the /wikis/8c8ae6a9ba part.

This happens because the way $wgVectorSearchHost is used in restSearchClient.js assumes that the local wiki's wgScriptPath is the same as the target wiki's. But that's not the case when connecting a PatchDemo wiki to a production wiki. I suggest changing the $wgVectorSearchHost setting to take a full URL to rest.php, rather than just a domain name, and renaming it accordingly.

Event Timeline

Change 838943 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/skins/Vector@master] Deprecate $wgVectorSearchHost, replace with $wgVectorSearchApiUrl

Eventually yes, although with the b/c code for $wgVectorSearchHost PatchDemo will start working correctly as soon as this patch is merged (because my patch assumes a hard-coded script path of /w for foreign wikis, rather than reusing the current wiki's script path setting). After this patch is merged I'll upload a PR to PatchDemo to switch it over from $wgVectorSearchHost to $wgVectorSearchApiUrl.

Test wiki created on Patch demo by Roan Kattouw (WMF) using patch(es) linked to this task:

Per Jon's feedback on Gerrit I've removed the backwards compatibility code from the patch, and uploaded a PR for PatchDemo here:

Jdlrobson claimed this task.

All merged our side.

Change 838943 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Remove $wgVectorSearchHost, replace with $wgVectorSearchApiUrl