Hooks! Hoooooks!
[lhc/web/wiklou.git] / includes / Article.php
index 0950e61..792fd7e 100644 (file)
@@ -1309,6 +1309,7 @@ class Article {
                $oldsize = strlen( $oldtext );
                $newsize = strlen( $text );
                $lastRevision = 0;
+               $revisionId = 0;
 
                if ( 0 != strcmp( $text, $oldtext ) ) {
                        $this->mGoodAdjustment = $this->isCountable( $text )
@@ -1343,8 +1344,10 @@ class Article {
                                RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary,
                                        $lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
                                        $revisionId );
-                               Article::onArticleEdit( $this->mTitle );
                                $dbw->commit();
+                               
+                               // Update caches outside the main transaction
+                               Article::onArticleEdit( $this->mTitle );
                        }
                }
 
@@ -1372,32 +1375,6 @@ class Article {
                        $this->editUpdates( $text, $summary, $minor, $now );
 
 
-                       $urls = array();
-                       # Template namespace
-                       # Purge all articles linking here
-                       if ( $this->mTitle->getNamespace() == NS_TEMPLATE) {
-                               $titles = $this->mTitle->getLinksTo();
-                               Title::touchArray( $titles );
-                               if ( $wgUseSquid ) {
-                                               foreach ( $titles as $title ) {
-                                                       $urls[] = $title->getInternalURL();
-                                               }
-                               }
-                       }
-
-                       # Squid updates
-                       if ( $wgUseSquid ) {
-                               $urls = array_merge( $urls, $this->mTitle->getSquidURLs() );
-                               $u = new SquidUpdate( $urls );
-                               array_push( $wgPostCommitUpdateList, $u );
-                       }
-
-                       # File cache
-                       if ( $wgUseFileCache ) {
-                               $cm = new CacheManager($this->mTitle);
-                               @unlink($cm->fileCacheName());
-                       }
-
                        $this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $isminor, $now, $summary, $lastRevision, $revisionId );
                }
                wfRunHooks( 'ArticleSaveComplete',
@@ -1453,13 +1430,7 @@ class Article {
                else
                        $r = '';
                $wgOut->redirect( $this->mTitle->getFullURL( $r ).$sectionanchor );
-
-               if ( $wgUseEnotif  ) {
-                       # this would be better as an extension hook
-                       include_once( "UserMailer.php" );
-                       $enotif = new EmailNotification ();
-                       $enotif->notifyOnPageChange( $this->mTitle, $now, $summary, $me2, $oldid );
-               }
+               
                wfProfileOut( $fname );
        }
 
@@ -2436,9 +2407,38 @@ class Article {
                }
        }
 
-       function onArticleEdit($title_obj) {
-               // This would be an appropriate place to purge caches.
-               // Why's this not in here now?
+       /**
+        * Purge caches on page update etc
+        */
+       function onArticleEdit( $title ) {
+               global $wgUseSquid, $wgPostCommitUpdateList, $wgUseFileCache;
+               
+               $urls = array();
+               
+               // Template namespace? Purge all articles linking here.
+               // FIXME: When a templatelinks table arrives, use it for all includes.
+               if ( $title->getNamespace() == NS_TEMPLATE) {
+                       $titles = $title->getLinksTo();
+                       Title::touchArray( $titles );
+                       if ( $wgUseSquid ) {
+                               foreach ( $titles as $link ) {
+                                       $urls[] = $link->getInternalURL();
+                               }
+                       }
+               }
+
+               # Squid updates
+               if ( $wgUseSquid ) {
+                       $urls = array_merge( $urls, $title->getSquidURLs() );
+                       $u = new SquidUpdate( $urls );
+                       array_push( $wgPostCommitUpdateList, $u );
+               }
+
+               # File cache
+               if ( $wgUseFileCache ) {
+                       $cm = new CacheManager( $title );
+                       @unlink( $cm->fileCacheName() );
+               }
        }
 
        /**#@-*/