class SquidUpdate {
var $urlArr, $mMaxTitles;
- function __construct( $urlArr = Array(), $maxTitles = false ) {
+ /**
+ * @param $urlArr array
+ * @param $maxTitles bool|int
+ */
+ function __construct( $urlArr = array(), $maxTitles = false ) {
global $wgMaxSquidPurgeTitles;
if ( $maxTitles === false ) {
$this->mMaxTitles = $wgMaxSquidPurgeTitles;
static function purge( $urlArr ) {
global $wgSquidServers, $wgHTCPMulticastRouting;
- /*if ( (@$wgSquidServers[0]) == 'echo' ) {
- echo implode("<br />\n", $urlArr) . "<br />\n";
- return;
- }*/
-
if( !$urlArr ) {
return;
}
+ wfDebug( "Squid purge: " . implode( ' ', $urlArr ) . "\n" );
+
if ( $wgHTCPMulticastRouting ) {
SquidUpdate::HTCPPurge( $urlArr );
}
throw new MWException( "Invalid HTCP rule for URL $url\n" );
}
+ // Try and incremement value in APC cache
+ $id = apc_inc( 'squidhtcppurge' );
+ if ( $id === false ) {
+ // If false, means it didn't work
+ // Chances are that means it isn't in the cache
+ // Start saving a cached value
+ $add = apc_add( 'squidhtcppurge', 1 );
+ if ( $add === false ) {
+ wfDebugLog( 'htcp', 'Unable to set value to APC cache' );
+ $id = 0;
+ } else {
+ $id = $add;
+ }
+ }
+
// Construct a minimal HTCP request diagram
// as per RFC 2756
// Opcode 'CLR', no response desired, no auth
- $htcpTransID = rand();
+ $htcpTransID = $id;
$htcpSpecifier = pack( 'na4na*na8n',
4, 'HEAD', strlen( $url ), $url,
static function expand( $url ) {
return wfExpandUrl( $url, PROTO_INTERNAL );
}
-
+
/**
* Find the HTCP routing rule to use for a given URL.
* @param $url string URL to match
}
return false;
}
-
}