Wikia code/includes/Article.php
Appearance
< Wikia code | includes
This page is obsolete. It is being retained for archival purposes. It may document extensions or features that are obsolete and/or no longer supported. Do not rely on the information here being up-to-date. The information shown below refers to the now unmaintained 1.16 MediaWiki release. The current stable release number is 1.43.0. |
--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\Article.php 2011-07-18 22:31:28.003906300 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\Article.php 2011-08-17 15:28:46.365234400 +0100
@@ -642,7 +642,20 @@
$id = $this->getID();
if ( 0 == $id ) return;
+ // wikia change start, cache last revision of article, where we have expiration?
+ if( !empty( $this->mLatest ) ) {
+ global $wgMemc;
+ $key = wfMemcKey( 'art', $this->mLatest );
+ $this->mLastRevision = $wgMemc->get( $key );
+ }
+ if( empty( $this->mLastRevision ) ) {
$this->mLastRevision = Revision::loadFromPageId( wfGetDB( DB_MASTER ), $id );
+ if( !empty( $key ) ) {
+ $wgMemc->set( $key, $this->mLastRevision, 60*60*24 );
+ }
+ }
+
+ // wikia change end
if ( !is_null( $this->mLastRevision ) ) {
$this->mUser = $this->mLastRevision->getUser();
$this->mUserText = $this->mLastRevision->getUserText();
@@ -833,7 +846,9 @@
case 3:
$text = $this->getContent();
- if ( $text === false || $this->getID() == 0 ) {
+ $fakeReturn404 = false;
+ if ( ($text === false || $this->getID() == 0)
+ && wfRunHooks( 'ArticleNonExistentPage', array( $this, $wgOut, &$text, &$fakeReturn404 ) ) ) {
wfDebug( __METHOD__ . ": showing missing article\n" );
$this->showMissingArticle();
wfProfileOut( __METHOD__ );
@@ -1110,10 +1125,17 @@
// This is an internally redirected page view.
// We'll need a backlink to the source page for navigation.
if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
+ // wikia change
+ global $wgWikiaUseNoFollow;
+ $redirAttribs = array();
+ if( !empty( $wgWikiaUseNoFollow ) ) {
+ $redirAttribs['rel'] = 'nofollow';
+ }
+
$redir = $sk->link(
$this->mRedirectedFrom,
null,
- array(),
+ $redirAttribs,
array( 'redirect' => 'no' ),
array( 'known', 'noclasses' )
);
@@ -1126,10 +1149,19 @@
$wgOut->addInlineScript( "redirectToFragment(\"$fragment\");" );
}
+ /*
+ * Commented out by christian@wikia-inc.com
+ * /extensions/wikia/CanonicalHref is used by Wikia to handle redirects and all of these cases:
+ * http://muppet.wikia.com/wiki/Kermit_the_Frog
+ * http://muppet.wikia.com/index.php/Kermit_the_Frog
+ * http://muppet.wikia.com/index.php?title=Kermit_the_Frog
+ * http://muppet.wikia.com/wiki/Kermit_the_Frog?action=view
+ *
// Add a <link rel="canonical"> tag
$wgOut->addLink( array( 'rel' => 'canonical',
'href' => $this->mTitle->getLocalURL() )
);
+ */
return true;
}
} elseif ( $rdfrom ) {
@@ -1345,7 +1377,13 @@
# Don't show section-edit links on old revisions... this way lies madness.
$parserOptions->setEditSection( $this->isCurrent() );
$useParserCache = $this->useParserCache( $oldid );
- $this->outputWikiText( $this->getContent(), $useParserCache, $parserOptions );
+ /* Wikia change begin - @author: wladek */
+ $content = $this->getContent();
+ if ($this->getID() == 0) {
+ wfRunHooks('Article::view:not-existing', array( $this, &$content ) );
+ }
+ $this->outputWikiText( $content, $useParserCache, $parserOptions );
+ /* Wikia change end */
}
/**
@@ -1408,6 +1446,12 @@
$imageUrl2 = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
$alt2 = $wgContLang->isRTL()Â ? '←'Â : '→'; // should -> and <- be used instead of entities?
+ // Wikia change - overwrite imageUrl with $wgRedirectIconUrl
+ global $wgRedirectIconUrl;
+ if( !empty( $wgRedirectIconUrl ) ) {
+ $imageUrl = $wgRedirectIconUrl;
+ }
+
if ( $appendSubtitle ) {
$wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) );
}
@@ -1441,9 +1485,10 @@
. $sk->link( $rt, htmlspecialchars( $rt->getFullText() ) );
}
}
- return '<img src="' . $imageUrl . '" alt="#REDIRECT " />' .
- '<span class="redirectText">' . $link . '</span>';
-
+ return '<div class="redirectMsg">' .
+ '<img src="' . $imageUrl . '" alt="#REDIRECT " />' .
+ '<span class="redirectText">' . $link . '</span>' .
+ '</div>';
}
public function addTrackbacks() {
@@ -2190,6 +2235,7 @@
*/
public function watch() {
global $wgUser, $wgOut;
+ global $wgEnableWikiaFollowedPages;
if ( $wgUser->isAnon() ) {
$wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
return;
@@ -2199,6 +2245,9 @@
return;
}
if ( $this->doWatch() ) {
+ if ( $wgEnableWikiaFollowedPages ) {
+ $wgOut->redirect( $this->mTitle->getFullUrl( "action=view" ) );
+ }
$wgOut->setPagetitle( wfMsg( 'addedwatch' ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->addWikiMsg( 'addedwatchtext', $this->mTitle->getPrefixedText() );
@@ -2227,6 +2276,8 @@
*/
public function unwatch() {
global $wgUser, $wgOut;
+ global $wgEnableWikiaFollowedPages;
+
if ( $wgUser->isAnon() ) {
$wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
return;
@@ -2236,6 +2287,9 @@
return;
}
if ( $this->doUnwatch() ) {
+ if ( $wgEnableWikiaFollowedPages ) {
+ $wgOut->redirect( $this->mTitle->getFullUrl( "action=view" ) );
+ }
$wgOut->setPagetitle( wfMsg( 'removedwatch' ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->addWikiMsg( 'removedwatchtext', $this->mTitle->getPrefixedText() );
@@ -2411,6 +2465,8 @@
# Insert a null revision
$nullRevision = Revision::newNullRevision( $dbw, $id, $editComment, true );
+
+ if( $nullRevision instanceof Revision ) {
$nullRevId = $nullRevision->insertOn( $dbw );
$latest = $this->getLatest();
@@ -2436,6 +2492,10 @@
} else {
$log->addEntry( 'unprotect', $this->mTitle, $reason );
}
+ } else {
+ wfDebug( "updateRestrictions failed: page supposed to be protected does not exist anymore (ID: $id) \n" );
+ return false;
+ }
} # End hook
} # End "changed" check
@@ -3132,6 +3192,11 @@
}
}
+ /* Wikia change begin - @author: Macbre */
+ /* MyHome: store ID of the rollbacked revision */
+ Wikia::setVar('RollbackedRevId', $target->getNext()->getId());
+ /* Wikia change end */
+
# Allow the custom summary to use the same args as the default message
$args = array(
$target->getUserText(), $from, $s->rev_id,
@@ -3259,6 +3324,9 @@
}
# Update newtalk / watchlist notification status
$wgUser->clearNotification( $this->mTitle );
+ // wikia changes begin
+ wfRunHooks( 'AfterViewUpdates', array( $this ) );
+ // wikia changes end
}
/**
@@ -3963,6 +4031,9 @@
$ot = Title::newFromRedirect( $oldtext );
$rt = Title::newFromRedirect( $newtext );
if ( is_object( $rt ) && ( !is_object( $ot ) ||Â !$rt->equals( $ot ) || $ot->getFragment()Â != $rt->getFragment() ) ) {
+ // wikia changes begin
+ Wikia::setVar( 'AutoSummaryType', 'autoredircomment' );
+ // wikia changes end
return wfMsgForContent( 'autoredircomment', $rt->getFullText() );
}
@@ -3973,11 +4044,13 @@
$truncatedtext = $wgContLang->truncate(
str_replace( "\n", ' ', $newtext ),
max( 0, 200 - strlen( wfMsgForContent( 'autosumm-new' ) ) ) );
+ Wikia::setVar( 'AutoSummaryType', 'autosumm-new' );
return wfMsgForContent( 'autosumm-new', $truncatedtext );
}
# Blanking autosummaries
if ( $oldtext != '' && $newtext == '' ) {
+ Wikia::setVar( 'AutoSummaryType', 'autosumm-blank' );
return wfMsgForContent( 'autosumm-blank' );
} elseif ( strlen( $oldtext ) > 10 * strlen( $newtext ) && strlen( $newtext ) < 500 ) {
# Removing more than 90% of the article
@@ -3985,6 +4058,7 @@
$truncatedtext = $wgContLang->truncate(
$newtext,
max( 0, 200 - strlen( wfMsgForContent( 'autosumm-replace' ) ) ) );
+ Wikia::setVar( 'AutoSummaryType', 'autosumm-replace' );
return wfMsgForContent( 'autosumm-replace', $truncatedtext );
}
@@ -4114,6 +4188,18 @@
* @return null
*/
public function updateCategoryCounts( $added, $deleted ) {
+ /* Wikia change begin - @author: wladek */
+ global $wgSkipCountForCategories;
+
+ /* Used by CategoryService */
+ wfRunHooks( 'ArticleUpdateCategoryCounts', array( &$this, $added, $deleted ));
+
+ if( is_array( $wgSkipCountForCategories ) ) {
+ $added = array_diff( $added, $wgSkipCountForCategories );
+ $deleted = array_diff( $deleted, $wgSkipCountForCategories );
+ }
+ /* Wikia change end */
+
$ns = $this->mTitle->getNamespace();
$dbw = wfGetDB( DB_MASTER );