# Try to open, return false on failure
$params = $wgKnownDBServers[$machineId];
$db = Database::newFromParams( $params['server'], $params['user'], $params['password'],
- $dbName, 1, false, true, true );
+ $dbName, 1, DBO_IGNORE );
}
}
if ( $db->isOpen() ) {
return wfMsg( 'noarticletext' );
} else {
$this->loadContent( $noredir );
-
- if(
- # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
- ( $this->mTitle->getNamespace() == Namespace::getTalk( Namespace::getUser()) ) &&
- preg_match('/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/',$this->mTitle->getText()) &&
- $action=='view'
- )
- {
+ # 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()) &&
+ $action=='view'
+ ) {
wfProfileOut( $fname );
- return $this->mContent . "\n" .wfMsg('anontalkpagetext'); }
- else {
+ return $this->mContent . "\n" .wfMsg('anontalkpagetext');
+ } else {
if($action=='edit') {
if($section!='') {
if($section=='new') {
}
return $wgArticleOldContentFields;
}
-
+
# Load the revision (including cur_text) into this object
function loadContent( $noredir = false )
{
# If we got a redirect, follow it (unless we've been told
# not to by either the function parameter or the query
- if ( ( 'no' != $redirect ) && ( false == $noredir ) &&
- ( $wgMwRedir->matchStart( $s->cur_text ) ) ) {
- if ( preg_match( '/\\[\\[([^\\]\\|]+)[\\]\\|]/',
- $s->cur_text, $m ) ) {
- $rt = Title::newFromText( $m[1] );
- if( $rt ) {
- # Gotta hand redirects to special pages differently:
- # Fill the HTTP response "Location" header and ignore
- # the rest of the page we're on.
-
- if ( $rt->getInterwiki() != '' ) {
- $wgOut->redirect( $rt->getFullURL() ) ;
- return;
- }
- if ( $rt->getNamespace() == Namespace::getSpecial() ) {
- $wgOut->redirect( $rt->getFullURL() );
- return;
- }
- $rid = $rt->getArticleID();
- if ( 0 != $rid ) {
- $redirRow = $dbr->getArray( 'cur', $this->getCurContentFields(), array( 'cur_id' => $rid ), $fname );
-
- if ( $redirRow !== false ) {
- $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
- $this->mTitle = $rt;
- $s = $redirRow;
- }
+ if ( ( 'no' != $redirect ) && ( false == $noredir ) ) {
+ $rt = Title::newFromRedirect( $s->cur_text );
+ if ( $rt ) {
+ # Gotta hand redirects to special pages differently:
+ # Fill the HTTP response "Location" header and ignore
+ # the rest of the page we're on.
+
+ if ( $rt->getInterwiki() != '' ) {
+ $wgOut->redirect( $rt->getFullURL() ) ;
+ return;
+ }
+ if ( $rt->getNamespace() == NS_SPECIAL ) {
+ $wgOut->redirect( $rt->getFullURL() );
+ return;
+ }
+ $rid = $rt->getArticleID();
+ if ( 0 != $rid ) {
+ $redirRow = $dbr->getArray( 'cur', $this->getCurContentFields(), array( 'cur_id' => $rid ), $fname );
+
+ if ( $redirRow !== false ) {
+ $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
+ $this->mTitle = $rt;
+ $s = $redirRow;
}
}
}
# If we got a redirect, follow it (unless we've been told
# not to by either the function parameter or the query
- if ( !$noredir && $wgMwRedir->matchStart( $s->cur_text ) ) {
- if ( preg_match( '/\\[\\[([^\\]\\|]+)[\\]\\|]/',
- $s->cur_text, $m ) ) {
- $rt = Title::newFromText( $m[1] );
- if( $rt && $rt->getInterwiki() == '' && $rt->getNamespace() != Namespace::getSpecial() ) {
- $rid = $rt->getArticleID();
- if ( 0 != $rid ) {
- $redirRow = $dbr->getArray( 'cur', $this->getCurContentFields(), array( 'cur_id' => $rid ), $fname );
-
- if ( $redirRow !== false ) {
- $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
- $this->mTitle = $rt;
- $s = $redirRow;
- }
+ if ( !$noredir ) {
+ $rt = Title::newFromRedirect( $s->cur_text );
+ if( $rt && $rt->getInterwiki() == '' && $rt->getNamespace() != NS_SPECIAL ) {
+ $rid = $rt->getArticleID();
+ if ( 0 != $rid ) {
+ $redirRow = $dbr->getArray( 'cur', $this->getCurContentFields(), array( 'cur_id' => $rid ), $fname );
+
+ if ( $redirRow !== false ) {
+ $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
+ $this->mTitle = $rt;
+ $s = $redirRow;
}
}
}
function view()
{
- global $wgUser, $wgOut, $wgLang, $wgRequest;
- global $wgLinkCache, $IP, $wgEnableParserCache;
+ global $wgUser, $wgOut, $wgLang, $wgRequest, $wgMwRedir;
+ global $wgLinkCache, $IP, $wgEnableParserCache, $wgStylePath;
$fname = 'Article::view';
wfProfileIn( $fname );
$de = new DifferenceEngine( intval($oldid), intval($diff) );
$de->showDiffPage();
wfProfileOut( $fname );
+ if( $diff == 0 ) {
+ # Run view updates for current revision only
+ $this->viewUpdates();
+ }
return;
}
$pcache = false;
}
- $wgLinkCache->preFill( $this->mTitle );
-
# 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 (
- $this->mTitle->getNamespace() == Namespace::getUser() &&
+ $this->mTitle->getNamespace() == NS_USER &&
preg_match('/\\/[\\w]+\\.(css|js)$/', $this->mTitle->getDBkey())
) {
$wgOut->addWikiText( wfMsg('clearyourcache'));
$wgOut->addHTML( '<pre>'.htmlspecialchars($this->mContent)."\n</pre>" );
+ } else if ( $rt = Title::newFromRedirect( $text ) ) {
+ # Display redirect
+ $sk = $wgUser->getSkin();
+ $imageUrl = "$wgStylePath/images/redirect.png";
+ $targetUrl = $rt->escapeLocalURL();
+ $titleText = htmlspecialchars( $rt->getPrefixedText() );
+ $link = $sk->makeLinkObj( $rt );
+ $wgOut->addHTML( "<img valign=\"center\" src=\"$imageUrl\">" .
+ "<span class=\"redirectText\">$link</span>" );
} else if ( $pcache ) {
+ # Display content and save to parser cache
$wgOut->addWikiText( $text, true, $this );
} else {
+ # Display content, don't attempt to save to parser cache
$wgOut->addWikiText( $text );
}
}
/* private */ function insertNewArticle( $text, $summary, $isminor, $watchthis )
{
- global $wgOut, $wgUser, $wgLinkCache, $wgMwRedir;
+ global $wgOut, $wgUser, $wgMwRedir;
global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer;
$fname = 'Article::insertNewArticle';
function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' )
{
- global $wgOut, $wgUser, $wgLinkCache;
+ global $wgOut, $wgUser;
global $wgDBtransactions, $wgMwRedir;
global $wgUseSquid, $wgInternalServer;
# Get old version of link table to allow incremental link updates
$wgLinkCache->preFill( $this->mTitle );
$wgLinkCache->clear();
-
+
+ # Switch on use of link cache in the skin
+ $sk =& $wgUser->getSkin();
+ $sk->postParseLinkColour( false );
+
# Now update the link cache by parsing the text
$wgOut = new OutputPage();
$wgOut->addWikiText( $text );
function validate ()
{
global $wgOut ;
- $v = new Validation ;
- $html = $v->validate_form ( $this->mTitle->getDBkey() ) ;
- $wgOut->setPagetitle( wfMsg( 'validate' ) . " : " . $this->mTitle->getText() );
+ $wgOut->setPagetitle( wfMsg( 'validate' ) . " : " . $this->mTitle->getPrefixedText() );
$wgOut->setRobotpolicy( 'noindex,follow' );
- $wgOut->addHTML( $html ) ;
+ if ( $this->mTitle->getNamespace() != 0 )
+ {
+ $wgOut->addHTML ( wfMsg ( 'val_validate_article_namespace_only' ) ) ;
+ return ;
+ }
+ $v = new Validation ;
+ $v->validate_form ( $this->mTitle->getDBkey() ) ;
}
# Add this page to my watchlist
$up = new UserUpdate();
array_push( $wgDeferredUpdateList, $up );
- $wgOut->returnToMain( false );
+ $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() );
}
function unwatch()
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$sk = $wgUser->getSkin();
- $loglink = $sk->makeKnownLink( $wgLang->getNsText(
- Namespace::getWikipedia() ) .
+ $loglink = $sk->makeKnownLink( $wgLang->getNsText( NS_WIKIPEDIA ) .
':' . wfMsg( 'dellogpage' ), wfMsg( 'deletionlog' ) );
$text = wfMsg( "deletedtext", $deleted, $loglink );
$linkID = $titleObj->getArticleID();
$brokenLinks[] = array( 'bl_from' => $linkID, 'bl_to' => $t );
}
- $dbw->insertArray( 'brokenlinks', $brokenLinks, $fname );
+ $dbw->insert( 'brokenlinks', $brokenLinks, $fname, 'IGNORE' );
# Delete live links
$dbw->delete( 'links', array( 'l_to' => $id ) );
$u = new SiteStatsUpdate( 1, 0, 0 );
array_push( $wgDeferredUpdateList, $u );
}
- $u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(),
- $this->mTitle->getDBkey() );
- array_push( $wgDeferredUpdateList, $u );
}
+ $u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(),
+ $this->mTitle->getDBkey() );
+ array_push( $wgDeferredUpdateList, $u );
}
# Do standard deferred updates after page edit.
and ($this->getID() != 0)
and ($wgUser->getId() == 0)
and (!$wgUser->getNewtalk())
- and ($this->mTitle->getNamespace() != Namespace::getSpecial())
+ and ($this->mTitle->getNamespace() != NS_SPECIAL )
and ($action == 'view' || empty( $action ))
and (!isset($oldid))
and (!isset($diff))
}
# Not important enough to warrant an error page in case of failure
- $oldignore = $dbw->setIgnoreErrors( true );
+ $oldignore = $dbw->ignoreErrors( true );
$dbw->query( "INSERT INTO $hitcounterTable (hc_id) VALUES ({$id})" );
$checkfreq = intval( $wgHitcounterUpdateFreq/25 + 1 );
if( (rand() % $checkfreq != 0) or ($dbw->lastErrno() != 0) ){
# Most of the time (or on SQL errors), skip row count check
- $dbw->setIgnoreErrors( $oldignore );
+ $dbw->ignoreErrors( $oldignore );
return;
}
ignore_user_abort( $old_user_abort );
wfProfileOut( 'Article::incViewCount-collect' );
}
- $dbw->setIgnoreErrors( $oldignore );
+ $dbw->ignoreErrors( $oldignore );
}
# The onArticle*() functions are supposed to be a kind of hooks