* @return Return the text of this revision
*/
function getContent( $noredir ) {
- global $wgRequest, $wgUser;
+ global $wgRequest, $wgUser, $wgOut;
# Get variables from query string :P
$action = $wgRequest->getText( 'action', 'view' );
$section = $wgRequest->getText( 'section' );
+ $preload = $wgRequest->getText( 'preload' );
$fname = 'Article::getContent';
wfProfileIn( $fname );
if ( 0 == $this->getID() ) {
if ( 'edit' == $action ) {
wfProfileOut( $fname );
- return ''; # was "newarticletext", now moved above the box)
+
+ # If requested, preload some text.
+ $text=$this->getPreloadedText($preload);
+
+ # We used to put MediaWiki:Newarticletext here if
+ # $text was empty at this point.
+ # This is now shown above the edit box instead.
+ return $text;
}
wfProfileOut( $fname );
- return wfMsg( 'noarticletext' );
+ $wgOut->setRobotpolicy( 'noindex,nofollow' );
+
+ $ret = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' );
+ return "<div class='noarticletext'>$ret</div>";
} else {
$this->loadContent( $noredir );
# check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
if($section!='') {
if($section=='new') {
wfProfileOut( $fname );
- return '';
+ $text=$this->getPreloadedText($preload);
+ return $text;
}
# strip NOWIKI etc. to avoid confusion (true-parameter causes HTML
}
}
+ /**
+ This function accepts a title string as parameter
+ ($preload). If this string is non-empty, it attempts
+ to fetch the current revision text. It respects
+ <includeonly>.
+ */
+ function getPreloadedText($preload) {
+ if($preload) {
+ $preloadTitle=Title::newFromText($preload);
+ if(isset($preloadTitle) && $preloadTitle->userCanRead()) {
+ $rev=Revision::newFromTitle($preloadTitle);
+ if($rev) {
+ $text=$rev->getText();
+ $text=preg_replace('/<\/?includeonly>/i','',$text);
+ return $text;
+ }
+ }
+ }
+ return '';
+ }
+
/**
* This function returns the text of a section, specified by a number ($section).
* A section is text under a heading like == Heading == or <h1>Heading</h1>, or
$striparray=array();
$parser=new Parser();
$parser->mOutputType=OT_WIKI;
+ $parser->mOptions = new ParserOptions();
$striptext=$parser->strip($text, $striparray, true);
# now that we can be sure that no pseudo-sections are in the source,
}
- /**
- * Return an array of the columns of the "cur"-table
- */
- function getContentFields() {
- return $wgArticleContentFields = array(
- 'old_text','old_flags',
- 'rev_timestamp','rev_user', 'rev_user_text', 'rev_comment','page_counter',
- 'page_namespace', 'page_title', 'page_restrictions','page_touched','page_is_redirect' );
- }
-
/**
* Return the oldid of the article that is to be shown.
* For requests with a "direction", this is not the oldid of the
# Query variables :P
$oldid = $wgRequest->getVal( 'oldid' );
if ( isset( $oldid ) ) {
- $oldid = IntVal( $oldid );
+ $oldid = intval( $oldid );
if ( $wgRequest->getVal( 'direction' ) == 'next' ) {
$nextid = $this->mTitle->getNextRevisionID( $oldid );
if ( $nextid ) {
function pageDataFromId( &$dbr, $id ) {
return $this->pageData( $dbr, array(
- 'page_id' => IntVal( $id ) ) );
+ 'page_id' => intval( $id ) ) );
}
/**
return false;
}
}
- $redirData = $this->pageDataFromTitle( $dbr, $rt );
- if( $redirData ) {
- $redirRev = Revision::newFromId( $redirData->page_latest );
- if( !is_null( $redirRev ) ) {
- $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
- $this->mTitle = $rt;
- $data = $redirData;
- $this->loadPageData( $data );
- $revision = $redirRev;
+ if( $rt->getInterwiki() == '' ) {
+ $redirData = $this->pageDataFromTitle( $dbr, $rt );
+ if( $redirData ) {
+ $redirRev = Revision::newFromId( $redirData->page_latest );
+ if( !is_null( $redirRev ) ) {
+ $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
+ $this->mTitle = $rt;
+ $data = $redirData;
+ $this->loadPageData( $data );
+ $revision = $redirRev;
+ }
}
}
}
* Get the database which should be used for reads
*/
function &getDB() {
+ $ret =& wfGetDB( DB_MASTER );
+ return $ret;
#if ( $this->mForUpdate ) {
- return wfGetDB( DB_MASTER );
+ $ret =& wfGetDB( DB_MASTER );
#} else {
- # return wfGetDB( DB_SLAVE );
+ # $ret =& wfGetDB( DB_SLAVE );
#}
+ return $ret;
}
/**
function getTimestamp() {
$this->loadLastEdit();
- return $this->mTimestamp;
+ return wfTimestamp(TS_MW, $this->mTimestamp);
}
function getUser() {
* the given title.
*/
function view() {
- global $wgUser, $wgOut, $wgRequest, $wgOnlySysopsCanPatrol, $wgLang;
- global $wgLinkCache, $IP, $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol;
- global $wgEnotif, $wgParser, $wgParserCache;
+ global $wgUser, $wgOut, $wgRequest, $wgOnlySysopsCanPatrol, $wgContLang;
+ global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser;
+ global $wgParserCache, $wgUseTrackbacks;
$sk = $wgUser->getSkin();
$fname = 'Article::view';
require_once( 'DifferenceEngine.php' );
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
- $de = new DifferenceEngine( $oldid, $diff, $rcid );
+ $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid );
// DifferenceEngine directly fetched the revision:
$this->mRevIdFetched = $de->mNewid;
$de->showDiffPage();
$this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid );
$wgOut->setRobotpolicy( 'noindex,follow' );
}
+ $wasRedirected = false;
if ( '' != $this->mRedirectedFrom ) {
- $sk = $wgUser->getSkin();
- $redir = $sk->makeKnownLink( $this->mRedirectedFrom, '',
- 'redirect=no' );
- $s = wfMsg( 'redirectedfrom', $redir );
- $wgOut->setSubtitle( $s );
-
- # Can't cache redirects
- $pcache = false;
+ if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
+ $sk = $wgUser->getSkin();
+ $redir = $sk->makeKnownLink( $this->mRedirectedFrom, '', 'redirect=no' );
+ $s = wfMsg( 'redirectedfrom', $redir );
+ $wgOut->setSubtitle( $s );
+
+ // Check the parser cache again, for the target page
+ if( $pcache ) {
+ if( $wgOut->tryParserCache( $this, $wgUser ) ) {
+ $outputDone = true;
+ }
+ }
+ $wasRedirected = true;
+ }
} elseif ( !empty( $rdfrom ) ) {
global $wgRedirectSources;
if( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
$redir = $sk->makeExternalLink( $rdfrom, $rdfrom );
$s = wfMsg( 'redirectedfrom', $redir );
$wgOut->setSubtitle( $s );
+ $wasRedirected = true;
}
}
-
+ }
+ if( !$outputDone ) {
# 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 (
$wgOut->addHTML( '<pre>'.htmlspecialchars($this->mContent)."\n</pre>" );
} else if ( $rt = Title::newFromRedirect( $text ) ) {
# Display redirect
- $imageUrl = $wgStylePath.'/common/images/redirect.png';
+ $imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
+ $imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png';
+ if( !$wasRedirected ) {
+ $wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) );
+ }
$targetUrl = $rt->escapeLocalURL();
$titleText = htmlspecialchars( $rt->getPrefixedText() );
$link = $sk->makeLinkObj( $rt );
- $wgOut->addHTML( '<img valign="center" src="'.$imageUrl.'" alt="#REDIRECT" />' .
+ $wgOut->addHTML( '<img src="'.$imageUrl.'" alt="#REDIRECT" />' .
'<span class="redirectText">'.$link.'</span>' );
$parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser));
$skin = $wgUser->getSkin();
} else if ( $pcache ) {
# Display content and save to parser cache
+ $wgOut->setRevisionId( $this->getRevIdFetched() );
$wgOut->addPrimaryWikiText( $text, $this );
} else {
# Display content, don't attempt to save to parser cache
if( !$this->isCurrent() ) {
$oldEditSectionSetting = $wgOut->mParserOptions->setEditSection( false );
}
+ $wgOut->setRevisionId( $this->getRevIdFetched() );
$wgOut->addWikiText( $text );
if( !$this->isCurrent() ) {
);
}
+ # Trackbacks
+ if ($wgUseTrackbacks)
+ $this->addTrackbacks();
+
# Put link titles into the link cache
$wgOut->transformBuffer();
wfProfileOut( $fname );
}
+ function addTrackbacks() {
+ global $wgOut, $wgUser;
+
+ $dbr =& wfGetDB(DB_SLAVE);
+ $tbs = $dbr->select(
+ /* FROM */ 'trackbacks',
+ /* SELECT */ array('tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name'),
+ /* WHERE */ array('tb_page' => $this->getID())
+ );
+
+ if (!$dbr->numrows($tbs))
+ return;
+
+ $tbtext = "";
+ while ($o = $dbr->fetchObject($tbs)) {
+ $rmvtxt = "";
+ if ($wgUser->isSysop()) {
+ $delurl = $this->mTitle->getFullURL("action=deletetrackback&tbid="
+ . $o->tb_id . "&token=" . $wgUser->editToken());
+ $rmvtxt = wfMsg('trackbackremove', $delurl);
+ }
+ $tbtext .= wfMsg(strlen($o->tb_ex) ? 'trackbackexcerpt' : 'trackback',
+ $o->tb_title,
+ $o->tb_url,
+ $o->tb_ex,
+ $o->tb_name,
+ $rmvtxt);
+ }
+ $wgOut->addWikitext(wfMsg('trackbackbox', $tbtext));
+ }
+
+ function deletetrackback() {
+ global $wgUser, $wgRequest, $wgOut, $wgTitle;
+
+ if (!$wgUser->matchEditToken($wgRequest->getVal('token'))) {
+ $wgOut->addWikitext(wfMsg('sessionfailure'));
+ return;
+ }
+
+ if ((!$wgUser->isAllowed('delete'))) {
+ $wgOut->sysopRequired();
+ return;
+ }
+
+ if (wfReadOnly()) {
+ $wgOut->readOnlyPage();
+ return;
+ }
+
+ $db =& wfGetDB(DB_MASTER);
+ $db->delete('trackbacks', array('tb_id' => $wgRequest->getInt('tbid')));
+ $wgTitle->invalidateCache();
+ $wgOut->addWikiText(wfMsg('trackbackdeleteok'));
+ }
+
+ function render() {
+ global $wgOut;
+
+ $wgOut->setArticleBodyOnly(true);
+ $this->view();
+ }
+
+ function purge() {
+ global $wgUser, $wgRequest, $wgOut, $wgUseSquid;
+
+ if ( $wgUser->isLoggedIn() || $wgRequest->wasPosted() ) {
+ // Invalidate the cache
+ $this->mTitle->invalidateCache();
+
+ if ( $wgUseSquid ) {
+ // Commit the transaction before the purge is sent
+ $dbw = wfGetDB( DB_MASTER );
+ $dbw->immediateCommit();
+
+ // Send purge
+ $update = SquidUpdate::newSimplePurge( $this->mTitle );
+ $update->doUpdate();
+ }
+ $this->view();
+ } else {
+ $msg = $wgOut->parse( wfMsg( 'confirm_purge' ) );
+ $action = $this->mTitle->escapeLocalURL( 'action=purge' );
+ $button = htmlspecialchars( wfMsg( 'confirm_purge_button' ) );
+ $msg = str_replace( '$1',
+ "<form method=\"post\" action=\"$action\">\n" .
+ "<input type=\"submit\" name=\"submit\" value=\"$button\" />\n" .
+ "</form>\n", $msg );
+
+ $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+ $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->addHTML( $msg );
+ }
+ }
+
/**
* Insert a new empty page record for this article.
* This *must* be followed up by creating a revision
'page_random' => wfRandom(),
'page_touched' => $dbw->timestamp(),
'page_latest' => 0, # Fill this in shortly...
+ 'page_len' => 0, # Fill this in shortly...
), $fname );
$newid = $dbw->insertId();
# An extra check against threads stepping on each other
$conditions['page_latest'] = $lastRevision;
}
+
$text = $revision->getText();
$dbw->update( 'page',
array( /* SET */
'page_latest' => $revision->getId(),
'page_touched' => $dbw->timestamp(),
'page_is_new' => ($lastRevision === 0) ? 1 : 0,
- 'page_is_redirect' => Article::isRedirect( $text ),
+ 'page_is_redirect' => Article::isRedirect( $text ) ? 1 : 0,
'page_len' => strlen( $text ),
),
$conditions,
'page_latest=rev_id' ),
$fname );
if( $row ) {
- if( $row->rev_timestamp >= $revision->getTimestamp() ) {
+ if( wfTimestamp(TS_MW, $row->rev_timestamp) >= $revision->getTimestamp() ) {
wfProfileOut( $fname );
return false;
}
* errors at some point.
* @private
*/
- function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false ) {
- global $wgOut, $wgUser;
- global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer;
+ function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false ) {
+ global $wgOut, $wgUser, $wgUseSquid;
$fname = 'Article::insertNewArticle';
+ wfProfileIn( $fname );
+ if( !wfRunHooks( 'ArticleSave', array( &$this, &$wgUser, &$text,
+ &$summary, &$isminor, &$watchthis, NULL ) ) ) {
+ wfDebug( "$fname: ArticleSave hook aborted save!\n" );
+ wfProfileOut( $fname );
+ return false;
+ }
+
$this->mGoodAdjustment = $this->isCountable( $text );
$this->mTotalAdjustment = 1;
$ns = $this->mTitle->getNamespace();
$ttl = $this->mTitle->getDBkey();
+
+ # If this is a comment, add the summary as headline
+ if($comment && $summary!="") {
+ $text="== {$summary} ==\n\n".$text;
+ }
$text = $this->preSaveTransform( $text );
$isminor = ( $isminor && $wgUser->isLoggedIn() ) ? 1 : 0;
$now = wfTimestampNow();
$this->editUpdates( $text, $summary, $isminor, $now );
$oldid = 0; # new article
- $this->showArticle( $text, wfMsg( 'newarticle' ), false, $isminor, $now, $summary, $oldid );
+ $this->showArticle( $text, wfMsg( 'newarticle' ), false, $isminor, $now, $summary, $oldid, $revisionId );
+
+ wfRunHooks( 'ArticleSaveComplete', array( &$this, &$wgUser, $text,
+ $summary, $isminor,
+ $watchthis, NULL ) );
+ wfProfileOut( $fname );
}
function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = '', $edittime = NULL) {
- $fname = 'Article::getTextOfLastEditWithSectionReplacedOrAdded';
+ $this->replaceSection( $section, $text, $summary, $edittime );
+ }
+
+ /**
+ * @return string Complete article text, or null if error
+ */
+ function replaceSection($section, $text, $summary = '', $edittime = NULL) {
+ $fname = 'Article::replaceSection';
+ wfProfileIn( $fname );
+
if ($section != '') {
if( is_null( $edittime ) ) {
$rev = Revision::newFromTitle( $this->mTitle );
$dbw =& wfGetDB( DB_MASTER );
$rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime );
}
+ if( is_null( $rev ) ) {
+ wfDebug( "Article::replaceSection asked for bogus section (page: " .
+ $this->getId() . "; section: $section; edittime: $edittime)\n" );
+ return null;
+ }
$oldtext = $rev->getText();
if($section=='new') {
$striparray=array();
$parser=new Parser();
$parser->mOutputType=OT_WIKI;
+ $parser->mOptions = new ParserOptions();
$oldtext=$parser->strip($oldtext, $striparray, true);
# now that we can be sure that no pseudo-sections are in the source,
}
}
+ wfProfileOut( $fname );
return $text;
}
* 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;
+ global $wgOut, $wgUser, $wgDBtransactions, $wgMwRedir, $wgUseSquid;
+ global $wgPostCommitUpdateList, $wgUseFileCache;
$fname = 'Article::updateArticle';
+ wfProfileIn( $fname );
$good = true;
+ if( !wfRunHooks( 'ArticleSave', array( &$this, &$wgUser, &$text,
+ &$summary, &$minor,
+ &$watchthis, &$sectionanchor ) ) ) {
+ wfDebug( "$fname: ArticleSave hook aborted save!\n" );
+ wfProfileOut( $fname );
+ return false;
+ }
+
$isminor = ( $minor && $wgUser->isLoggedIn() );
if ( $this->isRedirect( $text ) ) {
# Remove all content but redirect
'minor_edit' => $isminor,
'text' => $text
) );
+
+ $dbw->immediateCommit();
+ $dbw->begin();
$revisionId = $revision->insertOn( $dbw );
# Update page
if( !$ok ) {
/* Belated edit conflict! Run away!! */
$good = false;
+ $dbw->rollback();
} else {
# Update recentchanges and purge cache and whatnot
$bot = (int)($wgUser->isBot() || $forceBot);
$lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
$revisionId );
Article::onArticleEdit( $this->mTitle );
+ $dbw->commit();
}
}
if ( $good ) {
if ($watchthis) {
- if (!$this->mTitle->userIsWatching()) $this->watch();
+ if (!$this->mTitle->userIsWatching()) {
+ $dbw->immediateCommit();
+ $dbw->begin();
+ $this->watch();
+ $dbw->commit();
+ }
} else {
if ( $this->mTitle->userIsWatching() ) {
+ $dbw->immediateCommit();
+ $dbw->begin();
$this->unwatch();
+ $dbw->commit();
}
}
# standard deferred updates
array_push( $wgPostCommitUpdateList, $u );
}
- $this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $isminor, $now, $summary, $lastRevision );
+ # 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',
+ array( &$this, &$wgUser, $text,
+ $summary, $minor,
+ $watchthis, $sectionanchor ) );
+ wfProfileOut( $fname );
return $good;
}
* After we've either updated or inserted the article, update
* the link tables and redirect to the new page.
*/
- function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid ) {
+ function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid, $newid ) {
global $wgUseDumbLinkUpdate, $wgAntiLockFlags, $wgOut, $wgUser, $wgLinkCache, $wgEnotif;
global $wgUseEnotif;
+ $fname = 'Article::showArticle';
+ wfProfileIn( $fname );
+
$wgLinkCache = new LinkCache();
if ( !$wgUseDumbLinkUpdate ) {
}
}
- # Parse the text and replace links with placeholders
+ # Parse the text and save it to the parser cache
$wgOut = new OutputPage();
-
- # Pass the current title along in case we're creating a wiki page
- # which is different than the currently displayed one (e.g. image
- # pages created on file uploads); otherwise, link updates will
- # go wrong.
- $wgOut->addWikiTextWithTitle( $text, $this->mTitle );
+ $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
+ $wgOut->setRevisionId( $newid );
+ $wgOut->addPrimaryWikiText( $text, $this );
if ( !$wgUseDumbLinkUpdate ) {
# Move the current links back to the second register
$wgEnotif = new EmailNotification ();
$wgEnotif->notifyOnPageChange( $this->mTitle, $now, $summary, $me2, $oldid );
}
+ wfProfileOut( $fname );
}
/**
}
return;
} else {
- $reason = htmlspecialchars( wfMsg( 'protectreason' ) );
- return $this->confirmProtect( '', $reason, $limit );
+ return $this->confirmProtect( '', '', $limit );
}
}
wfDebug( "Article::confirmProtect\n" );
- $sub = $this->mTitle->getPrefixedText();
+ $sub = htmlspecialchars( $this->mTitle->getPrefixedText() );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$check = '';
$formaction = $this->mTitle->escapeLocalURL( 'action=protect' . $par );
}
- $confirm = htmlspecialchars( wfMsg( 'confirm' ) );
+ $confirm = htmlspecialchars( wfMsg( 'protectpage' ) );
$token = htmlspecialchars( $wgUser->editToken() );
$wgOut->addHTML( "
* 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' ) );
}
# Fetch cur_text
- $rev =& Revision::newFromTitle( $this->mTitle );
+ $rev = Revision::newFromTitle( $this->mTitle );
# Fetch name(s) of contributors
$rev_name = '';
# this should not happen, since it is not possible to store an empty, new
# page. Let's insert a standard text in case it does, though
if( $length == 0 && $reason === '' ) {
- $reason = wfMsg( 'exblank' );
+ $reason = wfMsgForContent( 'exblank' );
}
if( $length < 500 && $reason === '' ) {
if( !$blanked ) {
if( !$all_same_user ) {
- $reason = wfMsg( 'excontent', $text );
+ $reason = wfMsgForContent( 'excontent', $text );
} else {
- $reason = wfMsg( 'excontentauthor', $text, $rev_name );
+ $reason = wfMsgForContent( 'excontentauthor', $text, $rev_name );
}
} else {
- $reason = wfMsg( 'exbeforeblank', $text );
+ $reason = wfMsgForContent( 'exbeforeblank', $text );
}
}
}
$formaction = $this->mTitle->escapeLocalURL( 'action=delete' . $par );
- $confirm = htmlspecialchars( wfMsg( 'confirm' ) );
+ $confirm = htmlspecialchars( wfMsg( 'deletepage' ) );
$delcom = htmlspecialchars( wfMsg( 'deletecomment' ) );
$token = htmlspecialchars( $wgUser->editToken() );
* Returns success
*/
function doDeleteArticle( $reason ) {
- global $wgUser;
- global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer, $wgPostCommitUpdateList;
+ global $wgUser, $wgUseSquid, $wgDeferredUpdateList;
+ global $wgPostCommitUpdateList, $wgUseTrackbacks;
$fname = 'Article::doDeleteArticle';
wfDebug( $fname."\n" );
$dbw->delete( 'revision', array( 'rev_page' => $id ), $fname );
$dbw->delete( 'page', array( 'page_id' => $id ), $fname);
+ if ($wgUseTrackbacks)
+ $dbw->delete( 'trackbacks', array( 'tb_page' => $id ), $fname );
+
# Clean up recentchanges entries...
$dbw->delete( 'recentchanges', array( 'rc_namespace' => $ns, 'rc_title' => $t ), $fname );
$from = str_replace( '_', ' ', $wgRequest->getVal( 'from' ) );
if( $from != $current->getUserText() ) {
- $wgOut->setPageTitle(wfmsg('rollbackfailed'));
+ $wgOut->setPageTitle( wfMsg('rollbackfailed') );
$wgOut->addWikiText( wfMsg( 'alreadyrolled',
htmlspecialchars( $this->mTitle->getPrefixedText()),
htmlspecialchars( $from ),
}
# Get the last edit not by this guy
- $user = IntVal( $current->getUser() );
+ $user = intval( $current->getUser() );
$user_text = $dbw->addQuotes( $current->getUserText() );
$s = $dbw->selectRow( 'revision',
array( 'rev_id', 'rev_timestamp' ),
);
}
- # Save it!
+ # Get the edit summary
$target = Revision::newFromId( $s->rev_id );
- $newcomment = wfMsg( '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();
* @param string $text
*/
function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange) {
- global $wgDeferredUpdateList, $wgDBname, $wgMemc;
- global $wgMessageCache, $wgUser, $wgUseEnotif;
-
- wfSeedRandom();
- if ( 0 == mt_rand( 0, 999 ) ) {
- # Periodically flush old entries from the recentchanges table.
- global $wgRCMaxAge;
- $dbw =& wfGetDB( DB_MASTER );
- $cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
- $recentchanges = $dbw->tableName( 'recentchanges' );
- $sql = "DELETE FROM $recentchanges WHERE rc_timestamp < '{$cutoff}'";
- $dbw->query( $sql );
+ global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgUseEnotif;
+
+ if ( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) {
+ wfSeedRandom();
+ if ( 0 == mt_rand( 0, 999 ) ) {
+ # Periodically flush old entries from the recentchanges table.
+ global $wgRCMaxAge;
+
+ $dbw =& wfGetDB( DB_MASTER );
+ $cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
+ $recentchanges = $dbw->tableName( 'recentchanges' );
+ $sql = "DELETE FROM $recentchanges WHERE rc_timestamp < '{$cutoff}'";
+ $dbw->query( $sql );
+ }
}
+
$id = $this->getID();
$title = $this->mTitle->getPrefixedDBkey();
$shortTitle = $this->mTitle->getDBkey();
$u = new UserTalkUpdate( 1, $this->mTitle->getNamespace(), $shortTitle, $summary,
$minoredit, $timestamp_of_pagechange);
} else {
- $other = User::newFromName($shortTitle);
- $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(1);
+ $other->saveNewtalk();
+ }
}
}
}
}
- function onArticleDelete($title_obj) {
- $title_obj->touchLinks();
+ function onArticleDelete( $title ) {
+ global $wgMessageCache;
+
+ $title->touchLinks();
+
+ if( $title->getNamespace() == NS_MEDIAWIKI) {
+ $wgMessageCache->replace( $title->getDBkey(), false );
+ }
}
function onArticleEdit($title_obj) {
* @access public
*/
function info() {
- global $wgLang, $wgOut, $wgAllowPageInfo;
+ global $wgLang, $wgOut, $wgAllowPageInfo, $wgUser;
$fname = 'Article::info';
if ( !$wgAllowPageInfo ) {
# first, see if the page exists at all.
$exists = $page->getArticleId() != 0;
if( !$exists ) {
- $wgOut->addHTML( wfMsg('noarticletext') );
+ $wgOut->addHTML( wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ) );
} else {
$dbr =& $this->getDB( DB_SLAVE );
$wl_clause = array(
$db->freeResult( $res );
return $result;
}
-
-
}
-
?>