/* private */ function insertNewArticle( $text, $summary, $isminor, $watchthis )
{
global $wgOut, $wgUser, $wgLinkCache, $wgMwRedir;
- global $wgEnablePersistentLC;
$fname = "Article::insertNewArticle";
$newid = wfInsertId();
$this->mTitle->resetArticleID( $newid );
- if ( $wgEnablePersistentLC ) {
- // Purge related entries in links cache on new page, to heal broken links
- LinkCache::linksccClearBrokenLinksTo( $ttl );
- }
+ Article::onArticleCreate( $this->mTitle );
$sql = "INSERT INTO recentchanges (rc_timestamp,rc_cur_time," .
"rc_namespace,rc_title,rc_new,rc_minor,rc_cur_id,rc_user," .
"WHERE rc_cur_id=" . $this->getID();
wfQuery( $sql, DB_WRITE, $fname );
- global $wgEnablePersistentLC;
- if ( $wgEnablePersistentLC ) {
- // Purge link cache for this page
- LinkCache::linksccClearPage( $this->getID() );
- }
+ Article::onArticleEdit( $this->mTitle );
}
if( $wgDBtransactions ) {
function doDeleteArticle( $title )
{
- global $wgUser, $wgOut, $wgLang, $wpReason, $wgDeferredUpdateList,
- $wgEnablePersistentLC;
+ global $wgUser, $wgOut, $wgLang, $wpReason, $wgDeferredUpdateList;
$fname = "Article::doDeleteArticle";
wfDebug( "$fname\n" );
$t = wfStrencode( $title->getPrefixedDBkey() );
- if ( $wgEnablePersistentLC ) {
- // Purge related entries in links cache on delete,
- LinkCache::linksccClearLinksTo( $id );
- }
+ Article::onArticleDelete( $title );
$sql = "SELECT l_from FROM links WHERE l_to={$id}";
$res = wfQuery( $sql, DB_READ, $fname );
$wgOut->setRobotpolicy( "noindex,nofollow" );
$wgOut->addHTML( "<h2>" . $newcomment . "</h2>\n<hr>\n" );
$this->updateArticle( Article::getRevisionText( $s ), $newcomment, 1, $this->mTitle->userIsWatching(), "", $bot );
-
- global $wgEnablePersistentLC;
- if ( $wgEnablePersistentLC ) {
- LinkCache::linksccClearPage( $pid );
- }
-
+
+ Article::onArticleEdit( $this->mTitle );
$wgOut->returnToMain( false );
}
}
wfIgnoreSQLErrors( $oldignore );
}
+
+ # The onArticle*() functions are supposed to be a kind of hooks
+ # which should be called whenever any of the specified actions
+ # are done.
+ #
+ # This is a good place to put code to clear caches, for instance.
+
+ /* static */ function onArticleCreate($title_obj){
+ global $wgEnablePersistentLC;
+ if ( $wgEnablePersistentLC ) {
+ LinkCache::linksccClearBrokenLinksTo( $title_obj->getPrefixedDBkey() );
+ }
+ }
+
+ /* static */ function onArticleDelete($title_obj){
+ global $wgEnablePersistentLC;
+ if ( $wgEnablePersistentLC ) {
+ LinkCache::linksccClearLinksTo( $title_obj->getArticleID() );
+ }
+ }
+
+ /* static */ function onArticleEdit($title_obj){
+ global $wgEnablePersistentLC;
+ if ( $wgEnablePersistentLC ) {
+ LinkCache::linksccClearPage( $title_obj->getArticleID() );
+ }
+ }
}
function wfReplaceSubstVar( $matches ) {
"old_namespace={$this->ons} AND old_title='{$this->odt}'";
wfQuery( $sql, DB_WRITE, $fname );
- $sql = "UPDATE recentchanges SET ".
+ $sql = "UPDATE recentchanges SET ".
"rc_namespace={$this->nns}, rc_title='{$this->ndt}' WHERE ".
"rc_namespace={$this->ons} AND rc_title='{$this->odt}'";
- wfQuery( $sql, DB_WRITE, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "INSERT INTO recentchanges (rc_namespace,rc_title,
rc_comment,rc_user,rc_user_text,rc_timestamp,
rc_cur_time,rc_cur_id,rc_new)
VALUES ({$common},'{$now}',{$this->newid},1)";
- wfQuery( $sql, DB_WRITE, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
- global $wgEnablePersistentLC;
- if ( $wgEnablePersistentLC ) {
- // Purge related entries in links cache on new page, to heal broken links
- LinkCache::linksccClearBrokenLinksTo( $this->nft );
- }
+ Article::onArticleCreate( $this->nt );
$sql = "UPDATE links SET l_from='{$this->nft}' WHERE l_from='{$this->oft}'";
wfQuery( $sql, DB_WRITE, $fname );