* @return Return the text of this revision
*/
function getContent( $noredir ) {
- global $wgRequest;
+ global $wgRequest, $wgUser;
# Get variables from query string :P
$action = $wgRequest->getText( 'action', 'view' );
$this->loadContent( $noredir );
# check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
if ( $this->mTitle->getNamespace() == NS_USER_TALK &&
- preg_match('/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/',$this->mTitle->getText()) &&
+ $wgUser->isIP($this->mTitle->getText()) &&
$action=='view'
) {
wfProfileOut( $fname );
}
}
# Should the parser cache be used?
- if ( $wgEnableParserCache && intval($wgUser->getOption( 'stubthreshold' )) == 0 && empty( $oldid ) ) {
+ if ( $wgEnableParserCache && intval($wgUser->getOption( 'stubthreshold' )) == 0 && empty( $oldid ) && $this->getID() ) {
$pcache = true;
} else {
$pcache = false;
# 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() &&
- ( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) )
+ if ( $wgUseRCPatrol
+ && !is_null($rcid)
+ && $rcid != 0
+ && $wgUser->isLoggedIn()
+ && ( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) )
{
- $wgOut->addHTML( wfMsg ( 'markaspatrolledlink',
- $sk->makeKnownLinkObj ( $this->mTitle, wfMsg ( 'markaspatrolledtext' ),
- 'action=markpatrolled&rcid='.$rcid )
- ) );
+ $wgOut->addHTML(
+ "<div class='patrollink'>" .
+ wfMsg ( 'markaspatrolledlink',
+ $sk->makeKnownLinkObj( $this->mTitle, wfMsg('markaspatrolledtext'), "action=markpatrolled&rcid=$rcid" )
+ ) .
+ '</div>'
+ );
}
# Put link titles into the link cache
/**
* Fetch and uncompress the text for a given revision.
* Can ask by rev_id number or timestamp (set $field)
+ * FIXME: This function is broken. Eliminate all uses and remove.
+ * Use Revision class in place.
*/
function fetchRevisionText( $revId = null, $field = 'rev_id' ) {
$fname = 'Article::fetchRevisionText';
function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = '', $edittime = NULL) {
$fname = 'Article::getTextOfLastEditWithSectionReplacedOrAdded';
- if( is_null( $edittime ) ) {
- $oldtext = $this->fetchRevisionText();
- } else {
- $oldtext = $this->fetchRevisionText( $edittime, 'rev_timestamp' );
- }
if ($section != '') {
+ if( is_null( $edittime ) ) {
+ $rev = Revision::newFromTitle( $this->mTitle );
+ } else {
+ $dbw =& wfGetDB( DB_MASTER );
+ $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime );
+ }
+ $oldtext = $rev->getText();
+
if($section=='new') {
if($summary) $subject="== {$summary} ==\n\n";
$text=$oldtext."\n\n".$subject.$text;
# Parse the text and replace links with placeholders
$wgOut = new OutputPage();
- $wgOut->addWikiText( $text );
+
+ # 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 );
# Look up the links in the DB and add them to the link cache
$wgOut->transformBuffer( RLH_FOR_UPDATE );
include_once( "UserMailer.php" );
$wgEnotif = new EmailNotification ();
- $wgEnotif->NotifyOnPageChange( $wgUser->getID(), $this->mTitle->getDBkey(), $this->mTitle->getNamespace(),$now, $summary, $me2, $oldid );
+ $wgEnotif->notifyOnPageChange( $this->mTitle, $now, $summary, $me2, $oldid );
}
/**
$v = new Validation ;
if ( $wgRequest->getVal ( "mode" , "" ) == "list" )
$t = $v->showList ( $this ) ;
+ else if ( $wgRequest->getVal ( "mode" , "" ) == "details" )
+ $t = $v->showDetails ( $this , $wgRequest->getVal( 'revision' ) ) ;
else
$t = $v->validatePageForm ( $this , $revision ) ;
$ns = $this->mTitle->getNamespace();
$title = $this->mTitle->getDBkey();
$revisions = $dbr->select( array( 'page', 'revision' ),
- array( 'rev_id' ),
+ array( 'rev_id', 'rev_user_text' ),
array(
'page_namespace' => $ns,
'page_title' => $title,
}
# Fetch cur_text
- $s = $dbr->selectRow( array( 'page', 'text' ),
- array( 'old_text' ),
- array(
- 'page_namespace' => $ns,
- 'page_title' => $title,
- 'page_latest = old_id'
- ), $fname, $this->getSelectOptions()
- );
-
- if( $s !== false ) {
+ $rev =& Revision::newFromTitle( $this->mTitle );
+
+ # Fetch name(s) of contributors
+ $rev_name = '';
+ $all_same_user = true;
+ while ( $row = $dbr->fetchObject( $revisions ) ) {
+ if ( $rev_name != '' && $rev_name != $row->rev_user_text ) {
+ $all_same_user = false;
+ } else {
+ $rev_name = $row->rev_user_text;
+ }
+ }
+
+ if( !is_null( $rev ) ) {
# if this is a mini-text, we can paste part of it into the deletion reason
+ $text = $rev->getText();
#if this is empty, an earlier revision may contain "useful" text
$blanked = false;
- if($s->old_text != '') {
- $text=$s->old_text;
- } else {
- if($old) { # TODO
- $text = Revision::getRevisionText( $old );
+ if($text == '') {
+ $prevId = $this->mTitle->getPreviousRevisionID( $rev->getId() );
+ $rev = Revision::newFromId( $prevId );
+ if ( $rev ) {
+ $text = $rev->getText();
$blanked = true;
}
-
}
$length=strlen($text);
$text=preg_replace('/\</','<',$text);
$text=preg_replace('/\>/','>',$text);
$text=preg_replace("/[\n\r]/",'',$text);
+
+ if( $length > 150 ) { $text .= '...'; } # we've only pasted part of the text
+
if(!$blanked) {
- $reason=wfMsg('excontent'). " '".$text;
+ if(!$all_same_user) {
+ $reason = wfMsg ( 'excontent', $text );
+ } else {
+ $reason = wfMsg ( 'excontentauthor', $text, $rev_name );
+ }
} else {
- $reason=wfMsg('exbeforeblank') . " '".$text;
+ $reason = wfMsg ( 'exbeforeblank', $text );
}
- if($length>150) { $reason .= '...'; } # we've only pasted part of the text
- $reason.="'";
}
}
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$sk = $wgUser->getSkin();
- $loglink = $sk->makeKnownLink( $wgContLang->getNsText( NS_PROJECT ) .
- ':' . wfMsgForContent( 'dellogpage' ),
+ $loglink = $sk->makeKnownLink( $wgContLang->getNsText( NS_SPECIAL ) .
+ ':Log/delete',
wfMsg( 'deletionlog' ) );
$text = wfMsg( 'deletedtext', $deleted, $loglink );
$this->mTitle->getInternalURL(),
$this->mTitle->getInternalURL( 'history' )
);
- foreach ( $linksTo as $linkTo ) {
- $urls[] = $linkTo->getInternalURL();
- }
- $u = new SquidUpdate( $urls );
+ $u = SquidUpdate::newFromTitles( $linksTo, $urls );
array_push( $wgPostCommitUpdateList, $u );
}
# Client and file cache invalidation
Title::touchArray( $linksTo );
- # Move article and history to the "archive" table
- $dbw->insertSelect( 'archive', array( 'page','revision', 'text' ),
+ // For now, shunt the revision data into the archive table.
+ // Text is *not* removed from the text table; bulk storage
+ // is left intact to avoid breaking block-compression or
+ // immutable storage schemes.
+ //
+ // For backwards compatibility, note that some older archive
+ // table entries will have ar_text and ar_flags fields still.
+ //
+ // In the future, we may keep revisions and mark them with
+ // the rev_deleted field, which is reserved for this purpose.
+ $dbw->insertSelect( 'archive', array( 'page', 'revision' ),
array(
'ar_namespace' => 'page_namespace',
'ar_title' => 'page_title',
- 'ar_text' => 'old_text',
'ar_comment' => 'rev_comment',
'ar_user' => 'rev_user',
'ar_user_text' => 'rev_user_text',
'ar_timestamp' => 'rev_timestamp',
'ar_minor_edit' => 'rev_minor_edit',
- 'ar_flags' => 'old_flags',
'ar_rev_id' => 'rev_id',
+ 'ar_text_id' => 'rev_text_id',
), array(
- 'page_namespace' => $ns,
- 'page_title' => $t,
- 'page_id = rev_page AND old_id = rev_id'
+ 'page_id' => $id,
+ 'page_id = rev_page'
), $fname
);
-
+
# Now that it's safely backed up, delete it
-
- $dbw->deleteJoin( 'text', 'revision', 'old_id', 'rev_id', array( "rev_page = {$id}" ), $fname );
$dbw->delete( 'revision', array( 'rev_page' => $id ), $fname );
$dbw->delete( 'page', array( 'page_id' => $id ), $fname);
-
+
+ # Clean up recentchanges entries...
$dbw->delete( 'recentchanges', array( 'rc_namespace' => $ns, 'rc_title' => $t ), $fname );
# Finally, clean up the link tables
Article::onArticleDelete( $this->mTitle );
- # Insert broken links
- $brokenLinks = array();
- foreach ( $linksTo as $titleObj ) {
- # Get article ID. Efficient because it was loaded into the cache by getLinksTo().
- $linkID = $titleObj->getArticleID();
- $brokenLinks[] = array( 'bl_from' => $linkID, 'bl_to' => $t );
- }
- $dbw->insert( 'brokenlinks', $brokenLinks, $fname, 'IGNORE' );
-
- # Delete live links
- $dbw->delete( 'links', array( 'l_to' => $id ) );
- $dbw->delete( 'links', array( 'l_from' => $id ) );
+ # Delete outgoing links
+ $dbw->delete( 'pagelinks', array( 'pl_from' => $id ) );
$dbw->delete( 'imagelinks', array( 'il_from' => $id ) );
- $dbw->delete( 'brokenlinks', array( 'bl_from' => $id ) );
$dbw->delete( 'categorylinks', array( 'cl_from' => $id ) );
# Log the deletion
global $wgUser;
if ($this->mTitle->getNamespace() == NS_USER_TALK &&
- $this->mTitle->getText() == $wgUser->getName()) {
+ $this->mTitle->getText() == $wgUser->getName())
+ {
require_once( 'UserTalkUpdate.php' );
$u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(), $this->mTitle->getDBkey(), false, false, false );
} else {
$shortTitle = $this->mTitle->getDBkey();
$adj = $this->mCountAdjustment;
-
if ( 0 != $id ) {
$u = new LinksUpdate( $id, $title );
array_push( $wgDeferredUpdateList, $u );
'GROUP BY hc_id');
$dbw->query("DELETE FROM $hitcounterTable");
$dbw->query('UNLOCK TABLES');
- $dbw->query("UPDATE $curTable,$acchitsTable SET cur_counter=cur_counter + hc_n ".
- 'WHERE cur_id = hc_id');
+ $dbw->query("UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n ".
+ 'WHERE page_id = hc_id');
$dbw->query("DROP TABLE $acchitsTable");
ignore_user_abort( $old_user_abort );
function onArticleCreate($title_obj) {
global $wgUseSquid, $wgPostCommitUpdateList;
- $titles = $title_obj->getBrokenLinksTo();
+ $title_obj->touchLinks();
+ $titles = $title_obj->getLinksTo();
# Purge squid
if ( $wgUseSquid ) {
}
# Clear persistent link cache
- LinkCache::linksccClearBrokenLinksTo( $title_obj->getPrefixedDBkey() );
+ LinkCache::linksccClearLinksTo( $title_obj );
}
function onArticleDelete($title_obj) {
- LinkCache::linksccClearLinksTo( $title_obj->getArticleID() );
+ $title_obj->touchLinks();
+ LinkCache::linksccClearLinksTo( $title_obj );
}
function onArticleEdit($title_obj) {
LinkCache::linksccClearPage( $title_obj->getArticleID() );
$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" );
+ $res = $db->select( array( 'pagelinks' ),
+ array( 'pl_title' ),
+ array(
+ 'pl_from' => $id,
+ 'pl_namespace' => NS_TEMPLATE ),
+ 'Article:getUsedTemplates' );
if ( false !== $res ) {
if ( $db->numRows( $res ) ) {
while ( $row = $db->fetchObject( $res ) ) {
- $result[] = $row->page_title;
+ $result[] = $row->pl_title;
}
}
}