User:0x99/MediaWiki Patches: Difference between revisions

From Puella Magi Wiki
Jump to navigation Jump to search
(blah blah mw sucks etc etc)
 
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
* [https://bugzilla.wikimedia.org/show_bug.cgi?id=17577 Bug 17577 - Images can't have far future expires].
* [https://bugzilla.wikimedia.org/show_bug.cgi?id=17577 Bug 17577 - Images can't have far future expires].


=== includes/filerepo/File.php ===
<pre>
<pre>
--- File.old.php 2012-02-26 10:45:34.000000000 +0000
--- File.old.php 2012-02-26 10:45:34.000000000 +0000
Line 22: Line 23:
  }
  }
- return $path;
- return $path;
+ return $path . "?" . $this->getTimestamp();;
+ return $path . "?" . $this->getTimestamp();
  }
  }
   
   
  /** Get the virtual URL for an archive file or directory */
  /** Get the virtual URL for an archive file or directory */
</pre>
</pre>

Latest revision as of 10:10, 26 February 2012

Image cache

Puella Magi Wiki is using a far future expiration header to help with page load and bandwidth usage however when re-uploading the file MediaWiki will replace the same URL and user won't get the latest version of the file until the file is expired from user's cache. This patch add a timestamp to every image URL. It is based on a patch by Surgey Chernyshev.

includes/filerepo/File.php

--- File.old.php	2012-02-26 10:45:34.000000000 +0000
+++ File.php	2012-02-26 09:51:09.000000000 +0000
@@ -170,7 +170,7 @@
 		if ( !isset( $this->url ) ) {
 			$this->url = $this->repo->getZoneUrl( 'public' ) . '/' . $this->getUrlRel();
 		}
-		return $this->url;
+		return $this->url . "?" . $this->getTimestamp();
 	}
 
 	/**
@@ -788,7 +788,7 @@
 		if ( $suffix !== false ) {
 			$path .= '/' . rawurlencode( $suffix );
 		}
-		return $path;
+		return $path . "?" . $this->getTimestamp();
 	}
 
 	/** Get the virtual URL for an archive file or directory */