Skin: Skip LinkRenderer in footerLink and remove $wgFooterLinkCacheExpiry
Test plan:
* Enable $wgDebugToolbar.
* Load Main_Page and refresh once more.
* Apply this page and open another new tab to Main_page
Before:
> 16 queries, including:
> Skin::preloadExistence: `SELECT ..,page_is_redirect,..,page_len FROM
> page WHERE (page_namespace = 2 AND page_title = 'Admin')
> OR (page_namespace = 3 AND page_title = 'Admin')
> OR (page_namespace = 1 AND page_title = 'Main_Page')
> OR (page_namespace = 4 AND page_title IN
> ('Privacy_policy','About','General_disclaimer')
> )`
After:
> 16 queries, including:
> Skin::preloadExistence: `SELECT ..,page_is_redirect,..,page_len FROM
> page WHERE (page_namespace = 2 AND page_title = 'Admin'
> OR (page_namespace = 3 AND page_title = 'Admin')
> OR (page_namespace = 1 AND page_title = 'Main_Page')`
The only other observable difference is that there is no longer a
title attribute on these links holding the destination page name.
This matches the other footer links such as
"By using this site, you agree to the Terms of Use and Privacy Policy."
and "Mobile view", "Developers", "Statistics" and "Cookie statement"
which also don't. If desired, this could be easily added though
by setting 'title' to the title page msg text value, the same used to
create the title object.
Bug: T313462
Change-Id: I581c49839ab4afe2542ee7d00393f11eff9879c6
This commit is contained in:
parent
6d840fa896
commit
1fa903a211
1 changed files with 10 additions and 44 deletions
|
|
@ -450,18 +450,6 @@ abstract class Skin extends ContextSource {
|
|||
}
|
||||
}
|
||||
|
||||
// Footer links (used by SkinTemplate::prepareQuickTemplate)
|
||||
if ( $this->getConfig()->get( MainConfigNames::FooterLinkCacheExpiry ) <= 0 ) {
|
||||
$titles = array_merge(
|
||||
$titles,
|
||||
array_filter( [
|
||||
$this->footerLinkTitle( 'privacy', 'privacypage' ),
|
||||
$this->footerLinkTitle( 'aboutsite', 'aboutpage' ),
|
||||
$this->footerLinkTitle( 'disclaimers', 'disclaimerpage' ),
|
||||
] )
|
||||
);
|
||||
}
|
||||
|
||||
$this->getHookRunner()->onSkinPreloadExistence( $titles, $this );
|
||||
|
||||
if ( $titles ) {
|
||||
|
|
@ -1026,14 +1014,15 @@ abstract class Skin extends ContextSource {
|
|||
*/
|
||||
public function footerLink( $desc, $page ) {
|
||||
$title = $this->footerLinkTitle( $desc, $page );
|
||||
|
||||
if ( !$title ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
|
||||
return $linkRenderer->makeKnownLink(
|
||||
$title,
|
||||
// Similar to Skin::addToSidebarPlain
|
||||
// Optimization: Avoid LinkRenderer here as it requires extra DB info
|
||||
// to add unneeded classes even for makeKnownLink (T313462).
|
||||
return Html::element( 'a',
|
||||
[ 'href' => $title->fixSpecialName()->getLinkURL() ],
|
||||
$this->msg( $desc )->text()
|
||||
);
|
||||
}
|
||||
|
|
@ -1062,34 +1051,11 @@ abstract class Skin extends ContextSource {
|
|||
* @return string[] Map of (key => HTML) for 'privacy', 'about', 'disclaimer'
|
||||
*/
|
||||
public function getSiteFooterLinks() {
|
||||
$callback = function () {
|
||||
return [
|
||||
'privacy' => $this->footerLink( 'privacy', 'privacypage' ),
|
||||
'about' => $this->footerLink( 'aboutsite', 'aboutpage' ),
|
||||
'disclaimer' => $this->footerLink( 'disclaimers', 'disclaimerpage' )
|
||||
];
|
||||
};
|
||||
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$msgCache = $services->getMessageCache();
|
||||
$wanCache = $services->getMainWANObjectCache();
|
||||
$config = $this->getConfig();
|
||||
|
||||
return ( $config->get( MainConfigNames::FooterLinkCacheExpiry ) > 0 )
|
||||
? $wanCache->getWithSetCallback(
|
||||
$wanCache->makeKey( 'footer-links' ),
|
||||
$config->get( MainConfigNames::FooterLinkCacheExpiry ),
|
||||
$callback,
|
||||
[
|
||||
'checkKeys' => [
|
||||
// Unless there is both no exact $code override nor an i18n definition
|
||||
// in the software, the only MediaWiki page to check is for $code.
|
||||
$msgCache->getCheckKey( $this->getLanguage()->getCode() )
|
||||
],
|
||||
'lockTSE' => 30
|
||||
]
|
||||
)
|
||||
: $callback();
|
||||
return [
|
||||
'privacy' => $this->footerLink( 'privacy', 'privacypage' ),
|
||||
'about' => $this->footerLink( 'aboutsite', 'aboutpage' ),
|
||||
'disclaimer' => $this->footerLink( 'disclaimers', 'disclaimerpage' )
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue