* @access private
*/
function pageData( &$dbr, $conditions ) {
- return $dbr->selectRow( 'page',
- array(
+ $fields = array(
'page_id',
'page_namespace',
'page_title',
'page_random',
'page_touched',
'page_latest',
- 'page_len' ),
+ 'page_len' ) ;
+ wfRunHooks( 'ArticlePageDataBefore', array( &$this , &$fields ) ) ;
+ $row = $dbr->selectRow( 'page',
+ $fields,
$conditions,
'Article::pageData' );
+ wfRunHooks( 'ArticlePageDataAfter', array( &$this , &$row ) ) ;
+ return $row ;
}
function pageDataFromTitle( &$dbr, $title ) {
* the given title.
*/
function view() {
- global $wgUser, $wgOut, $wgRequest, $wgOnlySysopsCanPatrol, $wgLang, $wgContLang;
- global $wgLinkCache, $IP, $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol;
- global $wgEnotif, $wgParser, $wgParserCache, $wgUseTrackbacks;
+ global $wgUser, $wgOut, $wgRequest, $wgOnlySysopsCanPatrol, $wgContLang;
+ global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser;
+ global $wgParserCache, $wgUseTrackbacks;
$sk = $wgUser->getSkin();
$fname = 'Article::view';
}
}
if( !$outputDone ) {
+ wfRunHooks( 'ArticleViewHeader', array( &$this ) ) ;
# wrap user css and user js in pre and don't parse
# XXX: use $this->mTitle->usCssJsSubpage() when php is fixed/ a workaround is found
if (
if ($wgUseTrackbacks)
$this->addTrackbacks();
- # Put link titles into the link cache
- $wgOut->transformBuffer();
-
# Add link titles as META keywords
$wgOut->addMetaTags() ;
* @private
*/
function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false ) {
- global $wgOut, $wgUser;
- global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer;
+ global $wgOut, $wgUser, $wgUseSquid;
$fname = 'Article::insertNewArticle';
wfProfileIn( $fname );
* first set $wgUser, and clean up $wgDeferredUpdates after each edit.
*/
function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) {
- global $wgOut, $wgUser;
- global $wgDBtransactions, $wgMwRedir;
- global $wgUseSquid, $wgInternalServer, $wgPostCommitUpdateList, $wgUseFileCache;
+ global $wgOut, $wgUser, $wgDBtransactions, $wgMwRedir, $wgUseSquid;
+ global $wgPostCommitUpdateList, $wgUseFileCache;
$fname = 'Article::updateArticle';
wfProfileIn( $fname );
$oldsize = strlen( $oldtext );
$newsize = strlen( $text );
$lastRevision = 0;
+ $revisionId = 0;
if ( 0 != strcmp( $text, $oldtext ) ) {
$this->mGoodAdjustment = $this->isCountable( $text )
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 );
}
}
$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',
* the link tables and redirect to the new page.
*/
function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid, $newid ) {
- global $wgUseDumbLinkUpdate, $wgAntiLockFlags, $wgOut, $wgUser, $wgLinkCache, $wgEnotif;
+ global $wgUseDumbLinkUpdate, $wgAntiLockFlags, $wgOut, $wgUser, $wgLinkCache;
global $wgUseEnotif;
$fname = 'Article::showArticle';
else
$r = '';
$wgOut->redirect( $this->mTitle->getFullURL( $r ).$sectionanchor );
-
- if ( $wgUseEnotif ) {
- # this would be better as an extension hook
- include_once( "UserMailer.php" );
- $wgEnotif = new EmailNotification ();
- $wgEnotif->notifyOnPageChange( $this->mTitle, $now, $summary, $me2, $oldid );
- }
+
wfProfileOut( $fname );
}
* UI entry point for page deletion
*/
function delete() {
- global $wgUser, $wgOut, $wgMessageCache, $wgRequest;
+ global $wgUser, $wgOut, $wgRequest;
$fname = 'Article::delete';
$confirm = $wgRequest->wasPosted() &&
$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
* Returns success
*/
function doDeleteArticle( $reason ) {
- global $wgUser;
- global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer, $wgPostCommitUpdateList;
- global $wgUseTrackbacks;
+ global $wgUser, $wgUseSquid, $wgDeferredUpdateList;
+ global $wgPostCommitUpdateList, $wgUseTrackbacks;
$fname = 'Article::doDeleteArticle';
wfDebug( $fname."\n" );
);
}
- # Save it!
+ # Get the edit summary
$target = Revision::newFromId( $s->rev_id );
- $newcomment = wfMsgForContent( 'revertpage', $target->getUserText(), $from );
+ $newComment = wfMsgForContent( 'revertpage', $target->getUserText(), $from );
+ $newComment = $wgRequest->getText( 'summary', $newComment );
+ # Save it!
$wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
- $wgOut->addHTML( '<h2>' . htmlspecialchars( $newcomment ) . "</h2>\n<hr />\n" );
+ $wgOut->addHTML( '<h2>' . htmlspecialchars( $newComment ) . "</h2>\n<hr />\n" );
- $this->updateArticle( $target->getText(), $newcomment, 1, $this->mTitle->userIsWatching(), $bot );
+ $this->updateArticle( $target->getText(), $newComment, 1, $this->mTitle->userIsWatching(), $bot );
Article::onArticleEdit( $this->mTitle );
$dbw->commit();
* @private
*/
function viewUpdates() {
- global $wgDeferredUpdateList, $wgUseEnotif;
+ global $wgDeferredUpdateList;
if ( 0 != $this->getID() ) {
global $wgDisableCounters;
}
}
- # Update newtalk status if user is reading their own
- # talk page
-
+ # Update newtalk / watchlist notification status
global $wgUser;
- if ($this->mTitle->getNamespace() == NS_USER_TALK &&
- $this->mTitle->getText() == $wgUser->getName())
- {
- if ( $wgUseEnotif ) {
- require_once( 'UserTalkUpdate.php' );
- $u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(), $this->mTitle->getDBkey(), false, false, false );
- } else {
- $wgUser->setNewtalk(0);
- $wgUser->saveNewtalk();
- }
- } elseif ( $wgUseEnotif ) {
- $wgUser->clearNotification( $this->mTitle );
- }
-
+ $wgUser->clearNotification( $this->mTitle );
}
/**
* @param string $text
*/
function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange) {
- global $wgDeferredUpdateList, $wgDBname, $wgMemc;
- global $wgMessageCache, $wgUser, $wgUseEnotif;
+ global $wgDeferredUpdateList, $wgMessageCache, $wgUser;
- if ( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', &$this ) ) {
+ if ( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) {
wfSeedRandom();
if ( 0 == mt_rand( 0, 999 ) ) {
# Periodically flush old entries from the recentchanges table.
# If this is another user's talk page, update newtalk
if ($this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getName()) {
- if ( $wgUseEnotif ) {
- require_once( 'UserTalkUpdate.php' );
- $u = new UserTalkUpdate( 1, $this->mTitle->getNamespace(), $shortTitle, $summary,
- $minoredit, $timestamp_of_pagechange);
- } else {
- $other = User::newFromName( $shortTitle );
- if( is_null( $other ) && User::isIP( $shortTitle ) ) {
- // An anonymous user
- $other = new User();
- $other->setName( $shortTitle );
- }
- if( $other ) {
- $other->setNewtalk(1);
- $other->saveNewtalk();
- }
+ $other = User::newFromName( $shortTitle );
+ if( is_null( $other ) && User::isIP( $shortTitle ) ) {
+ // An anonymous user
+ $other = new User();
+ $other->setName( $shortTitle );
+ }
+ if( $other ) {
+ $other->setNewtalk( true );
}
}
}
}
- 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() );
+ }
}
/**#@-*/