/**
* @var array Additional stylesheets. Looks like this is for extensions.
- * Might be replaced by resource loader.
+ * Might be replaced by ResourceLoader.
*/
protected $mExtStyles = array();
private $mLanguageLinks = array();
/**
- * Used for JavaScript (pre resource loader)
+ * Used for JavaScript (predates ResourceLoader)
* @todo We should split JS / CSS.
* mScripts content is inserted as is in "<head>" by Skin. This might
* contain either a link to a stylesheet or inline CSS.
/** @var array Array of elements in "<head>". Parser might add its own headers! */
protected $mHeadItems = array();
- // @todo FIXME: Next 5 variables probably come from the resource loader
-
/** @var array */
protected $mModules = array();
/**
* @var bool Comes from the parser. This was probably made to load CSS/JS
* only if we had "<gallery>". Used directly in CategoryPage.php.
- * Looks like resource loader can replace this.
+ * Looks like ResourceLoader can replace this.
*/
public $mNoGallery = false;
/** @var string */
private $mPageTitleActionText = '';
- /** @var array */
- private $mParseWarnings = array();
-
/** @var int Cache stuff. Looks like mEnableClientCache */
- protected $mSquidMaxage = 0;
- /** @var int Upper limit on mSquidMaxage */
+ protected $mCdnMaxage = 0;
+ /** @var int Upper limit on mCdnMaxage */
protected $mCdnMaxageLimit = INF;
/**
/**
* Add raw HTML to the list of scripts (including \<script\> tag, etc.)
+ * Internal use only. Use OutputPage::addModules() or OutputPage::addJsConfigVars()
+ * if possible.
*
* @param string $script Raw HTML
*/
/**
* Register and add a stylesheet from an extension directory.
*
+ * @deprecated since 1.27 use addModuleStyles() or addStyle() instead
* @param string $url Path to sheet. Provide either a full url (beginning
* with 'http', etc) or a relative path from the document root
* (beginning with '/'). Otherwise it behaves identically to
* addStyle() and draws from the /skins folder.
*/
public function addExtensionStyle( $url ) {
+ wfDeprecated( __METHOD__, '1.27' );
array_push( $this->mExtStyles, $url );
}
/**
* Get all styles added by extensions
*
+ * @deprecated since 1.27
* @return array
*/
function getExtStyle() {
+ wfDeprecated( __METHOD__, '1.27' );
return $this->mExtStyles;
}
/**
* Add a JavaScript file out of skins/common, or a given relative path.
+ * Internal use only. Use OutputPage::addModules() if possible.
*
* @param string $file Filename in skins/common or complete on-server path
* (/foo/bar.js)
/**
* Add a self-contained script tag with the given contents
+ * Internal use only. Use OutputPage::addModules() if possible.
*
* @param string $script JavaScript text, no "<script>" tags
*/
}
/**
- * Add one or more modules recognized by the resource loader. Modules added
- * through this function will be loaded by the resource loader when the
+ * Add one or more modules recognized by ResourceLoader. Modules added
+ * through this function will be loaded by ResourceLoader when the
* page loads.
*
* @param string|array $modules Module name (string) or array of module names
}
/**
- * Add only JS of one or more modules recognized by the resource loader. Module
- * scripts added through this function will be loaded by the resource loader when
+ * Add only JS of one or more modules recognized by ResourceLoader. Module
+ * scripts added through this function will be loaded by ResourceLoader when
* the page loads.
*
* @param string|array $modules Module name (string) or array of module names
}
/**
- * Add only CSS of one or more modules recognized by the resource loader.
+ * Add only CSS of one or more modules recognized by ResourceLoader.
*
* Module styles added through this function will be added using standard link CSS
* tags, rather than as a combined Javascript and CSS package. Thus, they will
/**
* Add or replace an header item to the output
*
+ * Whenever possible, use more specific options like ResourceLoader modules,
+ * OutputPage::addLink(), OutputPage::addMetaLink() and OutputPage::addFeedLink()
+ * Fallback options for those are: OutputPage::addStyle, OutputPage::addScript(),
+ * OutputPage::addInlineScript() and OutputPage::addInlineStyle()
+ * This would be your very LAST fallback.
+ *
* @param string $name Item name
* @param string $value Raw HTML
*/
$clientHeader = $this->getRequest()->getHeader( 'If-Modified-Since' );
if ( $clientHeader === false ) {
- wfDebug( __METHOD__ . ": client did not send If-Modified-Since header\n", 'log' );
+ wfDebug( __METHOD__ . ": client did not send If-Modified-Since header", 'private' );
return false;
}
}
wfDebug( __METHOD__ . ": client sent If-Modified-Since: " .
- wfTimestamp( TS_ISO_8601, $clientHeaderTime ) . "\n", 'log' );
+ wfTimestamp( TS_ISO_8601, $clientHeaderTime ), 'private' );
wfDebug( __METHOD__ . ": effective Last-Modified: " .
- wfTimestamp( TS_ISO_8601, $maxModified ) . "\n", 'log' );
+ wfTimestamp( TS_ISO_8601, $maxModified ), 'private' );
if ( $clientHeaderTime < $maxModified ) {
- wfDebug( __METHOD__ . ": STALE, $info\n", 'log' );
+ wfDebug( __METHOD__ . ": STALE, $info", 'private' );
return false;
}
# Not modified
# Give a 304 Not Modified response code and disable body output
- wfDebug( __METHOD__ . ": NOT MODIFIED, $info\n", 'log' );
+ wfDebug( __METHOD__ . ": NOT MODIFIED, $info", 'private' );
ini_set( 'zlib.output_compression', 0 );
$this->getRequest()->response()->statusHeader( 304 );
$this->sendCacheControl();
$this->addSubtitle( $str );
}
- /**
- * Add $str to the subtitle
- *
- * @deprecated since 1.19; use addSubtitle() instead
- * @param string|Message $str String or Message to add to the subtitle
- */
- public function appendSubtitle( $str ) {
- $this->addSubtitle( $str );
- }
-
/**
* Add $str to the subtitle
*
array( &$this, $categories, &$this->mCategoryLinks ) )
) {
foreach ( $categories as $category => $type ) {
+ // array keys will cast numeric category names to ints, so cast back to string
+ $category = (string)$category;
$origcategory = $category;
$title = Title::makeTitleSafe( NS_CATEGORY, $category );
if ( !$title ) {
* @param ParserOutput $parserOutput
*/
public function addParserOutputNoText( $parserOutput ) {
+ wfDeprecated( __METHOD__, '1.24' );
$this->addParserOutputMetadata( $parserOutput );
}
$this->mNewSectionLink = $parserOutput->getNewSection();
$this->mHideNewSectionLink = $parserOutput->getHideNewSection();
- $this->mParseWarnings = $parserOutput->getWarnings();
if ( !$parserOutput->isCacheable() ) {
$this->enableClientCache( false );
}
return Parser::stripOuterParagraph( $parsed );
}
+ /**
+ * @param $maxage
+ * @deprecated since 1.27 Use setCdnMaxage() instead
+ */
+ public function setSquidMaxage( $maxage ) {
+ $this->setCdnMaxage( $maxage );
+ }
+
/**
* Set the value of the "s-maxage" part of the "Cache-control" HTTP header
*
- * @param int $maxage Maximum cache time on the Squid, in seconds.
+ * @param int $maxage Maximum cache time on the CDN, in seconds.
*/
- public function setSquidMaxage( $maxage ) {
- $this->mSquidMaxage = min( $maxage, $this->mCdnMaxageLimit );
+ public function setCdnMaxage( $maxage ) {
+ $this->mCdnMaxage = min( $maxage, $this->mCdnMaxageLimit );
}
/**
* Lower the value of the "s-maxage" part of the "Cache-control" HTTP header
*
- * @param int $maxage Maximum cache time on the Squid, in seconds
+ * @param int $maxage Maximum cache time on the CDN, in seconds
* @since 1.27
*/
public function lowerCdnMaxage( $maxage ) {
$this->mCdnMaxageLimit = min( $maxage, $this->mCdnMaxageLimit );
- $this->setSquidMaxage( $this->mSquidMaxage );
+ $this->setCdnMaxage( $this->mCdnMaxage );
}
/**
if ( $this->mEnableClientCache ) {
if (
$config->get( 'UseSquid' ) && session_id() == '' && !$this->isPrintable() &&
- $this->mSquidMaxage != 0 && !$this->haveCacheVaryCookies()
+ $this->mCdnMaxage != 0 && !$this->haveCacheVaryCookies()
) {
if ( $config->get( 'UseESI' ) ) {
# We'll purge the proxy cache explicitly, but require end user agents
# to revalidate against the proxy on each visit.
- # Surrogate-Control controls our Squid, Cache-Control downstream caches
- wfDebug( __METHOD__ . ": proxy caching with ESI; {$this->mLastModified} **\n", 'log' );
+ # Surrogate-Control controls our CDN, Cache-Control downstream caches
+ wfDebug( __METHOD__ . ": proxy caching with ESI; {$this->mLastModified} **", 'private' );
# start with a shorter timeout for initial testing
# header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
$response->header( 'Surrogate-Control: max-age=' . $config->get( 'SquidMaxage' )
- . '+' . $this->mSquidMaxage . ', content="ESI/1.0"' );
+ . '+' . $this->mCdnMaxage . ', content="ESI/1.0"' );
$response->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
} else {
# We'll purge the proxy cache for anons explicitly, but require end user agents
# to revalidate against the proxy on each visit.
- # IMPORTANT! The Squid needs to replace the Cache-Control header with
+ # IMPORTANT! The CDN needs to replace the Cache-Control header with
# Cache-Control: s-maxage=0, must-revalidate, max-age=0
- wfDebug( __METHOD__ . ": local proxy caching; {$this->mLastModified} **\n", 'log' );
+ wfDebug( __METHOD__ . ": local proxy caching; {$this->mLastModified} **", 'private' );
# start with a shorter timeout for initial testing
# header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
- $response->header( 'Cache-Control: s-maxage=' . $this->mSquidMaxage
+ $response->header( 'Cache-Control: s-maxage=' . $this->mCdnMaxage
. ', must-revalidate, max-age=0' );
}
} else {
# We do want clients to cache if they can, but they *must* check for updates
# on revisiting the page.
- wfDebug( __METHOD__ . ": private caching; {$this->mLastModified} **\n", 'log' );
+ wfDebug( __METHOD__ . ": private caching; {$this->mLastModified} **", 'private' );
$response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
$response->header( "Cache-Control: private, must-revalidate, max-age=0" );
}
$response->header( "Last-Modified: {$this->mLastModified}" );
}
} else {
- wfDebug( __METHOD__ . ": no caching **\n", 'log' );
+ wfDebug( __METHOD__ . ": no caching **", 'private' );
# In general, the absence of a last modified header should be enough to prevent
# the client from using its cache. We send a few other things just to make sure.
print $ins;
}
- /**
- * Produce a "user is blocked" page.
- * @deprecated since 1.18
- */
- function blockedPage() {
- throw new UserBlockedError( $this->getUser()->mBlock );
- }
-
/**
* Prepare this object to display an error page; disable caching and
* indexing, clear the current text and redirect, set the page's title
# not especially useful as a returnto parameter. Use the title
# from the request instead, if there was one.
$request = $this->getRequest();
- $returnto = Title::newFromURL( $request->getVal( 'title', '' ) );
+ $returnto = Title::newFromText( $request->getVal( 'title', '' ) );
if ( $action == 'edit' ) {
$msg = 'whitelistedittext';
$displayReturnto = $returnto;
$this->returnToMain();
}
- /**
- * Display an error page noting that a given permission bit is required.
- * @deprecated since 1.18, just throw the exception directly
- * @param string $permission Key required
- * @throws PermissionsError
- */
- public function permissionRequired( $permission ) {
- throw new PermissionsError( $permission );
- }
-
- /**
- * Produce the stock "please login to use the wiki" page
- *
- * @deprecated since 1.19; throw the exception directly
- */
- public function loginToUse() {
- throw new PermissionsError( 'read' );
- }
-
/**
* Format a list of error messages
*
// on-wiki like user pages, or user preferences; we need to find the highest
// timestamp of these user-changeable modules so we can ensure cache misses on change
// This should NOT be done for the site group (bug 27564) because anons get that too
- // and we shouldn't be putting timestamps in Squid-cached HTML
+ // and we shouldn't be putting timestamps in CDN-cached HTML
$version = null;
if ( $group === 'user' ) {
$query['version'] = $resourceLoader->getCombinedVersion( $context, array_keys( $grpModules ) );
*/
public function userCanPreview() {
$request = $this->getRequest();
- if ( $request->getVal( 'action' ) !== 'submit' || !$request->wasPosted() ) {
+ if (
+ $request->getVal( 'action' ) !== 'submit' ||
+ !$request->getCheck( 'wpPreview' ) ||
+ !$request->wasPosted()
+ ) {
return false;
}
# Feeds
if ( $config->get( 'Feed' ) ) {
+ $feedLinks = array();
+
foreach ( $this->getSyndicationLinks() as $format => $link ) {
# Use the page name for the title. In principle, this could
# lead to issues with having the same name for different feeds
# corresponding to the same page, but we can't avoid that at
# this low a level.
- $tags[] = $this->feedLink(
+ $feedLinks[] = $this->feedLink(
$format,
$link,
# Used messages: 'page-rss-feed' and 'page-atom-feed' (for an easier grep)
if ( $config->get( 'OverrideSiteFeed' ) ) {
foreach ( $config->get( 'OverrideSiteFeed' ) as $type => $feedUrl ) {
// Note, this->feedLink escapes the url.
- $tags[] = $this->feedLink(
+ $feedLinks[] = $this->feedLink(
$type,
$feedUrl,
$this->msg( "site-{$type}-feed", $sitename )->text()
} elseif ( !$this->getTitle()->isSpecial( 'Recentchanges' ) ) {
$rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
foreach ( $config->get( 'AdvertisedFeedTypes' ) as $format ) {
- $tags[] = $this->feedLink(
+ $feedLinks[] = $this->feedLink(
$format,
$rctitle->getLocalURL( array( 'feed' => $format ) ),
# For grep: 'site-rss-feed', 'site-atom-feed'
);
}
}
+
+ # Allow extensions to change the list pf feeds. This hook is primarily for changing,
+ # manipulating or removing existing feed tags. If you want to add new feeds, you should
+ # use OutputPage::addFeedLink() instead.
+ Hooks::run( 'AfterBuildFeedLinks', array( &$feedLinks ) );
+
+ $tags += $feedLinks;
}
# Canonical URL
/**
* Add a local or specified stylesheet, with the given media options.
- * Meant primarily for internal use...
+ * Internal use only. Use OutputPage::addModuleStyles() if possible.
*
* @param string $style URL to the file
* @param string $media To specify a media type, 'screen', 'printable', 'handheld' or any.
/**
* Adds inline CSS styles
+ * Internal use only. Use OutputPage::addModuleStyles() if possible.
+ *
* @param mixed $style_css Inline CSS
* @param string $flip Set to 'flip' to flip the CSS if needed
*/
$this->addWikiText( $s );
}
- /**
- * Include jQuery core. Use this to avoid loading it multiple times
- * before we get a usable script loader.
- *
- * @param array $modules List of jQuery modules which should be loaded
- * @return array The list of modules which were not loaded.
- * @since 1.16
- * @deprecated since 1.17
- */
- public function includeJQuery( array $modules = array() ) {
- return array();
- }
-
/**
* Enables/disables TOC, doesn't override __NOTOC__
* @param bool $flag