Wikia code/includes/Title.php
< 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\Title.php 2011-07-18 22:31:28.209961000 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\Title.php 2011-08-17 15:28:46.568359400 +0100
@@ -821,7 +821,15 @@
if ( $query == '-' ) {
$query = '';
}
+ /* Wikia change begin - @author: Marooned */
+ /* Output nicer URLs with query */
+ global $wgPrettyUrlWithTitleAndQuery;
+ if (empty($wgPrettyUrlWithTitleAndQuery)) {
$url = "{$wgScript}?title={$dbkey}&{$query}";
+ } else {
+ $url = wfAppendQuery(str_replace( '$1', $dbkey, $wgArticlePath ), $query);
+ }
+ /* Wikia change end */
}
}
@@ -1180,6 +1188,15 @@
$errors[] = array( 'movenotallowedfile' );
}
+
+ /* Wikia change begin - @author: uberfuzzy */
+ // Check if uploading disabled or not enabled (wikia #36880)
+ global $wgDisableUploads, $wgEnableUploads;
+ if( $this->getNamespace() == NS_FILE && ($wgDisableUploads || !$wgEnableUploads) ) {
+ $errors[] = array( 'movenotallowedfile' );
+ }
+ /* Wikia change end */
+
if( !$user->isAllowed( 'move' ) ) {
// User can't move anything
global $wgGroupPermissions;
@@ -1214,6 +1231,11 @@
// Show user page-specific message only if the user can move other pages
$errors[] = array( 'cant-move-to-user-page' );
}
+ } elseif( $action == 'edit' ) {
+ if( !$user->isAllowed( 'edit' ) ) {
+ global $wgTitle;
+ $errors[] = $user->isAnon() ? array( 'editnologintext', wfGetReturntoParam() ) : array( 'editnotallowed' );
+ }
} elseif( !$user->isAllowed( $action ) ) {
$return = null;
@@ -1280,7 +1302,8 @@
# Only 'createaccount' and 'execute' can be performed on
# special pages, which don't actually exist in the DB.
$specialOKActions = array( 'createaccount', 'execute' );
- if( NS_SPECIAL == $this->mNamespace && !in_array( $action, $specialOKActions) ) {
+ // #3628 and #3633 fix, 29.10.2008 by Bartek, always allow for Special:Createpage to create a page
+ if( (NS_SPECIAL == $this->mNamespace && !in_array( $action, $specialOKActions)) && ('Createpage' != $this->getText()) && ('create' != $action) ) {
$errors[] = array('ns-specialprotected');
}
@@ -1562,13 +1585,20 @@
} else {
global $wgWhitelistRead;
+ /* Wikia change begin - @author: Uberfuzzy */
+ /* whitelist Special:Signup by default also - RT #47547 */
+ /* whitelist Special:Captcha by default also - RT #47710 */
/**
* Always grant access to the login page.
* Even anons need to be able to log in.
*/
- if( $this->isSpecial( 'Userlogin' ) || $this->isSpecial( 'Resetpass' ) ) {
+ if( $this->isSpecial( 'Userlogin' ) ||
+ $this->isSpecial( 'Resetpass' ) ||
+ $this->isSpecial( 'Signup' ) ||
+ $this->isSpecial( 'Captcha' ) ) {
return true;
}
+ /* Wikia change end */
/**
* Bail out if there isn't whitelist
@@ -1661,14 +1691,15 @@
/**
* Get all subpages of this page.
* @param $limit Maximum number of subpages to fetch; -1 for no limit
+ * @param $db index of the connection to get (** Wikia change **)
* @return mixed TitleArray, or empty array if this page's namespace
* doesn't allow subpages
*/
- public function getSubpages( $limit = -1 ) {
+ public function getSubpages( $limit = -1, $db = DB_SLAVE ) {
if( !MWNamespace::hasSubpages( $this->getNamespace() ) )
return array();
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( $db );
$conds['page_namespace'] = $this->getNamespace();
$conds[] = 'page_title ' . $dbr->buildLike( $this->getDBkey() . '/', $dbr->anyString() );
$options = array();
@@ -2000,6 +2031,9 @@
* Purge expired restrictions from the page_restrictions table
*/
static function purgeExpiredRestrictions() {
+ if( wfReadOnly() ) {
+ return;
+ }
$dbw = wfGetDB( DB_MASTER );
$dbw->delete( 'page_restrictions',
array( 'pr_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ),
@@ -2184,6 +2218,7 @@
* @return \type{\bool} true if the update succeded
*/
public function invalidateCache() {
+ global $wgMemc;
if( wfReadOnly() ) {
return;
}
@@ -2187,12 +2222,18 @@
if( wfReadOnly() ) {
return;
}
+
$dbw = wfGetDB( DB_MASTER );
+ $ts = $dbw->timestamp();
$success = $dbw->update( 'page',
array( 'page_touched' => $dbw->timestamp() ),
$this->pageCond(),
__METHOD__
);
+
+ $key = wfMemcKey("page_touched",implode("_", $this->pageCond()));
+ $wgMemc->set( $key, $ts, 60 );
+
HTMLFileCache::clearFileCache( $this );
return $success;
}
@@ -2600,7 +2641,6 @@
$urls = array(
$this->getInternalURL(),
- $this->getInternalURL( 'action=history' )
);
// purge variant urls as well
@@ -2611,6 +2651,46 @@
}
}
+ // if this is a site css or js purge it as well
+ global $wgUseSiteJs, $wgUseSiteCss, $wgAllowUserJs;
+ global $wgSquidMaxage, $wgJsMimeType;
+ if( $wgUseSiteCss && $this->getNamespace() == NS_MEDIAWIKI ) {
+ global $wgServer;
+ $urls[] = $wgServer.'/__am/';
+ $urls[] = $wgServer.'/__wikia_combined/';
+ $query = array(
+ 'usemsgcache' => 'yes',
+ 'ctype' => 'text/css',
+ 'smaxage' => $wgSquidMaxage,
+ 'action' => 'raw',
+ 'maxage' => $wgSquidMaxage,
+ );
+ if( $this->getText() == 'Common.css' ) {
+ $urls[] = $this->getInternalURL( $query );
+ } elseif( $this->getText() == 'Wikia.css' ) {
+ $urls[] = $this->getInternalURL( $query );
+ } else {
+ foreach( Skin::getSkinNames() as $skinkey => $skinname ) {
+ if( $this->getText() == ucfirst($skinkey).'.css' ) {
+ $urls[] = str_replace('text%2Fcss', 'text/css', $this->getInternalURL( $query )); // For Artur
+ $urls[] = $this->getInternalURL( $query ); // For Artur
+ break;
+ } elseif ( $wgUseSiteJs && $this->getText() == 'Common.js' ) {
+ $urls[] = Skin::makeUrl('-', "action=raw&gen=js&useskin=" .urlencode( $skinkey ) );
+ }
+ }
+ }
+ } elseif( $wgAllowUserJs && $this->isValidCssJsSubpage() ) {
+ if( $this->isJsSubpage() ) {
+ $urls[] = $this->getInternalURL( 'action=raw&ctype='.$wgJsMimeType );
+ } elseif( $this->isCssSubpage() ) {
+ $urls[] = $this->getInternalURL( 'action=raw&ctype=text/css' );
+ }
+ }
+
+ // purge Special:RecentChanges too
+ $urls[] = SpecialPage::getTitleFor('RecentChanges')->getInternalURL();
+
return $urls;
}
@@ -3384,8 +3464,11 @@
*
* @return bool
*/
- public function isNewPage() {
- $dbr = wfGetDB( DB_SLAVE );
+ /* Wikia change begin - @author: Marooned */
+ /* add possibility to use master - used in ArticleComments */
+ public function isNewPage( $flags=0 ) {
+ $dbr = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
+ /* Wikia change end */
return (bool)$dbr->selectField( 'page', 'page_is_new', $this->pageCond(), __METHOD__ );
}
@@ -3555,6 +3638,7 @@
public function getTouched( $db = null ) {
$db = isset($db) ? $db : wfGetDB( DB_SLAVE );
$touched = $db->selectField( 'page', 'page_touched', $this->pageCond(), __METHOD__ );
+ echo $touched;
return $touched;
}