var $mId, $mTable;
var $mForUpdate;
var $mOldId;
+ var $mRevIdFetched;
/**#@-*/
/**
$this->mTouched = '19700101000000';
$this->mForUpdate = false;
$this->mIsRedirect = false;
+ $this->mRevIdFetched = 0;
}
/**
$this->mComment = $revision->getComment();
$this->mTimestamp = wfTimestamp( TS_MW, $revision->getTimestamp() );
+ $this->mRevIdFetched = $revision->getID();
$this->mContentLoaded = true;
+
return $this->mContent;
}
function isRedirect( $text = false ) {
if ( $text === false ) {
$this->loadContent();
- $titleObj = Title::newFromRedirect( $this->mText );
+ $titleObj = Title::newFromRedirect( $this->fetchRevisionText() );
} else {
$titleObj = Title::newFromRedirect( $text );
}
$this->loadLastEdit();
return $this->mMinorEdit;
}
+
+ function getRevIdFetched() {
+ $this->loadLastEdit();
+ return $this->mRevIdFetched;
+ }
function getContributors($limit = 0, $offset = 0) {
$fname = 'Article::getContributors';
if ( !is_null( $diff ) ) {
require_once( 'DifferenceEngine.php' );
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+
$de = new DifferenceEngine( $oldid, $diff, $rcid );
+ // DifferenceEngine directly fetched the revision:
+ $this->mRevIdFetched = $de->mNewid;
$de->showDiffPage();
+
if( $diff == 0 ) {
# Run view updates for current revision only
$this->viewUpdates();
$wgOut->addWikiText( $text );
}
}
- $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+ /* title may have been set from the cache */
+ $t = $wgOut->getPageTitle();
+ if( empty( $t ) ) {
+ $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+ }
+
# If we have been passed an &rcid= parameter, we want to give the user a
# chance to mark this new article as patrolled.
if ( $wgUseRCPatrol && !is_null ( $rcid ) && $rcid != 0 && $wgUser->isLoggedIn() &&
* errors at some point.
* @private
*/
- function insertNewArticle( $text, $summary, $isminor, $watchthis ) {
+ function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false ) {
global $wgOut, $wgUser;
global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer;
$ttl = $this->mTitle->getDBkey();
$text = $this->preSaveTransform( $text );
$isminor = ( $isminor && $wgUser->isLoggedIn() ) ? 1 : 0;
+ $now = wfTimestampNow();
$dbw =& wfGetDB( DB_MASTER );
$this->updateRevisionOn( $dbw, $revision, 0 );
Article::onArticleCreate( $this->mTitle );
- RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary );
+ if(!$suppressRC) {
+ RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary );
+ }
if ($watchthis) {
if(!$this->mTitle->userIsWatching()) $this->watch();
$text = $this->preSaveTransform( $text );
$dbw =& wfGetDB( DB_MASTER );
+ $now = wfTimestampNow();
# Update article, but only if changed.
# It's important that we either rollback or complete, otherwise an attacker could
# overwrite cur entries by sending precisely timed user aborts. Random bored users
# could conceivably have the same effect, especially if cur is locked for long periods.
- if( $wgDBtransactions ) {
- $dbw->query( 'BEGIN', $fname );
- } else {
+ if( !$wgDBtransactions ) {
$userAbort = ignore_user_abort( true );
}
$oldtext = $this->getContent( true );
+ $lastRevision = 0;
if ( 0 != strcmp( $text, $oldtext ) ) {
$this->mCountAdjustment = $this->isCountable( $text )
} else {
# Update recentchanges and purge cache and whatnot
$bot = (int)($wgUser->isBot() || $forceBot);
- RecentChange::notifyEdit( $now, $this->mTitle, $me2, $wgUser, $summary,
+ RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary,
$lastRevision, $this->getTimestamp(), $bot );
Article::onArticleEdit( $this->mTitle );
}
}
- if( $wgDBtransactions ) {
- $dbw->query( 'COMMIT', $fname );
- } else {
+ if( !$wgDBtransactions ) {
ignore_user_abort( $userAbort );
}
array_push( $wgPostCommitUpdateList, $u );
}
- $this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $me2, $now, $summary, $lastRevision );
+ $this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $isminor, $now, $summary, $lastRevision );
}
return $good;
}
return array( 'edits' => $edits, 'authors' => $authors );
}
+
+ /**
+ * Return a list of templates used by this article.
+ * Uses the links table to find the templates
+ *
+ * @return array
+ */
+ function getUsedTemplates() {
+ $result = array();
+ $id = $this->mTitle->getArticleID();
+
+ $db =& wfGetDB( DB_SLAVE );
+ $page = $db->tableName( 'page' );
+ $links = $db->tableName( 'links' );
+ $sql = "SELECT page_title ".
+ "FROM $page,$links WHERE l_to=page_id AND l_from={$id} and page_namespace=".NS_TEMPLATE;
+ $res = $db->query( $sql, "Article:getUsedTemplates" );
+ if ( false !== $res ) {
+ if ( $db->numRows( $res ) ) {
+ while ( $row = $db->fetchObject( $res ) ) {
+ $result[] = $row->page_title;
+ }
+ }
+ }
+ $db->freeResult( $res );
+ return $result;
+ }
+
+
}