&& $this->mOptions->getAllowSpecialInclusion()
&& $this->ot['html']
) {
+ $specialPage = SpecialPageFactory::getPage( $title->getDBkey() );
// Pass the template arguments as URL parameters.
// "uselang" will have no effect since the Language object
// is forced to the one defined in ParserOptions.
$context = new RequestContext;
$context->setTitle( $title );
$context->setRequest( new FauxRequest( $pageArgs ) );
- $context->setUser( $this->getUser() );
+ if ( $specialPage && $specialPage->maxIncludeCacheTime() === 0 ) {
+ $context->setUser( $this->getUser() );
+ } else {
+ // If this page is cached, then we better not be per user.
+ $context->setUser( User::newFromName( '127.0.0.1', false ) );
+ }
$context->setLanguage( $this->mOptions->getUserLangObj() );
$ret = SpecialPageFactory::capturePath( $title, $context );
if ( $ret ) {
$this->mOutput->addOutputPageMetadata( $context->getOutput() );
$found = true;
$isHTML = true;
- // Severely reduce cache time to keep content dynamic
- $this->mOutput->updateCacheExpiry( 30 );
+ if ( $specialPage && $specialPage->maxIncludeCacheTime() !== false ) {
+ $this->mOutput->updateCacheExpiry( $specialPage->maxIncludeCacheTime() );
+ }
}
} elseif ( MWNamespace::isNonincludable( $title->getNamespace() ) ) {
$found = false; # access denied
return $this->mIncludable;
}
+ /**
+ * How long to cache page when it is being included.
+ *
+ * @note If cache time is not 0, then the current user becomes an anon
+ * if you want to do any per-user customizations, than this method
+ * must be overriden to return 0.
+ * @since 1.26
+ * @return int Time in seconds, 0 to disable caching altogether,
+ * false to use the parent page's cache settings
+ */
+ public function maxIncludeCacheTime() {
+ global $wgMiserMode;
+ if ( !$wgMiserMode ) {
+ return 0;
+ } else {
+ return 60*60;
+ }
+ }
+
/**
* Whether the special page is being evaluated via transclusion
* @param bool $x
protected function getGroupName() {
return 'changes';
}
+
+ /**
+ * How long to cache page when it is being included.
+ *
+ * @return int Time in seconds, 0 to disable caching altogether
+ */
+ public function maxIncludeCacheTime() {
+ global $wgMiserMode;
+ if ( !$wgMiserMode ) {
+ return 0;
+ } else {
+ return 60*5;
+ }
+ }
}
public function isIncludable() {
return true;
}
+
+ /**
+ * How long to cache page when it is being included.
+ *
+ * @return int|bool Time in seconds, 0 to disable caching altogether
+ */
+ public function maxIncludeCacheTime() {
+ global $wgMiserMode;
+ if ( !$wgMiserMode ) {
+ return 0;
+ } else {
+ return 60*5;
+ }
+ }
+
}