42 public const PURGE_NAIVE = 0;
48 public const PURGE_PRESEND = 1;
53 public const PURGE_REBOUND = 2;
63 public const PURGE_INTENT_TXROUND_REFLECTED = self::PURGE_PRESEND | self::PURGE_REBOUND;
73 public const PURGE_URLS_LINKSUPDATE_ONLY = 4;
81 public const UNLESS_CACHE_MTIME_AFTER =
'unless-timestamp-exceeds';
93 $this->hookRunner =
new HookRunner( $hookContainer );
105 return ( ( $flags & $flag ) === $flag );
116 public function purgeUrls( $urls, $flags = self::PURGE_PRESEND, array $unless = [] ) {
117 $minFreshCacheMtime = $unless[self::UNLESS_CACHE_MTIME_AFTER] ??
null;
118 if ( $minFreshCacheMtime && time() > ( $minFreshCacheMtime + $this->cdnMaxAge ) ) {
122 $urls = is_string( $urls ) ? [ $urls ] : $urls;
125 ? $this->reboundDelay
129 if ( $this->
fieldHasFlag( $flags, self::PURGE_PRESEND ) ) {
147 public function purgeTitleUrls( $titles, $flags = self::PURGE_PRESEND, array $unless = [] ) {
148 $titles = $titles instanceof
Title ? [ $titles ] : $titles;
150 if ( $this->useFileCache ) {
152 if ( $this->
fieldHasFlag( $flags, self::PURGE_PRESEND ) ) {
159 $minFreshCacheMtime = $unless[self::UNLESS_CACHE_MTIME_AFTER] ??
null;
160 if ( !$minFreshCacheMtime || time() <= ( $minFreshCacheMtime + $this->cdnMaxAge ) ) {
162 foreach ( $titles as
$title ) {
164 $urls = array_merge( $urls, $this->
getUrls( $title, $flags ) );
189 if ( !$this->
fieldHasFlag( $flags, self::PURGE_URLS_LINKSUPDATE_ONLY ) ) {
190 $urls[] =
$title->getInternalURL(
'action=history' );
193 if (
$title->isUserJsConfigPage() ||
$title->isSiteJsConfigPage() ) {
194 $urls[] =
$title->getInternalURL(
'action=raw&ctype=text/javascript' );
195 } elseif (
$title->isUserJsonConfigPage() ||
$title->isSiteJsonConfigPage() ) {
196 $urls[] =
$title->getInternalURL(
'action=raw&ctype=application/json' );
197 } elseif (
$title->isUserCssConfigPage() ||
$title->isSiteCssConfigPage() ) {
198 $urls[] =
$title->getInternalURL(
'action=raw&ctype=text/css' );
204 $mode = $flags & self::PURGE_URLS_LINKSUPDATE_ONLY;
205 $this->hookRunner->onHtmlCacheUpdaterAppendUrls(
$title, $mode, $append );
206 $urls = array_merge( $urls, $append );
210 $this->hookRunner->onHtmlCacheUpdaterVaryUrls( $urls, $append );
211 $urls = array_merge( $urls, $append );
214 $this->hookRunner->onTitleSquidURLs(
$title, $urls );