Page MenuHomePhabricator

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

Description

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

  • Create a PatchDemo wiki and check the "Proxy articles from wikipedia.org" 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 'https://en.wikipedia.org/wikis/8c8ae6a9ba/w/rest.php/v1/search/title?q=m&limit=10' from origin 'https://patchdemo.wmflabs.org' 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.
GET https://en.wikipedia.org/wikis/8c8ae6a9ba/w/rest.php/v1/search/title?q=m&limit=10 net::ERR_FAILED 200

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 https://en.wikipedia.org/wikis/8c8ae6a9ba/w/rest.php/v1/search/title?q=m&limit=10 , but this should be https://en.wikipedia.org/w/rest.php/v1/search/title?q=m&limit=10 , 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

https://gerrit.wikimedia.org/r/838943

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:
https://patchdemo.wmflabs.org/wikis/81097ba4d2/w

Per Jon's feedback on Gerrit I've removed the backwards compatibility code from the patch, and uploaded a PR for PatchDemo here: https://github.com/MatmaRex/patchdemo/pull/503

Jdlrobson claimed this task.

All merged our side.

Change 838943 merged by jenkins-bot:

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

https://gerrit.wikimedia.org/r/838943