*/
use MediaWiki\Linker\LinkTarget;
-use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use MediaWiki\Session\SessionManager;
use Wikimedia\Rdbms\IResultWrapper;
/** @var array */
protected $mModules = [];
- /** @var array */
- protected $mModuleScripts = [];
-
/** @var array */
protected $mModuleStyles = [];
}
/**
- * Get the list of script-only modules to load on this page.
- *
- * @param bool $filter
- * @param string|null $position Unused
- * @return array Array of module names
- */
- public function getModuleScripts( $filter = false, $position = null ) {
- return $this->getModules( $filter, null, 'mModuleScripts',
- ResourceLoaderModule::TYPE_SCRIPTS
- );
- }
-
- /**
- * Load the scripts of one or more ResourceLoader modules, on this page.
- *
- * This method exists purely to provide the legacy behaviour of loading
- * a module's scripts in the global scope, and without dependency resolution.
- * See <https://phabricator.wikimedia.org/T188689>.
- *
- * @deprecated since 1.31 Use addModules() instead.
- * @param string|array $modules Module name (string) or array of module names
+ * @deprecated since 1.33 Use getModules() instead.
+ * @return array
*/
- public function addModuleScripts( $modules ) {
- $this->mModuleScripts = array_merge( $this->mModuleScripts, (array)$modules );
+ public function getModuleScripts() {
+ wfDeprecated( __METHOD__, '1.33' );
+ return [];
}
/**
* good tags like \<i\> will be dropped entirely.
*
* @param string|Message $name
+ * @param-taint $name tainted
+ * Phan-taint-check gets very confused by $name being either a string or a Message
*/
public function setPageTitle( $name ) {
if ( $name instanceof Message ) {
# change "<i>foo&bar</i>" to "foo&bar"
$this->setHTMLTitle(
- $this->msg( 'pagetitle' )->rawParams( Sanitizer::stripAllTags( $nameWithTags ) )
+ $this->msg( 'pagetitle' )->plaintextParams( Sanitizer::stripAllTags( $nameWithTags ) )
->inContentLanguage()
);
}
}
}
+ /**
+ * Return effective list of advertised feed types
+ * @see addFeedLink()
+ *
+ * @return array Array of feed type names ( 'rss', 'atom' )
+ */
+ protected function getAdvertisedFeedTypes() {
+ if ( $this->getConfig()->get( 'Feed' ) ) {
+ return $this->getConfig()->get( 'AdvertisedFeedTypes' );
+ } else {
+ return [];
+ }
+ }
+
/**
* Add default feeds to the page header
* This is mainly kept for backward compatibility, see OutputPage::addFeedLink()
public function setFeedAppendQuery( $val ) {
$this->mFeedLinks = [];
- foreach ( $this->getConfig()->get( 'AdvertisedFeedTypes' ) as $type ) {
+ foreach ( $this->getAdvertisedFeedTypes() as $type ) {
$query = "feed=$type";
if ( is_string( $val ) ) {
$query .= '&' . $val;
* @param string $href URL
*/
public function addFeedLink( $format, $href ) {
- if ( in_array( $format, $this->getConfig()->get( 'AdvertisedFeedTypes' ) ) ) {
+ if ( in_array( $format, $this->getAdvertisedFeedTypes() ) ) {
$this->mFeedLinks[$format] = $href;
}
}
}
if ( !$this->mParserOptions ) {
- if ( !$this->getContext()->getUser()->isSafeToLoad() ) {
+ if ( !$this->getUser()->isSafeToLoad() ) {
// $wgUser isn't unstubbable yet, so don't try to get a
// ParserOptions for it. And don't cache this ParserOptions
// either.
$this->mNoGallery = $parserOutput->getNoGallery();
$this->mHeadItems = array_merge( $this->mHeadItems, $parserOutput->getHeadItems() );
$this->addModules( $parserOutput->getModules() );
- $this->addModuleScripts( $parserOutput->getModuleScripts() );
$this->addModuleStyles( $parserOutput->getModuleStyles() );
$this->addJsConfigVars( $parserOutput->getJsConfigVars() );
$this->mPreventClickjacking = $this->mPreventClickjacking
$this->addParserOutputText( $parserOutput, $poOptions );
$this->addModules( $parserOutput->getModules() );
- $this->addModuleScripts( $parserOutput->getModuleScripts() );
$this->addModuleStyles( $parserOutput->getModuleStyles() );
$this->addJsConfigVars( $parserOutput->getJsConfigVars() );
return false;
}
+ /**
+ * Get the Origin-Trial header values. This is used to enable Chrome Origin
+ * Trials: https://github.com/GoogleChrome/OriginTrials
+ *
+ * @return array
+ */
+ private function getOriginTrials() {
+ $config = $this->getConfig();
+
+ return $config->get( 'OriginTrials' );
+ }
+
/**
* Send cache control HTTP headers
*/
$response->header( "X-Frame-Options: $frameOptions" );
}
+ $originTrials = $this->getOriginTrials();
+ foreach ( $originTrials as $originTrial ) {
+ $response->header( "Origin-Trial: $originTrial", false );
+ }
+
ContentSecurityPolicy::sendHeaders( $this );
if ( $this->mArticleBodyOnly ) {
$query['returntoquery'] = wfArrayToCgi( $returntoquery );
}
}
+ $title = SpecialPage::getTitleFor( 'Userlogin' );
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+ $loginUrl = $title->getLinkURL( $query, false, PROTO_RELATIVE );
$loginLink = $linkRenderer->makeKnownLink(
- SpecialPage::getTitleFor( 'Userlogin' ),
+ $title,
$this->msg( 'loginreqlink' )->text(),
[],
$query
);
$this->prepareErrorPage( $this->msg( 'loginreqtitle' ) );
- $this->addHTML( $this->msg( $msg )->rawParams( $loginLink )->parse() );
+ $this->addHTML( $this->msg( $msg )->rawParams( $loginLink )->params( $loginUrl )->parse() );
# Don't return to a page the user can't read otherwise
# we'll end up in a pointless loop
$rlClient->setConfig( $this->getJSVars() );
$rlClient->setModules( $this->getModules( /*filter*/ true ) );
$rlClient->setModuleStyles( $moduleStyles );
- $rlClient->setModuleScripts( $this->getModuleScripts( /*filter*/ true ) );
$rlClient->setExemptStates( $exemptStates );
$this->rlClient = $rlClient;
}
*/
public function getResourceLoader() {
if ( is_null( $this->mResourceLoader ) ) {
- $this->mResourceLoader = new ResourceLoader(
- $this->getConfig(),
- LoggerFactory::getInstance( 'resourceloader' )
- );
+ // Lazy-initialise as needed
+ $this->mResourceLoader = MediaWikiServices::getInstance()->getResourceLoader();
}
return $this->mResourceLoader;
}
# or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
# If so, use it instead.
$sitename = $config->get( 'Sitename' );
- if ( $config->get( 'OverrideSiteFeed' ) ) {
- foreach ( $config->get( 'OverrideSiteFeed' ) as $type => $feedUrl ) {
+ $overrideSiteFeed = $config->get( 'OverrideSiteFeed' );
+ if ( $overrideSiteFeed ) {
+ foreach ( $overrideSiteFeed as $type => $feedUrl ) {
// Note, this->feedLink escapes the url.
$feedLinks[] = $this->feedLink(
$type,
}
} elseif ( !$this->getTitle()->isSpecial( 'Recentchanges' ) ) {
$rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
- foreach ( $config->get( 'AdvertisedFeedTypes' ) as $format ) {
+ foreach ( $this->getAdvertisedFeedTypes() as $format ) {
$feedLinks[] = $this->feedLink(
$format,
$rctitle->getLocalURL( [ 'feed' => $format ] ),
*
* For example:
*
- * $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>", 'some-error' );
+ * $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>", 'some-error' );
*
* Is equivalent to:
*
- * $wgOut->addWikiTextAsInterface( "<div class='error'>\n"
- * . wfMessage( 'some-error' )->plain() . "\n</div>" );
+ * $wgOut->addWikiTextAsInterface( "<div class='error'>\n"
+ * . wfMessage( 'some-error' )->plain() . "\n</div>" );
*
* The newline after the opening div is needed in some wikitext. See T21226.
*