https://bugzilla.wikimedia.org/show_bug.cgi?id=57647
--- Comment #3 from [email protected] --- (In reply to comment #2) > Sorry, but that's probably going to be too hacky to be accepted. ($wgTitle is > not allowed to be used in new code). Ok, of course. (For me it was a hack to get things working, so I didn't care). > I'm not entirely sure why we're outputting the WebRequest::getRequestUrl as > the > canonical url. Maybe it might make sense to change the > OutputPage::getHeadLinksArray method to use $this->getTitle()->getLocalURL(); > instead of $this->getRequest()->getRequestURL(). (I haven't looked at the > code > very much at all, but intuitively, the canonical link shouldn't have extra > junk > from the url anyway) Seems like a good idea. I did a few changes which seem to work fine, but my MediaWiki installation is broken so I can't properly test right now. I also changed something else (DRY), so it looks better to me. I don't really like the variable re-use that's going on there. First, $canonicalUrl is used as a relative URL and later it's re-used as an absolute URL. diff --git a/includes/OutputPage.php b/includes/OutputPage.php index f1c7d5b..4238776 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -3297,12 +3297,10 @@ $templates # Canonical URL global $wgEnableCanonicalServerLink; if ( $wgEnableCanonicalServerLink ) { - if ( $canonicalUrl !== false ) { - $canonicalUrl = wfExpandUrl( $canonicalUrl, PROTO_CANONICAL ); - } else { - $reqUrl = $this->getRequest()->getRequestURL(); - $canonicalUrl = wfExpandUrl( $reqUrl, PROTO_CANONICAL ); + if ( $canonicalUrl === false ) { + $canonicalUrl = $this->getTitle()->getLocalURL(); } + $canonicalUrl = wfExpandUrl( $canonicalUrl, PROTO_CANONICAL ); } if ( $canonicalUrl !== false ) { $tags[] = Html::element( 'link', array( Note, though, that Google recommends the canonical link to be absolute (this is the case with this change): https://support.google.com/webmasters/answer/139394?hl=en I think that might also be better when a wiki can be reached from multiple domain names or both HTTP and HTTPS. Thanks for the git/gerrit information :) If I have the time I will properly test and submit a patch. -- You are receiving this mail because: You are the assignee for the bug. You are on the CC list for the bug. _______________________________________________ Wikibugs-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
