Page MenuHomePhabricator

TitleKey blocks opensearch from suggesting titles in namespaces outside of NS_MAIN and NS_SPECIAL
Open, Needs TriagePublic

Description

Using:

  • MediaWiki 1.34.0
  • TitleKey 1.0 (6e13b04) 13:36, 19 August 2019 -- the version for MW 1.34
  • The default MediaWiki search engine (not CirrusSearch)

When I use the MediaWiki search box to suggest articles in the Main or Special namespaces, everything works fine, but if I type (for example) any of these strings into the search box:

File:A
Template:A

the search box shows no suggestions. If I remove TitleKey from LocalSettings and restart memcached, the problem goes away and I see search suggestions in all namespaces.

Here is the HTTP data with and without TitleKey. I don't see a significant difference.

Without TitleKey:

Request headers:

GET /w/api.php?action=opensearch&format=json&formatversion=2&search=file%3Aa&namespace=0&limit=10&suggest=true HTTP/1.1
Host: dev.example.com
Connection: keep-alive
Accept: application/json, text/javascript, */*; q=0.01
DNT: 1
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36
Referer: http://dev.example.com/notes/Reviews_of_7%C2%BD_Lessons_About_the_Brain
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: wikiEditor-0-toolbar-section=advanced; example_wp_UserName=Me; example_wp_UserID=1; example_wp_Token=99f70baee7ff84e9561c07ba1dae4a87; VEE=wikitext; mf_testcookie=test_value; stopMobileRedirect=true; example_wp__session=e71t40p2tga8bt4oqudqiga04lfpaiog

Response headers:

HTTP/1.1 200 OK
Date: Sat, 29 Feb 2020 12:59:03 GMT
Server: Apache/2.4.29 (Ubuntu)
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Content-Disposition: inline; filename=api-result.json
Vary: Accept-Encoding,Treat-as-Untrusted,Cookie
Cache-Control: private, must-revalidate, max-age=1200
Content-Length: 107
Keep-Alive: timeout=5, max=95
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8

Response:

["file:a",["File:Amazon-logo.png"],[""],["http://dev.example.com/notes/File:Amazon-logo.png"]]

With TitleKey:

Request headers:

GET /w/api.php?action=opensearch&format=json&formatversion=2&search=file%3Aa&namespace=0&limit=10&suggest=true HTTP/1.1
Host: dev.example.com
Connection: keep-alive
Accept: application/json, text/javascript, */*; q=0.01
DNT: 1
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36
Referer: http://dev.example.com/notes/Home
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: wikiEditor-0-toolbar-section=advanced; example_wp_UserName=Me; example_wp_UserID=1; example_wp_Token=99f70baee7ff84e9561c07ba1dae4a87; VEE=wikitext; mf_testcookie=test_value; stopMobileRedirect=true; example_wp__session=gspokg5gmgjo2a28th7un6a2s7jd3goc

Response headers:

HTTP/1.1 200 OK
Date: Sat, 29 Feb 2020 13:02:32 GMT
Server: Apache/2.4.29 (Ubuntu)
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Content-Disposition: inline; filename=api-result.json
Vary: Accept-Encoding,Treat-as-Untrusted,Cookie
Cache-Control: private, must-revalidate, max-age=1200
Content-Length: 19
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive

Response:

["file:a",[],[],[]]

Other info:

  • Disabling memcached and switching to CACHE_NONE throughout does not help.
  • Adding $wgNamespacesToBeSearchedDefault[NS_FILE] = true to LocalSettings does not help