Go to the documentation of this file.
24 use Wikimedia\Assert\Assert;
39 $this->urls = $urlArr;
44 Assert::parameterType( __CLASS__, $update,
'$update' );
46 $this->urls = array_merge( $this->urls, $update->urls );
60 $urlArr = array_merge( $urlArr,
$title->getCdnUrls() );
87 'urls' => $this->urls,
109 $urlArr = array_unique( $urlArr );
111 wfDebugLog(
'squid', __METHOD__ .
': ' . implode(
' ', $urlArr ) );
114 $relayer = MediaWikiServices::getInstance()->getEventRelayerGroup()
115 ->getRelayer(
'cdn-url-purges' );
116 $ts = microtime(
true );
117 $relayer->notifyMulti(
120 function ( $url )
use ( $ts ) {
138 $maxSocketsPerSquid = 8;
141 $urlsPerSocket = 400;
142 $socketsPerSquid = ceil(
count( $urlArr ) / $urlsPerSocket );
143 if ( $socketsPerSquid > $maxSocketsPerSquid ) {
144 $socketsPerSquid = $maxSocketsPerSquid;
148 $chunks = array_chunk( $urlArr, ceil(
count( $urlArr ) / $socketsPerSquid ) );
150 foreach ( $chunks
as $chunk ) {
152 foreach ( $chunk
as $url ) {
153 $client->queuePurge( $url );
155 $pool->addClient( $client );
176 if ( !defined(
"IPPROTO_IP" ) ) {
177 define(
"IPPROTO_IP", 0 );
178 define(
"IP_MULTICAST_LOOP", 34 );
179 define(
"IP_MULTICAST_TTL", 33 );
183 $conn = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
185 $errstr = socket_strerror( socket_last_error() );
187 ": Error opening UDP socket: $errstr" );
193 socket_set_option( $conn, IPPROTO_IP, IP_MULTICAST_LOOP, 0 );
196 socket_set_option( $conn, IPPROTO_IP, IP_MULTICAST_TTL,
205 foreach ( $urlArr
as $url ) {
206 if ( !is_string( $url ) ) {
213 "No HTCP rule configured for URL {$url} , skipping" );
217 if ( isset( $conf[
'host'] ) && isset( $conf[
'port'] ) ) {
221 foreach ( $conf
as $subconf ) {
222 if ( !isset( $subconf[
'host'] ) || !isset( $subconf[
'port'] ) ) {
223 throw new MWException(
"Invalid HTCP rule for URL $url\n" );
230 $htcpTransID = current( $ids );
233 $htcpSpecifier = pack(
'na4na*na8n',
234 4,
'HEAD', strlen( $url ), $url,
237 $htcpDataLen = 8 + 2 + strlen( $htcpSpecifier );
238 $htcpLen = 4 + $htcpDataLen + 2;
243 $htcpPacket = pack(
'nxxnCxNxxa*n',
244 $htcpLen, $htcpDataLen, $htcpOpCLR,
245 $htcpTransID, $htcpSpecifier, 2 );
248 "Purging URL $url via HTCP" );
249 foreach ( $conf
as $subconf ) {
250 socket_sendto( $conn, $htcpPacket, $htcpLen, 0,
251 $subconf[
'host'], $subconf[
'port'] );
281 foreach ( $rules
as $regex => $routing ) {
282 if ( $regex ===
'' || preg_match( $regex, $url ) ) {
static purge(array $urlArr)
Purges a list of CDN nodes defined in $wgSquidServers.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
$wgHTCPMulticastTTL
HTCP multicast TTL.
Interface that deferrable updates can implement.
string[] $urls
Collection of URLs to purge.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
doUpdate()
Purges the list of URLs passed to the constructor.
An HTTP 1.0 client built for the purposes of purging Squid and Varnish.
static HTCPPurge(array $urlArr)
Send Hyper Text Caching Protocol (HTCP) CLR requests.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
static getRuleForURL( $url, $rules)
Find the HTCP routing rule to use for a given URL.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static newSimplePurge(Title $title)
merge(MergeableUpdate $update)
Merge this update with $update.
namespace and then decline to actually register it file or subcat img or subcat $title
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
static expand( $url)
Expand local URLs to fully-qualified URLs using the internal protocol and host defined in $wgInternal...
$wgHTCPRouting
Routing configuration for HTCP multicast purging.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
when a variable name is used in a it is silently declared as a new masking the global
__construct(array $urlArr)
static newFromTitles( $titles, $urlArr=[])
Create an update object from an array of Title objects, or a TitleArray object.
Handles purging appropriate CDN URLs given a title (or titles)
Job to purge a set of URLs from CDN.
$wgSquidServers
List of proxy servers to purge on changes; default port is 80.
Represents a title within MediaWiki.
static singleton( $wiki=false)
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Interface that deferrable updates should implement.
static newSequentialPerNodeIDs( $bucket, $bits, $count, $flags=0)
Return IDs that are sequential only for this node and bucket.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
$wgCdnReboundPurgeDelay
If set, any SquidPurge call on a URL or URLs will send a second purge no less than this many seconds ...
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
the array() calling protocol came about after MediaWiki 1.4rc1.