Squid branch merge. Calls to purge functions in Article.php and special pages.

This commit is contained in:
Gabriel Wicke 2004-02-02 01:40:03 +00:00
parent d305622d9a
commit ef98e54686
4 changed files with 102 additions and 3 deletions

View file

@ -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," .

View file

@ -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 );

View file

@ -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" ),

View file

@ -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.
}