23use Wikimedia\Assert\Assert;
38 $this->urls = $urlArr;
43 Assert::parameterType( __CLASS__, $update,
'$update' );
45 $this->urls = array_merge( $this->urls, $update->urls );
59 $urlArr = array_merge( $urlArr, $title->getCdnUrls() );
83 JobQueueGroup::singleton()->lazyPush(
new CdnPurgeJob(
84 Title::makeTitle(
NS_SPECIAL,
'Badtitle/' . __CLASS__ ),
86 'urls' => $this->urls,
108 $urlArr = array_unique( $urlArr );
110 wfDebugLog(
'squid', __METHOD__ .
': ' . implode(
' ', $urlArr ) );
113 $relayer = MediaWikiServices::getInstance()->getEventRelayerGroup()
114 ->getRelayer(
'cdn-url-purges' );
115 $ts = microtime(
true );
116 $relayer->notifyMulti(
119 function ( $url ) use ( $ts ) {
137 $maxSocketsPerSquid = 8;
140 $urlsPerSocket = 400;
141 $socketsPerSquid = ceil( count( $urlArr ) / $urlsPerSocket );
142 if ( $socketsPerSquid > $maxSocketsPerSquid ) {
143 $socketsPerSquid = $maxSocketsPerSquid;
147 $chunks = array_chunk( $urlArr, ceil( count( $urlArr ) / $socketsPerSquid ) );
149 foreach ( $chunks as $chunk ) {
151 foreach ( $chunk as $url ) {
152 $client->queuePurge( $url );
154 $pool->addClient( $client );
175 if ( !defined(
"IPPROTO_IP" ) ) {
176 define(
"IPPROTO_IP", 0 );
177 define(
"IP_MULTICAST_LOOP", 34 );
178 define(
"IP_MULTICAST_TTL", 33 );
182 $conn = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
184 $errstr = socket_strerror( socket_last_error() );
186 ": Error opening UDP socket: $errstr" );
192 socket_set_option( $conn, IPPROTO_IP, IP_MULTICAST_LOOP, 0 );
195 socket_set_option( $conn, IPPROTO_IP, IP_MULTICAST_TTL,
204 foreach ( $urlArr as $url ) {
205 if ( !is_string( $url ) ) {
212 "No HTCP rule configured for URL {$url} , skipping" );
216 if ( isset( $conf[
'host'] ) && isset( $conf[
'port'] ) ) {
220 foreach ( $conf as $subconf ) {
221 if ( !isset( $subconf[
'host'] ) || !isset( $subconf[
'port'] ) ) {
222 throw new MWException(
"Invalid HTCP rule for URL $url\n" );
229 $htcpTransID = current( $ids );
232 $htcpSpecifier = pack(
'na4na*na8n',
233 4,
'HEAD', strlen( $url ), $url,
236 $htcpDataLen = 8 + 2 + strlen( $htcpSpecifier );
237 $htcpLen = 4 + $htcpDataLen + 2;
242 $htcpPacket = pack(
'nxxnCxNxxa*n',
243 $htcpLen, $htcpDataLen, $htcpOpCLR,
244 $htcpTransID, $htcpSpecifier, 2 );
247 "Purging URL $url via HTCP" );
248 foreach ( $conf as $subconf ) {
249 socket_sendto( $conn, $htcpPacket, $htcpLen, 0,
250 $subconf[
'host'], $subconf[
'port'] );
280 foreach ( $rules as $regex => $routing ) {
281 if ( $regex ===
'' || preg_match( $regex, $url ) ) {
$wgCdnReboundPurgeDelay
If set, any SquidPurge call on a URL or URLs will send a second purge no less than this many seconds ...
$wgHTCPRouting
Routing configuration for HTCP multicast purging.
$wgSquidServers
List of proxy servers to purge on changes; default port is 80.
$wgHTCPMulticastTTL
HTCP multicast TTL.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Handles purging appropriate CDN URLs given a title (or titles)
static newFromTitles( $titles, $urlArr=[])
Create an update object from an array of Title objects, or a TitleArray object.
__construct(array $urlArr)
static HTCPPurge(array $urlArr)
Send Hyper Text Caching Protocol (HTCP) CLR requests.
static getRuleForURL( $url, $rules)
Find the HTCP routing rule to use for a given URL.
string[] $urls
Collection of URLs to purge.
static purge(array $urlArr)
Purges a list of CDN nodes defined in $wgSquidServers.
doUpdate()
Purges the list of URLs passed to the constructor.
static expand( $url)
Expand local URLs to fully-qualified URLs using the internal protocol and host defined in $wgInternal...
static newSimplePurge(Title $title)
merge(MergeableUpdate $update)
Merge this update with $update.
Job to purge a set of URLs from CDN.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
An HTTP 1.0 client built for the purposes of purging Squid and Varnish.
Represents a title within MediaWiki.
static newSequentialPerNodeIDs( $bucket, $bits, $count, $flags=0)
Return IDs that are sequential only for this node and bucket.
Interface that deferrable updates should implement.
Interface that deferrable updates can implement.
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
In both all secondary updates will be triggered handle like object that caches derived data representing a and can trigger updates of cached copies of that e g in the links the and the CDN layer DerivedPageDataUpdater is used by PageUpdater when creating new but can also be used independently when performing meta data updates during or when puring a page It s a stepping stone on the way to a more complete refactoring of WikiPage we want to define interfaces for the different use cases of particularly providing access to post PST content and ParserOutput to callbacks during revision which currently use and allowing updates to be triggered on purge