X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FOutputPage.php;h=acf2d2553256aa87f94a975ed16587156bc20b3a;hb=29c25bb31c4b558a245f1b0c80a934b8b949ca55;hp=15a759b11917bb9e1c9f2cbe2bea9a68d33167de;hpb=9bbb26ffbd16edbaccce27461730fa9e172aa048;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 15a759b119..acf2d25532 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -50,7 +50,7 @@ class OutputPage extends ContextSource { /** @var array */ protected $mLinktags = []; - /** @var bool */ + /** @var string|bool */ protected $mCanonicalUrl = false; /** @@ -332,7 +332,7 @@ class OutputPage extends ContextSource { * a OutputPage tied to that context. * @param IContextSource $context */ - function __construct( IContextSource $context ) { + public function __construct( IContextSource $context ) { $this->setContext( $context ); } @@ -385,8 +385,8 @@ class OutputPage extends ContextSource { * @param string $name Name of the meta tag * @param string $val Value of the meta tag */ - function addMeta( $name, $val ) { - array_push( $this->mMetatags, [ $name, $val ] ); + public function addMeta( $name, $val ) { + $this->mMetatags[] = [ $name, $val ]; } /** @@ -406,8 +406,8 @@ class OutputPage extends ContextSource { * * @param array $linkarr Associative array of attributes. */ - function addLink( array $linkarr ) { - array_push( $this->mLinktags, $linkarr ); + public function addLink( array $linkarr ) { + $this->mLinktags[] = $linkarr; } /** @@ -425,7 +425,7 @@ class OutputPage extends ContextSource { * in preference to addLink(), to avoid duplicate link tags. * @param string $url */ - function setCanonicalUrl( $url ) { + public function setCanonicalUrl( $url ) { $this->mCanonicalUrl = $url; } @@ -447,7 +447,7 @@ class OutputPage extends ContextSource { * * @param string $script Raw HTML */ - function addScript( $script ) { + public function addScript( $script ) { $this->mScripts .= $script; } @@ -621,7 +621,7 @@ class OutputPage extends ContextSource { * * @return array */ - function getHeadItemsArray() { + public function getHeadItemsArray() { return $this->mHeadItems; } @@ -1598,6 +1598,7 @@ class OutputPage extends ContextSource { * @param ParserOptions|null $options Either the ParserOption to use or null to only get the * current ParserOption object. This parameter is deprecated since 1.31. * @return ParserOptions + * @suppress PhanUndeclaredProperty For isBogus */ public function parserOptions( $options = null ) { if ( $options !== null ) { @@ -1954,7 +1955,7 @@ class OutputPage extends ContextSource { * @param ParserOutput $parserOutput * @param array $poOptions Options to ParserOutput::getText() */ - function addParserOutput( ParserOutput $parserOutput, $poOptions = [] ) { + public function addParserOutput( ParserOutput $parserOutput, $poOptions = [] ) { $this->addParserOutputMetadata( $parserOutput ); $this->addParserOutputText( $parserOutput, $poOptions ); } @@ -2146,7 +2147,7 @@ class OutputPage extends ContextSource { } /** - * Get TTL in [$minTTL,$maxTTL] in pass it to lowerCdnMaxage() + * Get TTL in [$minTTL,$maxTTL] and pass it to lowerCdnMaxage() * * This sets and returns $minTTL if $mtime is false or null. Otherwise, * the TTL is higher the older the $mtime timestamp is. Essentially, the @@ -2162,10 +2163,10 @@ class OutputPage extends ContextSource { $maxTTL = $maxTTL ?: $this->getConfig()->get( 'CdnMaxAge' ); if ( $mtime === null || $mtime === false ) { - return $minTTL; // entity does not exist + return; // entity does not exist } - $age = MWTimestamp::time() - wfTimestamp( TS_UNIX, $mtime ); + $age = MWTimestamp::time() - (int)wfTimestamp( TS_UNIX, $mtime ); $adaptiveTTL = max( 0.9 * $age, $minTTL ); $adaptiveTTL = min( $adaptiveTTL, $maxTTL ); @@ -2188,7 +2189,7 @@ class OutputPage extends ContextSource { * * @return array */ - function getCacheVaryCookies() { + public function getCacheVaryCookies() { if ( self::$cacheVaryCookies === null ) { $config = $this->getConfig(); self::$cacheVaryCookies = array_values( array_unique( array_merge( @@ -2209,7 +2210,7 @@ class OutputPage extends ContextSource { * * @return bool */ - function haveCacheVaryCookies() { + public function haveCacheVaryCookies() { $request = $this->getRequest(); foreach ( $this->getCacheVaryCookies() as $cookieName ) { if ( $request->getCookie( $cookieName, '', '' ) !== '' ) { @@ -2269,7 +2270,7 @@ class OutputPage extends ContextSource { /** * Return a Link: header. Based on the values of $mLinkHeader. * - * @return string + * @return string|false */ public function getLinkHeader() { if ( !$this->mLinkHeader ) { @@ -2414,32 +2415,16 @@ class OutputPage extends ContextSource { $this->mCdnMaxage != 0 && !$this->haveCacheVaryCookies() ) { - if ( $config->get( 'UseESI' ) ) { - wfDeprecated( '$wgUseESI = true', '1.33' ); - # We'll purge the proxy cache explicitly, but require end user agents - # to revalidate against the proxy on each visit. - # 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( 'CdnMaxAge' )}" . - "+{$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 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} **", '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->mCdnMaxage}, must-revalidate, max-age=0" ); - } + # We'll purge the proxy cache for anons explicitly, but require end user agents + # to revalidate against the proxy on each visit. + # 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} **", '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->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. @@ -2617,7 +2602,7 @@ class OutputPage extends ContextSource { * and optionally an custom HTML title (content of the "" tag). * * @param string|Message $pageTitle Will be passed directly to setPageTitle() - * @param string|Message $htmlTitle Will be passed directly to setHTMLTitle(); + * @param string|Message|false $htmlTitle Will be passed directly to setHTMLTitle(); * optional, if not passed the "<title>" attribute will be * based on $pageTitle */ @@ -2838,7 +2823,7 @@ class OutputPage extends ContextSource { /** * Add a "return to" link pointing to a specified title * - * @param Title $title Title to link + * @param LinkTarget $title Title to link * @param array $query Query string parameters * @param string|null $text Text of the link (input is not escaped) * @param array $options Options array to pass to Linker @@ -3298,7 +3283,7 @@ class OutputPage extends ContextSource { $vars['wgUserId'] = $user->getId(); $vars['wgUserEditCount'] = $user->getEditCount(); $userReg = $user->getRegistration(); - $vars['wgUserRegistration'] = $userReg ? wfTimestamp( TS_UNIX, $userReg ) * 1000 : null; + $vars['wgUserRegistration'] = $userReg ? (int)wfTimestamp( TS_UNIX, $userReg ) * 1000 : null; // Get the revision ID of the oldest new message on the user's talk // page. This can be used for constructing new message alerts on // the client side.