From: Tim Starling Date: Sat, 17 Jan 2004 09:49:43 +0000 (+0000) Subject: Bug fixes: watchlist and recent changes linked were broken in the last commit X-Git-Tag: 1.3.0beta1~1156 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=a12ffe0ceac97cff2f9c649ba7346a184d7e27ff;p=lhc%2Fweb%2Fwiklou.git Bug fixes: watchlist and recent changes linked were broken in the last commit --- diff --git a/includes/Article.php b/includes/Article.php index 807007f1c7..4051a5c750 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -503,7 +503,7 @@ class Article { $oldid = wfInsertID( $res ); $bot = (int)($wgUser->isBot() || $forceBot); - RecentChange::notifyEdit( $now, $this->mTitle, $me2, $wgUser, $this->getComment(), + RecentChange::notifyEdit( $now, $this->mTitle, $me2, $wgUser, $summary, $oldid, $this->getTimestamp() ); Article::onArticleEdit( $this->mTitle ); } diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index c3188c79f7..3012fe395b 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -32,12 +32,26 @@ class DifferenceEngine { $wgOut->setRobotpolicy( "noindex,follow" ); $sk = $wgUser->getSkin(); - $oldUserTitle = Title::makeTitle( NS_USER, $this->mOldUser ); - $newUserTitle = Title::makeTitle( NS_USER, $this->mNewUser ); - $oldUserLink = $sk->makeLinkObj( $oldUserTitle, $this->mOldUser ); - $newUserLink = $sk->makeLinkObj( $newUserTitle, $this->mNewUser ); - $oldHeader = "{$this->mOldtitle}
$oldUserLink"; - $newHeader = "{$this->mNewtitle}
$newUserLink"; + $talk = $wgLang->getNsText( NS_TALK ); + $contribs = wfMsg( "contribslink" ); + + $oldUserLink = $sk->makeLinkObj( Title::makeTitle( NS_USER, $this->mOldUser ), $this->mOldUser ); + $newUserLink = $sk->makeLinkObj( Title::makeTitle( NS_USER, $this->mNewUser ), $this->mNewUser ); + $oldUTLink = $sk->makeLinkObj( Title::makeTitle( NS_USER_TALK, $this->mOldUser ), $talk ); + $newUTLink = $sk->makeLinkObj( Title::makeTitle( NS_USER_TALK, $this->mNewUser ), $talk ); + $oldContribs = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, "Contributions" ), $contribs, + "target=" . urlencode($this->mOldUser) ); + $newContribs = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, "Contributions" ), $contribs, + "target=" . urlencode($this->mNewUser) ); + if ( !$this->mNewid && $wgUser->isSysop() ) { + $rollback = "   [" . $sk->makeKnownLinkObj( $wgTitle, wfMsg( "rollbacklink" ), + "action=rollback&from=" . urlencode($this->mNewUser) ) . "]"; + } else { + $rollback = ""; + } + + $oldHeader = "{$this->mOldtitle}
$oldUserLink ($oldUTLink | $oldContribs)"; + $newHeader = "{$this->mNewtitle}
$newUserLink ($newUTLink | $newContribs) $rollback"; DifferenceEngine::showDiff( $this->mOldtext, $this->mNewtext, $oldHeader, $newHeader ); diff --git a/includes/EditPage.php b/includes/EditPage.php index 72be47615d..86c3c5c561 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -167,7 +167,9 @@ class EditPage { $wpSummary = ""; } $wgOut->setRobotpolicy( "noindex,nofollow" ); - $wgOut->setArticleFlag( false ); + + # Enabled article-related sidebar, toplinks, etc. + $wgOut->setArticleRelated( true ); if ( $isConflict ) { $s = wfMsg( "editconflict", $this->mTitle->getPrefixedText() ); @@ -342,7 +344,7 @@ $wgLang->recodeForEdit( $wpTextbox1 ) . $wgOut->setPageTitle( wfMsg( "blockedtitle" ) ); $wgOut->setRobotpolicy( "noindex,nofollow" ); - $wgOut->setArticleFlag( false ); + $wgOut->setArticleRelated( false ); $id = $wgUser->blockedBy(); $reason = $wgUser->blockedFor(); @@ -364,7 +366,7 @@ $wgLang->recodeForEdit( $wpTextbox1 ) . $wgOut->setPageTitle( wfMsg( "whitelistedittitle" ) ); $wgOut->setRobotpolicy( "noindex,nofollow" ); - $wgOut->setArticleFlag( false ); + $wgOut->setArticleRelated( false ); $wgOut->addWikiText( wfMsg( "whitelistedittext" ) ); $wgOut->returnToMain( false ); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 2fb8e0f5dc..672ade15b8 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -15,6 +15,7 @@ class OutputPage { var $mOnloadHandler; var $mDoNothing; var $mContainsOldMagic, $mContainsNewMagic; + var $mIsArticleRelated; function OutputPage() { @@ -24,7 +25,7 @@ class OutputPage { $this->mLastSection = $this->mRedirect = $this->mLastModified = $this->mSubtitle = $this->mDebugtext = $this->mRobotpolicy = $this->mOnloadHandler = ""; - $this->mIsarticle = $this->mPrintable = true; + $this->mIsArticleRelated = $this->mIsarticle = $this->mPrintable = true; $this->mSupressQuickbar = $this->mDTopen = $this->mPrintable = false; $this->mLanguageLinks = array(); $this->mCategoryLinks = array() ; @@ -100,7 +101,6 @@ class OutputPage { function getPageTitle() { return $this->mPagetitle; } function setSubtitle( $str ) { $this->mSubtitle = $str; } function getSubtitle() { return $this->mSubtitle; } - function setArticleFlag( $v ) { $this->mIsarticle = $v; } function isArticle() { return $this->mIsarticle; } function setPrintable() { $this->mPrintable = true; } function isPrintable() { return $this->mPrintable; } @@ -108,6 +108,25 @@ class OutputPage { function getOnloadHandler() { return $this->mOnloadHandler; } function disable() { $this->mDoNothing = true; } + function setArticleRelated( $v ) + { + $this->mIsArticleRelated = $v; + if ( !$v ) { + $this->mIsarticle = false; + } + } + function setArticleFlag( $v ) { + $this->mIsarticle = $v; + if ( $v ) { + $this->mIsArticleRelated = $v; + } + } + + function isArticleRelated( $v ) + { + return $this->mIsArticleRelated; + } + function getLanguageLinks() { global $wgTitle, $wgLanguageCode; global $wgDBconnection, $wgDBname; @@ -375,7 +394,7 @@ class OutputPage { $this->setHTMLTitle( wfMsg( "errorpagetitle" ) ); $this->setPageTitle( wfMsg( $title ) ); $this->setRobotpolicy( "noindex,nofollow" ); - $this->setArticleFlag( false ); + $this->setArticleRelated( false ); $this->mBodytext = ""; $this->addHTML( "

" . wfMsg( $msg ) . "\n" ); @@ -392,7 +411,7 @@ class OutputPage { $this->setHTMLTitle( wfMsg( "errorpagetitle" ) ); $this->setPageTitle( wfMsg( "sysoptitle" ) ); $this->setRobotpolicy( "noindex,nofollow" ); - $this->setArticleFlag( false ); + $this->setArticleRelated( false ); $this->mBodytext = ""; $sk = $wgUser->getSkin(); @@ -408,7 +427,7 @@ class OutputPage { $this->setHTMLTitle( wfMsg( "errorpagetitle" ) ); $this->setPageTitle( wfMsg( "developertitle" ) ); $this->setRobotpolicy( "noindex,nofollow" ); - $this->setArticleFlag( false ); + $this->setArticleRelated( false ); $this->mBodytext = ""; $sk = $wgUser->getSkin(); @@ -423,7 +442,7 @@ class OutputPage { $this->setPageTitle( wfMsgNoDB( "databaseerror" ) ); $this->setRobotpolicy( "noindex,nofollow" ); - $this->setArticleFlag( false ); + $this->setArticleRelated( false ); if ( $wgCommandLineMode ) { $msg = wfMsgNoDB( "dberrortextcl" ); @@ -455,7 +474,7 @@ class OutputPage { global $wgUser, $wgReadOnlyFile; $this->setRobotpolicy( "noindex,nofollow" ); - $this->setArticleFlag( false ); + $this->setArticleRelated( false ); if( $protected ) { $this->setPageTitle( wfMsg( "viewsource" ) ); @@ -481,7 +500,7 @@ class OutputPage { { $this->setPageTitle( wfMsg( "internalerror" ) ); $this->setRobotpolicy( "noindex,nofollow" ); - $this->setArticleFlag( false ); + $this->setArticleRelated( false ); $this->mBodytext = $message; $this->output(); diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 1def0a1cae..cca1d66fed 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -31,6 +31,7 @@ class PageHistory { $wgOut->setPageTitle( $this->mTitle->getPRefixedText() ); $wgOut->setSubtitle( wfMsg( "revhistory" ) ); $wgOut->setArticleFlag( false ); + $wgOut->setArticleRelated( true ); $wgOut->setRobotpolicy( "noindex,nofollow" ); if( $this->mTitle->getArticleID() == 0 ) { diff --git a/includes/RecentChange.php b/includes/RecentChange.php index d7e8a6d979..f2138e13e7 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -42,6 +42,13 @@ class RecentChange return $rc; } + /* static */ function newFromCurRow( $row ) + { + $rc = new RecentChange; + $rc->loadFromCurRow( $row ); + return $rc; + } + # Accessors function setAttribs( $attribs ) @@ -242,6 +249,31 @@ class RecentChange $this->mExtra = array(); } + # Makes a pseudo-RC entry from a cur row, for watchlists and things + function loadFromCurRow( $row ) + { + $this->mAttribs = array( + "rc_timestamp" => $row->cur_timestamp, + "rc_cur_time" => $row->cur_timestamp, + "rc_user" => $row->cur_user, + "rc_user_text" => $row->cur_user_text, + "rc_namespace" => $row->cur_namespace, + "rc_title" => $row->cur_title, + "rc_comment" => $row->cur_comment, + "rc_minor" => !!$row->cur_minor_edit, + "rc_type" => $row->cur_is_new ? RC_NEW : RC_EDIT, + "rc_cur_id" => $row->cur_id, + 'rc_this_oldid' => 0, + 'rc_last_oldid' => 0, + 'rc_bot' => 0, + 'rc_moved_to_ns' => 0, + 'rc_moved_to_title' => '' + ); + + $this->mExtra = array(); + } + + # Gets the end part of the diff URL assoicated with this object # Blank if no diff link should be displayed function diffLinkTrail( $forceCur ) diff --git a/includes/Skin.php b/includes/Skin.php index d15272e9d1..0f324d1a8a 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -33,6 +33,14 @@ class RCCacheEntry extends RecentChange var $secureName, $link; var $curlink , $lastlink , $usertalklink , $versionlink ; var $userlink, $timestamp, $watched; + + function newFromParent( $rc ) + { + $rc2 = new RCCacheEntry; + $rc2->mAttribs = $rc->mAttribs; + $rc2->mExtra = $rc->mExtra; + return $rc2; + } } ; class Skin { @@ -408,7 +416,7 @@ class Skin { $s = $this->printableLink(); if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ; - if ( $wgOut->isArticle() ) { + if ( $wgOut->isArticleRelated() ) { if ( $wgTitle->getNamespace() == Namespace::getImage() ) { $name = $wgTitle->getDBkey(); $link = wfEscapeHTML( wfImageUrl( $name ) ); @@ -424,33 +432,34 @@ class Skin { #wfEscapeHTML( wfImageUrl( $name ) ); $style = $this->getExternalLinkAttributes( $link, $name ); $s .= " | {$name}" ; - } } - if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) { - $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(), - wfMsg( "currentrev" ) ); - } + } + } + if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) { + $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(), + wfMsg( "currentrev" ) ); + } - if ( $wgUser->getNewtalk() ) { - # do not show "You have new messages" text when we are viewing our - # own talk page - - if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 && - $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) { - $n =$wgUser->getName(); - $tl = $this->makeKnownLink( $wgLang->getNsText( - Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}", - wfMsg("newmessageslink") ); - $s.=" | ". wfMsg( "newmessages", $tl ) . ""; - } - } - if( $wgUser->isSysop() && - (($wgTitle->getArticleId() == 0) || ($action == "history")) && - ($n = $wgTitle->isDeleted() ) ) { - $s .= " | " . wfMsg( "thisisdeleted", - $this->makeKnownLink( - $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ), - wfMsg( "restorelink", $n ) ) ); + if ( $wgUser->getNewtalk() ) { + # do not show "You have new messages" text when we are viewing our + # own talk page + + if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 && + $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) { + $n =$wgUser->getName(); + $tl = $this->makeKnownLink( $wgLang->getNsText( + Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}", + wfMsg("newmessageslink") ); + $s.=" | ". wfMsg( "newmessages", $tl ) . ""; } + } + if( $wgUser->isSysop() && + (($wgTitle->getArticleId() == 0) || ($action == "history")) && + ($n = $wgTitle->isDeleted() ) ) { + $s .= " | " . wfMsg( "thisisdeleted", + $this->makeKnownLink( + $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ), + wfMsg( "restorelink", $n ) ) ); + } return $s; } @@ -588,7 +597,7 @@ class Skin { $s = $this->mainPageLink() . $sep . $this->specialLink( "recentchanges" ); - if ( $wgOut->isArticle() ) { + if ( $wgOut->isArticleRelated() ) { $s .= $sep . $this->editThisPage() . $sep . $this->historyLink(); } @@ -604,7 +613,7 @@ class Skin { $sep = " |\n"; $s = ""; - if ( $wgOut->isArticle() ) { + if ( $wgOut->isArticleRelated() ) { $s .= "" . $this->editThisPage() . ""; if ( 0 != $wgUser->getID() ) { $s .= $sep . $this->watchThisPage(); @@ -768,8 +777,7 @@ class Skin { unwatched. Therefore we do not show the "Watch this page" link in edit mode */ if ( 0 != $wgUser->getID() && $articleExists) { - if($action!="edit" && $action!="history" && - $action != "submit" ) + if($action!="edit" && $action != "submit" ) { $s .= $sep . $this->watchThisPage(); } @@ -786,7 +794,7 @@ class Skin { } $s.=$sep . $this->whatLinksHere(); - if($wgOut->isArticle()) { + if($wgOut->isArticleRelated()) { $s .= $sep . $this->watchPageLinksLink(); } @@ -907,7 +915,7 @@ class Skin { { global $wgOut, $wgTitle, $oldid, $redirect, $diff; - if ( ! $wgOut->isArticle() || $diff ) { + if ( ! $wgOut->isArticleRelated() ) { $s = wfMsg( "protectedpage" ); } else { $n = $wgTitle->getPrefixedText(); @@ -968,7 +976,7 @@ class Skin { { global $wgUser, $wgOut, $wgTitle, $diff; - if ( $wgOut->isArticle() && ( ! $diff ) ) { + if ( $wgOut->isArticleRelated() ) { $n = $wgTitle->getPrefixedText(); if ( $wgTitle->userIsWatching() ) { @@ -1036,7 +1044,7 @@ class Skin { { global $wgOut, $wgTitle, $wgLang; - if ( ! $wgOut->isArticle() ) { + if ( ! $wgOut->isArticleRelated() ) { $s = "(" . wfMsg( "notanarticle" ) . ")"; } else { $s = $this->makeKnownLink( $wgLang->specialPage( @@ -1871,24 +1879,23 @@ class Skin { # Called in a loop over all displayed RC entries # Either returns the line, or caches it for later use - function recentChangesLine( $row, $watched = false ) + function recentChangesLine( &$rc, $watched = false ) { global $wgUser ; $usenew = $wgUser->getOption( "usenewrc" ); if ( $usenew ) - $line = $this->recentChangesLineNew ( $row, $watched ) ; + $line = $this->recentChangesLineNew ( $rc, $watched ) ; else - $line = $this->recentChangesLineOld ( $row, $watched ) ; + $line = $this->recentChangesLineOld ( $rc, $watched ) ; return $line ; } - function recentChangesLineOld( $row, $watched = false ) + function recentChangesLineOld( &$rc, $watched = false ) { global $wgTitle, $wgLang, $wgUser; # Extract DB fields into local scope - extract( get_object_vars( $row ) ); - $rc = RecentChange::newFromRow( $row ); + extract( $rc->mAttribs ); $curIdEq = "curid=" . $rc_cur_id; # Make date header if necessary @@ -1986,13 +1993,12 @@ class Skin { } # function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 ) - function recentChangesLineNew( $row, $watched = false ) + function recentChangesLineNew( &$baseRC, $watched = false ) { global $wgTitle, $wgLang, $wgUser; - # Fill $rc with all the information from the row - $rc = new RCCacheEntry ; - $rc->loadFromRow( $row ); + # Create a specialised object + $rc = RCCacheEntry::newFromParent( $baseRC ) ; # Extract fields from DB into the function scope (rc_xxxx variables) extract( $rc->mAttribs ); diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index f7753551ba..c38bf633ff 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -111,7 +111,8 @@ function wfSpecialRecentchanges( $par ) break; } if ( ! ( $hideminor && $obj1->rc_minor ) ) { - $s .= $sk->recentChangesLine( $obj1, $obj1->wl_user ); + $rc = RecentChange::newFromRow( $obj1 ); + $s .= $sk->recentChangesLine( $rc, $obj1->wl_user ); --$limit; } $obj1 = wfFetchObject( $res ); diff --git a/includes/SpecialRecentchangeslinked.php b/includes/SpecialRecentchangeslinked.php index b2c568e462..59d2e36066 100644 --- a/includes/SpecialRecentchangeslinked.php +++ b/includes/SpecialRecentchangeslinked.php @@ -66,16 +66,8 @@ function wfSpecialRecentchangeslinked( $par = NULL ) $obj = wfFetchObject( $res ); --$count; - $ts = $obj->cur_timestamp; - $u = $obj->cur_user; - $ut = $obj->cur_user_text; - $ns = $obj->cur_namespace; - $ttl = $obj->cur_title; - $com = $obj->cur_comment; - $me = ( $obj->cur_minor_edit > 0 ); - $new = ( $obj->cur_is_new > 0 ); - - $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl, $com, $me, $new ); + $rc = RecentChange::newFromCurRow( $obj ); + $s .= $sk->recentChangesLine( $rc ); --$limit; } $s .= $sk->endRecentChangesList(); diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index d45734834f..136cb3f69b 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -123,7 +123,7 @@ function wfSpecialWatchlist() $sql = "SELECT - cur_namespace,cur_title,cur_comment, + cur_namespace,cur_title,cur_comment, cur_id cur_user,cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM watchlist,cur USE INDEX ($x) WHERE wl_user=$uid @@ -154,17 +154,9 @@ function wfSpecialWatchlist() $s = $sk->beginRecentChangesList(); while ( $obj = wfFetchObject( $res ) ) { - $ts = $obj->cur_timestamp; - $u = $obj->cur_user; - $ut = $obj->cur_user_text; - $ns = $obj->cur_namespace; - $ttl = $obj->cur_title; - $com = $obj->cur_comment; - $me = ( $obj->cur_minor_edit > 0 ); - $new = ( $obj->cur_is_new > 0 ); - $watched = true; - - $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl, $com, $me, $new, $watched ); + # Make fake RC entry + $rc = RecentChange::newFromCurRow( $obj ); + $s .= $sk->recentChangesLine( $rc, true ); } $s .= $sk->endRecentChangesList();