From: Gabriel Wicke Date: Mon, 2 Feb 2004 01:40:03 +0000 (+0000) Subject: Squid branch merge. Calls to purge functions in Article.php and special pages. X-Git-Tag: 1.3.0beta1~1036 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=ef98e54686112443e4a7799407b41fa33bc72fbc;p=lhc%2Fweb%2Fwiklou.git Squid branch merge. Calls to purge functions in Article.php and special pages. --- diff --git a/includes/Article.php b/includes/Article.php index 55e63c895f..3f57d9efbd 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -375,6 +375,7 @@ class Article { /* private */ function insertNewArticle( $text, $summary, $isminor, $watchthis ) { global $wgOut, $wgUser, $wgLinkCache, $wgMwRedir; + global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer; $fname = "Article::insertNewArticle"; @@ -421,6 +422,20 @@ class Article { $sql = "UPDATE cur set cur_touched='$now' WHERE cur_namespace=$talkns AND cur_title='" . wfStrencode( $ttl ) . "'"; wfQuery( $sql, DB_WRITE ); + # standard deferred updates + $this->editUpdates( $text ); + + # Squid purging + if ( $wgUseSquid ) { + $urlArr = Array( + $wgInternalServer.wfLocalUrl( $this->mTitle->getPrefixedURL()) + ); + wfPurgeSquidServers($urlArr); + /* this needs to be done after LinksUpdate */ + $u = new SquidUpdate($this->mTitle); + array_push( $wgDeferredUpdateList, $u ); + } + $this->showArticle( $text, wfMsg( "newarticle" ) ); } @@ -428,6 +443,7 @@ class Article { { global $wgOut, $wgUser, $wgLinkCache; global $wgDBtransactions, $wgMwRedir; + global $wgUseSquid, $wgInternalServer; $fname = "Article::updateArticle"; $this->loadLastEdit(); @@ -521,6 +537,17 @@ class Article { $this->unwatch(); } } + # standard deferred updates + $this->editUpdates( $text ); + + # Squid updates + + if ( $wgUseSquid ) { + $urlArr = Array( + $wgInternalServer.wfLocalUrl( $this->mTitle->getPrefixedURL()) + ); + wfPurgeSquidServers($urlArr); + } $this->showArticle( $text, wfMsg( "updated" ) ); return true; @@ -544,7 +571,6 @@ class Article { $wgOut = new OutputPage(); $wgOut->addWikiText( $text ); - $this->editUpdates( $text ); if( $wgMwRedir->matchStart( $text ) ) $r = "redirect=no"; else @@ -787,7 +813,8 @@ class Article { function doDeleteArticle( $title ) { - global $wgUser, $wgOut, $wgLang, $wpReason, $wgDeferredUpdateList; + global $wgUser, $wgOut, $wgLang, $wpReason; + global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer; $fname = "Article::doDeleteArticle"; wfDebug( "$fname\n" ); @@ -803,6 +830,29 @@ class Article { $u = new SiteStatsUpdate( 0, 1, -$this->isCountable( $this->getContent( true ) ) ); array_push( $wgDeferredUpdateList, $u ); + + # Squid purging + if ( $wgUseSquid ) { + $urlArr = Array( + $wgInternalServer.wfLocalUrl( $this->mTitle->getPrefixedURL()) + ); + wfPurgeSquidServers($urlArr); + + /* prepare the list of urls to purge */ + $sql = "SELECT l_from FROM links WHERE l_to={$id}" ; + $res = wfQuery ( $sql, DB_READ ) ; + while ( $BL = wfFetchObject ( $res ) ) + { + $t = Title::newFromDBkey( $BL->l_from) ; + $blurlArr[] = $wgInternalServer.wfLocalUrl( $t->getPrefixedURL() ); + } + wfFreeResult ( $res ) ; + $u = new SquidUpdate( $this->mTitle, $blurlArr ); + array_push( $wgDeferredUpdateList, $u ); + + } + + # Move article and history to the "archive" table $sql = "INSERT INTO archive (ar_namespace,ar_title,ar_text," . diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 1743f25e64..331c01a321 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -254,7 +254,7 @@ class OutputPage { if( $this->mLastModified != "" ) { if( $wgUseSquid && ! isset( $_COOKIE[ini_get( "session.name") ] ) ) { if ( $wgUseESI ) { - # We'll purge the proxy cache for anons explicitly, but require end user agents + # We'll purge the proxy cache explicitly, but require end user agents # to revalidate against the proxy on each visit. # Surrogate-Control controls our Squid, Cache-Control downstream caches wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false ); diff --git a/includes/SpecialMovepage.php b/includes/SpecialMovepage.php index 0e5e7436d1..d76a510b0c 100644 --- a/includes/SpecialMovepage.php +++ b/includes/SpecialMovepage.php @@ -102,6 +102,7 @@ class MovePageForm { global $wgOut, $wgUser, $wgLang; global $wpNewTitle, $wpOldTitle, $wpMovetalk, $target; global $wgDeferredUpdateList, $wgMessageCache; + global $wgUseSquid, $wgInternalServer; $fname = "MovePageForm::doSubmit"; $this->ot = Title::newFromText( $wpOldTitle ); @@ -159,6 +160,26 @@ class MovePageForm { $u->doUpdate(); $u = new SearchUpdate( $this->newid, $this->ot->getPrefixedDBkey(), "" ); $u->doUpdate(); + + # Squid purging + if ( $wgUseSquid ) { + /* this needs to be done after LinksUpdate */ + $urlArr = Array( + # purge new title + $wgInternalServer.wfLocalUrl( $this->nt->getPrefixedURL()), + # purge old title + $wgInternalServer.wfLocalUrl( $this->ot->getPrefixedURL()) + ); + wfPurgeSquidServers($urlArr); + # purge pages linking to new title + $u = new SquidUpdate($this->nt); + array_push( $wgDeferredUpdateList, $u ); + # purge pages linking to old title + $u = new SquidUpdate($this->ot); + array_push( $wgDeferredUpdateList, $u ); + + + } # Move talk page if (1) the checkbox says to, (2) the source # and target namespaces are identical, (3) the namespaces are not @@ -196,6 +217,26 @@ class MovePageForm { $u->doUpdate(); $u = new SearchUpdate( $this->newid, $this->ot->getPrefixedDBkey(), "" ); $u->doUpdate(); + + # Squid purging + if ( $wgUseSquid ) { + /* this needs to be done after LinksUpdate */ + $urlArr = Array( + # purge new title + $wgInternalServer.wfLocalUrl( $this->nt->getPrefixedURL()), + # purge old title + $wgInternalServer.wfLocalUrl( $this->ot->getPrefixedURL()) + ); + wfPurgeSquidServers($urlArr); + # purge pages linking to new title + $u = new SquidUpdate($this->nt); + array_push( $wgDeferredUpdateList, $u ); + # purge pages linking to old title + $u = new SquidUpdate($this->ot); + array_push( $wgDeferredUpdateList, $u ); + + + } } } $success = wfLocalUrl( $wgLang->specialPage( "Movepage" ), diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index 8111e2b9a3..83003b8a33 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -110,6 +110,7 @@ function wfSpecialUndelete( $par ) /* private */ function doUndeleteArticle( $namespace, $title ) { global $wgUser, $wgOut, $wgLang, $target, $wgDeferredUpdateList; + global $wgUseSquid, $wgInternalServer; $fname = "doUndeleteArticle"; @@ -181,6 +182,13 @@ function wfSpecialUndelete( $par ) Article::onArticleCreate( $to ); + # Squid purging + if ( $wgUseSquid ) { + /* this needs to be done after LinksUpdate */ + $u = new SquidUpdate($to); + array_push( $wgDeferredUpdateList, $u ); + } + #TODO: SearchUpdate, etc. }