*
* @param integer $width maximum width of the generated thumbnail
* @param integer $height maximum height of the image (optional)
- * @return ThumbnailImage
+ * @return ThumbnailImage or null on failure
* @public
*/
function getThumbnail( $width, $height=-1 ) {
}
else $thumb= NULL; #not a bitmap or renderable image, don't try.
- if( is_null( $thumb ) ) {
- $thumb = $this->iconThumb();
- }
return $thumb;
}
* Returns an object which can return the pathname, URL, and physical
* pixel size of the thumbnail -- or null on failure.
*
- * @return ThumbnailImage
+ * @return ThumbnailImage or null on failure
* @private
*/
function renderThumb( $width, $useScript = true ) {
$this->purgeDescription();
// Purge cache of all pages using this image
- $linksTo = $this->getLinksTo();
- global $wgUseSquid, $wgPostCommitUpdateList;
- if ( $wgUseSquid ) {
- $u = SquidUpdate::newFromTitles( $linksTo, $urlArr );
- array_push( $wgPostCommitUpdateList, $u );
- }
-
- // Invalidate parser cache and client cache for pages using this image
- // This is left until relatively late to reduce lock time
- Title::touchArray( $linksTo );
+ $update = new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' );
+ $update->doUpdate();
}
function checkDBSchema(&$db) {
* Record an image upload in the upload log and the image table
*/
function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '', $watch = false ) {
- global $wgUser, $wgUseCopyrightUpload, $wgUseSquid, $wgPostCommitUpdateList;
+ global $wgUser, $wgUseCopyrightUpload;
$fname = 'Image::recordUpload';
$dbw =& wfGetDB( DB_MASTER );
$fname,
'IGNORE'
);
- $descTitle = $this->getTitle();
- $purgeURLs = array();
if( $dbw->affectedRows() == 0 ) {
# Collision, this is an update of an image
$dbw->query( "UPDATE $site_stats SET ss_images=ss_images+1", $fname );
}
+ $descTitle = $this->getTitle();
$article = new Article( $descTitle );
$minor = false;
$watch = $watch || $wgUser->isWatched( $descTitle );
# Invalidate the cache for the description page
$descTitle->invalidateCache();
- $purgeURLs[] = $descTitle->getInternalURL();
+ $descTitle->purgeSquid();
} else {
// New image; create the description page.
$article->insertNewArticle( $textdesc, $desc, $minor, $watch, $suppressRC );
}
- # Invalidate cache for all pages using this image
- $linksTo = $this->getLinksTo();
-
- if ( $wgUseSquid ) {
- $u = SquidUpdate::newFromTitles( $linksTo, $purgeURLs );
- array_push( $wgPostCommitUpdateList, $u );
- }
- Title::touchArray( $linksTo );
-
+ # Add the log entry
$log = new LogPage( 'upload' );
$log->addEntry( 'upload', $descTitle, $desc );
+ # Commit the transaction now, in case something goes wrong later
+ # The most important thing is that images don't get lost, especially archives
+ $dbw->immediateCommit();
+
+ # Invalidate cache for all pages using this image
+ $update = new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' );
+ $update->doUpdate();
+
return true;
}
* Also adds their IDs to the link cache
*
* This is mostly copied from Title::getLinksTo()
+ *
+ * @deprecated Use HTMLCacheUpdate, this function uses too much memory
*/
function getLinksTo( $options = '' ) {
$fname = 'Image::getLinksTo';