* Add {{CURRENTTIMESTAMP}} magic word
* (bug 6061) Improper escaping in some html forms
* (bug 6065) Remove underscore when using NAMESPACE and TALKSPACE magics.
+* (bug 6074) Correct squid purging of offsite upload URLs
+
== Compatibility ==
* @private
*/
function renderThumb( $width, $useScript = true ) {
- global $wgUseSquid, $wgInternalServer;
+ global $wgUseSquid;
global $wgSVGMaxSize, $wgMaxImageArea, $wgThumbnailEpoch;
$fname = 'Image::renderThumb';
# This has to be done after the image is updated and present for all machines on NFS,
# or else the old version might be stored into the squid again
if ( $wgUseSquid ) {
- if ( substr( $url, 0, 4 ) == 'http' ) {
- $urlArr = array( $url );
- } else {
- $urlArr = array( $wgInternalServer.$url );
- }
+ $urlArr = array( $url );
wfPurgeSquidServers($urlArr);
}
}
* Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid
*/
function purgeCache( $archiveFiles = array(), $shared = false ) {
- global $wgInternalServer, $wgUseSquid;
+ global $wgUseSquid;
// Refresh metadata cache
$this->purgeMetadataCache();
$urls = array();
foreach ( $files as $file ) {
if ( preg_match( '/^(\d+)px/', $file, $m ) ) {
- $urls[] = $wgInternalServer . $this->thumbUrl( $m[1], $this->fromSharedDirectory );
+ $urls[] = $this->thumbUrl( $m[1], $this->fromSharedDirectory );
@unlink( "$dir/$file" );
}
}
// Purge the squid
if ( $wgUseSquid ) {
- $urls[] = $wgInternalServer . $this->getViewURL();
+ $urls[] = $this->getViewURL();
foreach ( $archiveFiles as $file ) {
- $urls[] = $wgInternalServer . wfImageArchiveUrl( $file );
+ $urls[] = wfImageArchiveUrl( $file );
}
wfPurgeSquidServers( $urls );
}
}
function doDelete() {
- global $wgOut, $wgRequest, $wgUseSquid, $wgInternalServer;
+ global $wgOut, $wgRequest, $wgUseSquid;
global $wgPostCommitUpdateList;
$fname = 'ImagePage::doDelete';
# Squid purging
if ( $wgUseSquid ) {
$urlArr = array(
- $wgInternalServer.wfImageArchiveUrl( $oldimage ),
+ wfImageArchiveUrl( $oldimage ),
$this->mTitle->getInternalURL()
);
wfPurgeSquidServers($urlArr);
$urlArr = Array();
while ( $s = $dbw->fetchObject( $res ) ) {
$this->doDeleteOldImage( $s->oi_archive_name );
- $urlArr[] = $wgInternalServer.wfImageArchiveUrl( $s->oi_archive_name );
+ $urlArr[] = wfImageArchiveUrl( $s->oi_archive_name );
}
# And also the HTML of all pages using this image
$maxsocketspersquid = 8; // socket cap per Squid
$urlspersocket = 400; // 400 seems to be a good tradeoff, opening a socket takes a while
- $firsturl = $urlArr[0];
+ $firsturl = SquidUpdate::expand( $urlArr[0] );
unset($urlArr[0]);
$urlArr = array_values($urlArr);
$sockspersq = max(ceil(count($urlArr) / $urlspersocket ),1);
}
}
$urindex = $r + $urlspersocket * ($s - $sockspersq * floor($s / $sockspersq));
- $msg = 'PURGE ' . $urlArr[$urindex] . " HTTP/1.0\r\n".
+ $url = SquidUpdate::expand( $urlArr[$urindex] );
+ $msg = 'PURGE ' . $url . " HTTP/1.0\r\n".
"Connection: Keep-Alive\r\n\r\n";
#$this->debug($msg);
@fputs($sockets[$s],$msg);
$wgHTCPMulticastTTL );
foreach ( $urlArr as $url ) {
+ $url = SquidUpdate::expand( $url );
+
// Construct a minimal HTCP request diagram
// as per RFC 2756
// Opcode 'CLR', no response desired, no auth
wfDebug( $text );
}
}
+
+ /**
+ * Expand local URLs to fully-qualified URLs using the internal protocol
+ * and host defined in $wgInternalServer. Input that's already fully-
+ * qualified will be passed through unchanged.
+ *
+ * This is used to generate purge URLs that may be either local to the
+ * main wiki or include a non-native host, such as images hosted on a
+ * second internal server.
+ *
+ * Client functions should not need to call this.
+ *
+ * @return string
+ */
+ static function expand( $url ) {
+ global $wgInternalServer;
+ if( $url != '' && $url{0} == '/' ) {
+ return $wgInternalServer . $url;
+ }
+ return $url;
+ }
}
?>