Do not use User session in the constructor

This is going to be forbidden going forward.
The legacy lookup and overrides are deferred
until they are actually needed to keep the constructor
cheap

Bug: T289163
Change-Id: Ib23360e3439abc828404c1de8e0906915ee7d8b6
This commit is contained in:
jdlrobson 2021-09-20 19:12:48 -07:00 committed by Jdlrobson
parent 2bcfac0f07
commit d4befe8c39
1 changed files with 30 additions and 22 deletions

View File

@ -92,28 +92,6 @@ class SkinVector extends SkinMustache {
return !$isLatestSkinFeatureEnabled;
}
/**
* Overrides template, styles and scripts module when skin operates
* in legacy mode.
*
* @inheritDoc
* @param array|null $options Note; this param is only optional for internal purpose.
* Do not instantiate Vector, use SkinFactory to create the object instead.
* If you absolutely must to, this paramater is required; you have to provide the
* skinname with the `name` key. That's do it with `new SkinVector( ['name' => 'vector'] )`.
* Failure to do that, will lead to fatal exception.
*/
public function __construct( $options = [] ) {
if ( $this->isLegacy() ) {
$options['scripts'] = [ 'skins.vector.legacy.js' ];
$options['styles'] = [ 'skins.vector.styles.legacy' ];
$options['template'] = 'skin-legacy';
unset( $options['link'] );
}
parent::__construct( $options );
}
/**
* Calls getLanguages with caching.
* @return array
@ -318,6 +296,36 @@ class SkinVector extends SkinMustache {
Hooks::onSkinTemplateNavigation( $skin, $content_navigation );
}
/**
* Updates modules for use in legacy Vector skin.
* Do not repeat this pattern. Will be addressed in T291098.
* @inheritDoc
*/
public function getDefaultModules() {
// FIXME: Do not repeat this pattern. Will be addressed in T291098.
if ( $this->isLegacy() ) {
$this->options['scripts'] = [ 'skins.vector.legacy.js' ];
$this->options['styles'] = [ 'skins.vector.styles.legacy' ];
}
return parent::getDefaultModules();
}
/**
* Updates HTML generation for use in legacy Vector skin.
* Do not repeat this pattern. Will be addressed in T291098.
*
* @inheritDoc
*/
public function generateHTML() {
if ( $this->isLegacy() ) {
$this->options['template'] = 'skin-legacy';
// Does not apply to gadgets adding menu items via addPortletLink. Should be
// removed when Ib23360e3439abc828404c1de8e0906915ee7d8b6 is merged.
unset( $this->options['link'] );
}
return parent::generateHTML();
}
/**
* Generate data needed to generate the sticky header.
* Lack of i18n is intentional and will be done as part of follow up work.