Cripple the wiki text stuff for now. It doesn't SEEM dangerous but I haven't tested...
[lhc/web/wiklou.git] / includes / Image.php
index 3f5e642..3573d36 100644 (file)
@@ -888,7 +888,7 @@ class Image
         *
         * @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 ) {
@@ -904,9 +904,6 @@ class Image
                }
                else $thumb= NULL; #not a bitmap or renderable image, don't try.
 
-               if( is_null( $thumb ) ) {
-                       $thumb = $this->iconThumb();
-               }
                return $thumb;
        }
 
@@ -936,7 +933,7 @@ class Image
         * 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 ) {
@@ -1319,16 +1316,8 @@ class Image
                $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) {
@@ -1464,7 +1453,7 @@ class Image
         * 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 );
@@ -1531,8 +1520,6 @@ class Image
                        $fname,
                        'IGNORE'
                );
-               $descTitle = $this->getTitle();
-               $purgeURLs = array();
 
                if( $dbw->affectedRows() == 0 ) {
                        # Collision, this is an update of an image
@@ -1578,6 +1565,7 @@ class 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 );
@@ -1591,24 +1579,24 @@ class Image
 
                        # 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;
        }
 
@@ -1617,6 +1605,8 @@ class Image
         * 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';