List of steps to reproduce (step by step, including full links if applicable):
- LocalSettings.php
$wgScriptPath = ""; $wgArticlePath = "/wiki/$1"; $wgActionPaths['view'] = $wgArticlePath;
- visit main page (any page would work actually)
What happens?:
URL generated are not prettified, ex:
- Login: index.php?title=Special:UserLogin&returnto=MediaWiki
- Permanent link: index.php?title=MediaWiki&oldid=3878227
- Cite this page: index.php?title=Special:CiteThisPage&page=MediaWiki&id=3878227&wpFormIdentifier=titleform
What should have happened instead?:
URLs should be prettified ex:
- Login: /Special:UserLogin?returnto=MediaWiki
- Permanent link: /MediaWiki?oldid=3878227
- Cite this page: /Special:CiteThisPage?page=MediaWiki&id=3878227&wpFormIdentifier=titleform
Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:
MediaWiki 1.37.2 but the code seems to be the same on latest master
https://github.com/wikimedia/mediawiki/blob/master/includes/Title.php#L2277
From
https://phabricator.wikimedia.org/rMW7bbce3f6feded604919290c3825398b18ede9351#change-TW14alGcSnux
Suggested fix:
The issue is due to these urls doesn't have action=view (most view actions aren't included in the generated URL?)
We have tested the following change on our wiki instance with success.
However, a proper fix may be to update the regex to recognize that action may not always be provided when its view action?
diff --git a/includes/Title.php b/includes/Title.php index 33f9d390c2..936d3abddb 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2342,7 +2342,14 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject { if ( $query == '-' ) { $query = ''; } - $url = "{$wgScript}?title={$dbkey}&{$query}"; + if ( isset( $articlePaths['view'] ) ) { + $url = str_replace( '$1', $dbkey, $articlePaths['view'] ); + if ( $query != '' ) { + $url = wfAppendQuery( $url, $query ); + } + } else { + $url = "{$wgScript}?title={$dbkey}&{$query}"; + } } } Hooks::runner()->onGetLocalURL__Internal( $this, $url, $query );