Go to the documentation of this file.
202 return MediaWikiServices::getInstance()->getTitleFormatter();
214 return MediaWikiServices::getInstance()->getInterwikiLookup();
233 $t->mDbkeyform = $key;
236 $t->secureAndSplit();
270 if ( $linkTarget instanceof
Title ) {
272 if ( $forceClone === self::NEW_CLONE ) {
273 return clone $linkTarget;
308 if ( $text !==
null && !is_string( $text ) && !is_int( $text ) ) {
309 throw new InvalidArgumentException(
'$text must be a string.' );
311 if ( $text ===
null ) {
344 if ( is_object( $text ) ) {
345 throw new MWException(
'$text must be a string, given an object' );
346 } elseif ( $text ===
null ) {
358 if ( $defaultNamespace ==
NS_MAIN ) {
366 $filteredText = Sanitizer::decodeCharReferencesAndNormalize( $text );
369 $t->mDbkeyform = strtr( $filteredText,
' ',
'_' );
370 $t->mDefaultNamespace = (int)$defaultNamespace;
372 $t->secureAndSplit();
373 if ( $defaultNamespace ==
NS_MAIN ) {
397 # For compatibility with old buggy URLs. "+" is usually not valid in titles,
398 # but some URLs used it as a space replacement and they still come
399 # from some external search tools.
400 if ( strpos( self::legalChars(),
'+' ) ===
false ) {
401 $url = strtr( $url,
'+',
' ' );
404 $t->mDbkeyform = strtr( $url,
' ',
'_' );
407 $t->secureAndSplit();
418 if ( self::$titleCache ===
null ) {
419 self::$titleCache =
new MapCacheLRU( self::CACHE_MAX );
435 'page_namespace',
'page_title',
'page_id',
436 'page_len',
'page_is_redirect',
'page_latest',
440 $fields[] =
'page_content_model';
444 $fields[] =
'page_lang';
459 $row = $db->selectRow(
461 self::getSelectFields(),
462 [
'page_id' => $id ],
465 if ( $row !==
false ) {
481 if ( !
count( $ids ) ) {
488 self::getSelectFields(),
489 [
'page_id' => $ids ],
494 foreach (
$res as $row ) {
508 $t->loadFromRow( $row );
520 if ( isset( $row->page_id ) ) {
521 $this->mArticleID = (int)$row->page_id;
523 if ( isset( $row->page_len ) ) {
524 $this->mLength = (int)$row->page_len;
526 if ( isset( $row->page_is_redirect ) ) {
527 $this->mRedirect = (bool)$row->page_is_redirect;
529 if ( isset( $row->page_latest ) ) {
530 $this->mLatestID = (int)$row->page_latest;
532 if ( !$this->mForcedContentModel && isset( $row->page_content_model ) ) {
533 $this->mContentModel = (
string)$row->page_content_model;
534 } elseif ( !$this->mForcedContentModel ) {
537 if ( isset( $row->page_lang ) ) {
538 $this->mDbPageLanguage = (
string)$row->page_lang;
540 if ( isset( $row->page_restrictions ) ) {
541 $this->mOldRestrictions = $row->page_restrictions;
544 $this->mArticleID = 0;
546 $this->mRedirect =
false;
547 $this->mLatestID = 0;
548 if ( !$this->mForcedContentModel ) {
578 $t->mInterwiki = $interwiki;
579 $t->mFragment = $fragment;
580 $t->mNamespace = $ns = (int)$ns;
581 $t->mDbkeyform = strtr(
$title,
' ',
'_' );
582 $t->mArticleID = ( $ns >= 0 ) ? -1 : 0;
584 $t->mTextform = strtr(
$title,
'_',
' ' );
616 $t->secureAndSplit();
652 [
'page_namespace',
'page_title' ],
653 [
'page_id' => $id ],
656 if (
$s ===
false ) {
684 $length = strlen( $byteClass );
686 $x0 = $x1 = $x2 =
'';
688 $d0 = $d1 = $d2 =
'';
690 $ord0 = $ord1 = $ord2 = 0;
692 $r0 = $r1 = $r2 =
'';
696 $allowUnicode =
false;
697 for ( $pos = 0; $pos < $length; $pos++ ) {
708 $inChar = $byteClass[$pos];
709 if ( $inChar ==
'\\' ) {
710 if ( preg_match(
'/x([0-9a-fA-F]{2})/A', $byteClass, $m, 0, $pos + 1 ) ) {
711 $x0 = $inChar . $m[0];
712 $d0 = chr( hexdec( $m[1] ) );
713 $pos += strlen( $m[0] );
714 } elseif ( preg_match(
'/[0-7]{3}/A', $byteClass, $m, 0, $pos + 1 ) ) {
715 $x0 = $inChar . $m[0];
716 $d0 = chr( octdec( $m[0] ) );
717 $pos += strlen( $m[0] );
718 } elseif ( $pos + 1 >= $length ) {
721 $d0 = $byteClass[$pos + 1];
730 if ( $ord0 < 32 || $ord0 == 0x7f ) {
731 $r0 = sprintf(
'\x%02x', $ord0 );
732 } elseif ( $ord0 >= 0x80 ) {
734 $r0 = sprintf(
'\x%02x', $ord0 );
735 $allowUnicode =
true;
737 } elseif ( strpos(
'-\\[]^', $d0 ) !==
false ) {
743 if ( $x0 !==
'' && $x1 ===
'-' && $x2 !==
'' ) {
745 if ( $ord2 > $ord0 ) {
747 } elseif ( $ord0 >= 0x80 ) {
749 $allowUnicode =
true;
750 if ( $ord2 < 0x80 ) {
759 $x0 = $x1 = $d0 = $d1 = $r0 = $r1 =
'';
760 } elseif ( $ord2 < 0x80 ) {
765 if ( $ord1 < 0x80 ) {
768 if ( $ord0 < 0x80 ) {
771 if ( $allowUnicode ) {
772 $out .=
'\u0080-\uFFFF';
789 $canonicalNamespace =
false
791 if ( $canonicalNamespace ) {
794 $namespace = MediaWikiServices::getInstance()->getContentLanguage()->getNsText( $ns );
796 $name = $namespace ==
'' ?
$title :
"$namespace:$title";
797 if ( strval( $interwiki ) !=
'' ) {
798 $name =
"$interwiki:$name";
800 if ( strval( $fragment ) !=
'' ) {
801 $name .=
'#' . $fragment;
839 $parser = MediaWikiServices::getInstance()->getTitleParser();
840 $parser->parseTitle( $this->mDbkeyform, $this->mNamespace );
858 return $iw->isLocal();
870 return $this->mInterwiki !==
'';
930 if ( $this->mTitleValue ===
null ) {
938 }
catch ( InvalidArgumentException $ex ) {
939 wfDebug( __METHOD__ .
': Can\'t create a TitleValue for [[' .
981 if ( !is_null( $this->mUserCaseDBKey ) ) {
1007 if ( !$this->mForcedContentModel
1008 && ( !$this->mContentModel || $flags === self::GAID_FOR_UPDATE )
1011 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
1012 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
1013 $this->mContentModel = $linkCache->getGoodLinkFieldObj( $this,
'model' );
1016 if ( !$this->mContentModel ) {
1045 $this->mContentModel = $model;
1046 $this->mForcedContentModel =
true;
1059 if ( $nsText !==
false ) {
1066 return $formatter->getNamespaceName( $this->mNamespace, $this->mDbkeyform );
1067 }
catch ( InvalidArgumentException $ex ) {
1068 wfDebug( __METHOD__ .
': ' . $ex->getMessage() .
"\n" );
1079 return MediaWikiServices::getInstance()->getContentLanguage()->
1089 return MediaWikiServices::getInstance()->getContentLanguage()->
1111 return $this->mNamespace >=
NS_MAIN;
1140 list( $thisName, ) =
1141 MediaWikiServices::getInstance()->getSpecialPageFactory()->
1142 resolveAlias( $this->mDbkeyform );
1143 if (
$name == $thisName ) {
1158 $spFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
1159 list( $canonicalName, $par ) = $spFactory->resolveAlias( $this->mDbkeyform );
1160 if ( $canonicalName ) {
1161 $localName = $spFactory->getLocalNameFor( $canonicalName, $par );
1162 if ( $localName != $this->mDbkeyform ) {
1262 return $this->
equals( self::newMainPage() );
1285 strpos( $this->
getText(),
'Conversiontable/' ) === 0;
1340 $subpage = explode(
'/', $this->mTextform );
1341 $subpage = $subpage[
count( $subpage ) - 1];
1342 $lastdot = strrpos( $subpage,
'.' );
1343 if ( $lastdot ===
false ) {
1344 return $subpage; # Never happens: only called
for names ending
in '.css'/
'.json'/
'.js'
1346 return substr( $subpage, 0, $lastdot );
1404 || substr( $this->mDbkeyform, -4 ) ===
'.css'
1422 || substr( $this->mDbkeyform, -5 ) ===
'.json'
1440 || substr( $this->mDbkeyform, -3 ) ===
'.js'
1505 if ( $this->mNamespace == $subjectNS ) {
1521 throw new MWException(
'Special pages cannot have other pages' );
1527 throw new MWException(
"{$this->getPrefixedText()} does not have an other page" );
1560 return $this->mFragment !==
'';
1575 if ( $interwiki && !$interwiki->isLocal() ) {
1576 return '#' . Sanitizer::escapeIdForExternalInterwiki( $this->mFragment );
1580 return '#' . Sanitizer::escapeIdForLink( $this->mFragment );
1596 $this->mFragment = strtr( substr( $fragment, 1 ),
'_',
' ' );
1625 $p = $this->mInterwiki .
':';
1628 if ( $this->mNamespace != 0 ) {
1631 if ( $nsText ===
false ) {
1633 $nsText = MediaWikiServices::getInstance()->getContentLanguage()->
1637 $p .= $nsText .
':';
1649 $s = $this->
prefix( $this->mDbkeyform );
1650 $s = strtr(
$s,
' ',
'_' );
1661 if ( $this->prefixedText ===
null ) {
1662 $s = $this->
prefix( $this->mTextform );
1663 $s = strtr(
$s,
'_',
' ' );
1664 $this->prefixedText =
$s;
1709 return strtok( $this->
getText(),
'/' );
1745 $lastSlashPos = strrpos( $text,
'/' );
1747 if ( $lastSlashPos ===
false ) {
1751 return substr( $text, 0, $lastSlashPos );
1785 $parts = explode(
'/', $this->mTextform );
1786 return $parts[
count( $parts ) - 1];
1823 $s = $this->
prefix( $this->mDbkeyform );
1842 if ( $query2 !==
false ) {
1843 wfDeprecated(
"Title::get{Canonical,Full,Link,Local,Internal}URL " .
1844 "method called with a second parameter is deprecated. Add your " .
1845 "parameter to an array passed as the first parameter.",
"1.19" );
1847 if ( is_array(
$query ) ) {
1851 if ( is_string( $query2 ) ) {
1882 # Hand off all the decisions on urls to getLocalURL
1885 # Expand the url to make it a full url. Note that getLocalURL has the
1886 # potential to output full urls for a variety of reasons, so we use
1887 # wfExpandUrl instead of simply prepending $wgServer
1890 # Finally, add the fragment.
1922 return $target->getFullURL(
$query,
false, $proto );
1956 if ( $namespace !=
'' ) {
1957 # Can this actually happen? Interwikis shouldn't be parsed.
1958 # Yes! It can in interwiki transclusion. But... it probably shouldn't.
1961 $url = $interwiki->getURL( $namespace . $this->mDbkeyform );
1969 Hooks::run(
'GetLocalURL::Article', [ &$titleRef, &$url ] );
1976 && preg_match(
'/^(.*&|)action=([^&]*)(&(.*)|)$/',
$query,
$matches )
1978 $action = urldecode(
$matches[2] );
1995 MediaWikiServices::getInstance()->getContentLanguage() )
1998 $variant = urldecode(
$matches[1] );
2003 $url = str_replace(
'$1', $dbkey, $url );
2007 if ( $url ===
false ) {
2011 $url =
"{$wgScript}?title={$dbkey}&{$query}";
2020 if (
$wgRequest->getVal(
'action' ) ==
'render' ) {
2048 if ( $this->
isExternal() || $proto !==
false ) {
2158 public function userCan( $action,
$user =
null, $rigor = PermissionManager::RIGOR_SECURE ) {
2165 if ( $rigor ===
true ) {
2166 $rigor = PermissionManager::RIGOR_SECURE;
2167 } elseif ( $rigor ===
false ) {
2168 $rigor = PermissionManager::RIGOR_QUICK;
2171 return MediaWikiServices::getInstance()->getPermissionManager()
2172 ->userCan( $action,
$user, $this, $rigor );
2197 $action,
$user, $rigor = PermissionManager::RIGOR_SECURE, $ignoreErrors = []
2200 if ( $rigor ===
true ) {
2201 $rigor = PermissionManager::RIGOR_SECURE;
2202 } elseif ( $rigor ===
false ) {
2203 $rigor = PermissionManager::RIGOR_QUICK;
2206 return MediaWikiServices::getInstance()->getPermissionManager()
2207 ->getPermissionErrors( $action,
$user, $this, $rigor, $ignoreErrors );
2224 $errors = array_merge( $errors,
$result );
2231 } elseif (
$result ===
false ) {
2233 $errors[] = [
'badaccess-group0' ];
2249 # Remove the create restriction for existing titles
2250 $types = array_diff( $types, [
'create' ] );
2252 # Only the create and upload restrictions apply to non-existing titles
2253 $types = array_intersect( $types, [
'create',
'upload' ] );
2270 if ( $this->mNamespace !=
NS_FILE ) {
2271 # Remove the upload restriction for non-file titles
2272 $types = array_diff( $types, [
'upload' ] );
2275 Hooks::run(
'TitleGetRestrictionTypes', [ $this, &$types ] );
2277 wfDebug( __METHOD__ .
': applicable restrictions to [[' .
2278 $this->
getPrefixedText() .
']] are {' . implode(
',', $types ) .
"}\n" );
2292 if ( $protection ) {
2293 if ( $protection[
'permission'] ==
'sysop' ) {
2294 $protection[
'permission'] =
'editprotected';
2296 if ( $protection[
'permission'] ==
'autoconfirmed' ) {
2297 $protection[
'permission'] =
'editsemiprotected';
2315 if ( $this->mNamespace < 0 ) {
2324 if ( $this->mTitleProtection ===
null ) {
2327 $commentQuery = $commentStore->getJoin(
'pt_reason' );
2329 [
'protected_titles' ] + $commentQuery[
'tables'],
2331 'user' =>
'pt_user',
2332 'expiry' =>
'pt_expiry',
2333 'permission' =>
'pt_create_perm'
2334 ] + $commentQuery[
'fields'],
2335 [
'pt_namespace' => $this->mNamespace,
'pt_title' => $this->mDbkeyform ],
2338 $commentQuery[
'joins']
2344 $this->mTitleProtection = [
2345 'user' => $row[
'user'],
2346 'expiry' =>
$dbr->decodeExpiry( $row[
'expiry'] ),
2347 'permission' => $row[
'permission'],
2348 'reason' => $commentStore->getComment(
'pt_reason', $row )->text,
2351 $this->mTitleProtection =
false;
2365 [
'pt_namespace' => $this->mNamespace,
'pt_title' => $this->mDbkeyform ],
2368 $this->mTitleProtection =
false;
2383 if ( !$restrictions || !$semi ) {
2389 foreach ( array_keys( $semi,
'autoconfirmed' )
as $key ) {
2390 $semi[$key] =
'editsemiprotected';
2392 foreach ( array_keys( $restrictions,
'autoconfirmed' )
as $key ) {
2393 $restrictions[$key] =
'editsemiprotected';
2396 return !array_diff( $restrictions, $semi );
2411 # Special pages have inherent protection
2416 # Check regular protection levels
2417 foreach ( $restrictionTypes
as $type ) {
2418 if ( $action ==
$type || $action ==
'' ) {
2421 if ( in_array( $level, $r ) && $level !=
'' ) {
2443 if ( $right !=
'' && !
$user->isAllowed( $right ) ) {
2458 return ( $sources > 0 );
2471 return $getPages ? $this->mCascadeSources !==
null : $this->mHasCascadingRestrictions !==
null;
2488 $pagerestrictions = [];
2490 if ( $this->mCascadeSources !==
null && $getPages ) {
2492 } elseif ( $this->mHasCascadingRestrictions !==
null && !$getPages ) {
2498 if ( $this->mNamespace ==
NS_FILE ) {
2499 $tables = [
'imagelinks',
'page_restrictions' ];
2506 $tables = [
'templatelinks',
'page_restrictions' ];
2516 $cols = [
'pr_page',
'page_namespace',
'page_title',
2517 'pr_expiry',
'pr_type',
'pr_level' ];
2518 $where_clauses[] =
'page_id=pr_page';
2521 $cols = [
'pr_expiry' ];
2526 $sources = $getPages ? [] :
false;
2529 foreach (
$res as $row ) {
2530 $expiry =
$dbr->decodeExpiry( $row->pr_expiry );
2531 if ( $expiry > $now ) {
2533 $page_id = $row->pr_page;
2534 $page_ns = $row->page_namespace;
2535 $page_title = $row->page_title;
2537 # Add groups needed for each restriction type if its not already there
2538 # Make sure this restriction type still exists
2540 if ( !isset( $pagerestrictions[$row->pr_type] ) ) {
2541 $pagerestrictions[$row->pr_type] = [];
2545 isset( $pagerestrictions[$row->pr_type] )
2546 && !in_array( $row->pr_level, $pagerestrictions[$row->pr_type] )
2548 $pagerestrictions[$row->pr_type][] = $row->pr_level;
2557 $this->mCascadeSources = $sources;
2558 $this->mCascadingRestrictions = $pagerestrictions;
2560 $this->mHasCascadingRestrictions = $sources;
2563 return [ $sources, $pagerestrictions ];
2587 if ( !$this->mRestrictionsLoaded ) {
2590 return $this->mRestrictions[$action] ?? [];
2601 if ( !$this->mRestrictionsLoaded ) {
2615 if ( !$this->mRestrictionsLoaded ) {
2618 return $this->mRestrictionsExpiry[$action] ??
false;
2627 if ( !$this->mRestrictionsLoaded ) {
2653 foreach ( $restrictionTypes
as $type ) {
2654 $this->mRestrictions[
$type] = [];
2655 $this->mRestrictionsExpiry[
$type] =
'infinity';
2658 $this->mCascadeRestriction =
false;
2660 # Backwards-compatibility: also load the restrictions from the page record (old format).
2661 if ( $oldFashionedRestrictions !==
null ) {
2662 $this->mOldRestrictions = $oldFashionedRestrictions;
2665 if ( $this->mOldRestrictions ===
false ) {
2666 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
2667 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
2668 $this->mOldRestrictions = $linkCache->getGoodLinkFieldObj( $this,
'restrictions' );
2671 if ( $this->mOldRestrictions !=
'' ) {
2672 foreach ( explode(
':', trim( $this->mOldRestrictions ) )
as $restrict ) {
2673 $temp = explode(
'=', trim( $restrict ) );
2674 if (
count( $temp ) == 1 ) {
2676 $this->mRestrictions[
'edit'] = explode(
',', trim( $temp[0] ) );
2677 $this->mRestrictions[
'move'] = explode(
',', trim( $temp[0] ) );
2679 $restriction = trim( $temp[1] );
2680 if ( $restriction !=
'' ) {
2681 $this->mRestrictions[$temp[0]] = explode(
',', $restriction );
2688 # Current system - load second to make them override.
2691 # Cycle through all the restrictions.
2694 if ( !in_array( $row->pr_type, $restrictionTypes ) ) {
2698 $expiry =
$dbr->decodeExpiry( $row->pr_expiry );
2701 if ( !$expiry || $expiry > $now ) {
2702 $this->mRestrictionsExpiry[$row->pr_type] = $expiry;
2703 $this->mRestrictions[$row->pr_type] = explode(
',', trim( $row->pr_level ) );
2705 $this->mCascadeRestriction |= $row->pr_cascade;
2710 $this->mRestrictionsLoaded =
true;
2725 if ( $this->mRestrictionsLoaded && !$readLatest ) {
2736 return iterator_to_array(
2738 'page_restrictions',
2739 [
'pr_type',
'pr_expiry',
'pr_level',
'pr_cascade' ],
2740 [
'pr_page' => $id ],
2746 if ( $readLatest ) {
2748 $rows = $loadRestrictionsFromDb(
$dbr );
2750 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
2753 $cache->makeKey(
'page-restrictions',
'v1', $id, $this->getLatestRevID() ),
2755 function ( $curValue, &$ttl,
array &$setOpts )
use ( $loadRestrictionsFromDb ) {
2758 $setOpts += Database::getCacheSetOptions(
$dbr );
2759 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
2760 if ( $lb->hasOrMadeRecentMasterChanges() ) {
2765 return $loadRestrictionsFromDb(
$dbr );
2774 if ( $title_protection ) {
2778 if ( !$expiry || $expiry > $now ) {
2780 $this->mRestrictionsExpiry[
'create'] = $expiry;
2781 $this->mRestrictions[
'create'] =
2782 explode(
',', trim( $title_protection[
'permission'] ) );
2784 $this->mTitleProtection =
false;
2787 $this->mRestrictionsExpiry[
'create'] =
'infinity';
2789 $this->mRestrictionsLoaded =
true;
2798 $this->mRestrictionsLoaded =
false;
2799 $this->mTitleProtection =
null;
2816 $config = MediaWikiServices::getInstance()->getMainConfig();
2818 'page_restrictions',
2822 [
'LIMIT' => $config->get(
'UpdateRowsPerQuery' ) ]
2825 $dbw->
delete(
'page_restrictions', [
'pr_id' => $ids ],
$fname );
2854 # We dynamically add a member variable for the purpose of this method
2855 # alone to cache the result. There's no point in having it hanging
2856 # around uninitialized in every Title object; therefore we only add it
2857 # if needed and don't declare it statically.
2858 if ( $this->mHasSubpages ===
null ) {
2859 $this->mHasSubpages =
false;
2862 $this->mHasSubpages = (bool)$subpages->count();
2883 $conds[] =
'page_title ' .
$dbr->buildLike( $this->mDbkeyform .
'/',
$dbr->anyString() );
2885 if ( $limit > -1 ) {
2889 $dbr->select(
'page',
2890 [
'page_id',
'page_namespace',
'page_title',
'page_is_redirect' ],
2904 if ( $this->mNamespace < 0 ) {
2909 $n =
$dbr->selectField(
'archive',
'COUNT(*)',
2910 [
'ar_namespace' => $this->mNamespace,
'ar_title' => $this->mDbkeyform ],
2913 if ( $this->mNamespace ==
NS_FILE ) {
2914 $n +=
$dbr->selectField(
'filearchive',
'COUNT(*)',
2915 [
'fa_name' => $this->mDbkeyform ],
2929 if ( $this->mNamespace < 0 ) {
2933 $deleted = (bool)
$dbr->selectField(
'archive',
'1',
2934 [
'ar_namespace' => $this->mNamespace,
'ar_title' => $this->mDbkeyform ],
2937 if ( !$deleted && $this->mNamespace ==
NS_FILE ) {
2938 $deleted = (bool)
$dbr->selectField(
'filearchive',
'1',
2939 [
'fa_name' => $this->mDbkeyform ],
2955 if ( $this->mNamespace < 0 ) {
2956 $this->mArticleID = 0;
2959 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
2960 if ( $flags & self::GAID_FOR_UPDATE ) {
2961 $oldUpdate = $linkCache->forUpdate(
true );
2962 $linkCache->clearLink( $this );
2963 $this->mArticleID = $linkCache->addLinkObj( $this );
2964 $linkCache->forUpdate( $oldUpdate );
2965 } elseif ( $this->mArticleID == -1 ) {
2966 $this->mArticleID = $linkCache->addLinkObj( $this );
2979 if ( !is_null( $this->mRedirect ) ) {
2983 $this->mRedirect =
false;
2987 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
2988 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
2989 $cached = $linkCache->getGoodLinkFieldObj( $this,
'redirect' );
2990 if ( $cached ===
null ) {
2991 # Trust LinkCache's state over our own
2992 # LinkCache is telling us that the page doesn't exist, despite there being cached
2993 # data relating to an existing page in $this->mArticleID. Updaters should clear
2994 # LinkCache as appropriate, or use $flags = Title::GAID_FOR_UPDATE. If that flag is
2995 # set, then LinkCache will definitely be up to date here, since getArticleID() forces
2996 # LinkCache to refresh its data from the master.
2997 $this->mRedirect =
false;
3001 $this->mRedirect = (bool)$cached;
3014 if ( $this->mLength != -1 ) {
3021 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
3022 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
3023 $cached = $linkCache->getGoodLinkFieldObj( $this,
'length' );
3024 if ( $cached ===
null ) {
3025 # Trust LinkCache's state over our own, as for isRedirect()
3030 $this->mLength = intval( $cached );
3042 if ( !( $flags & self::GAID_FOR_UPDATE ) && $this->mLatestID !==
false ) {
3043 return intval( $this->mLatestID );
3046 $this->mLatestID = 0;
3049 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
3050 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
3051 $cached = $linkCache->getGoodLinkFieldObj( $this,
'revision' );
3052 if ( $cached ===
null ) {
3053 # Trust LinkCache's state over our own, as for isRedirect()
3054 $this->mLatestID = 0;
3058 $this->mLatestID = intval( $cached );
3074 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
3075 $linkCache->clearLink( $this );
3077 if ( $newid ===
false ) {
3078 $this->mArticleID = -1;
3080 $this->mArticleID = intval( $newid );
3082 $this->mRestrictionsLoaded =
false;
3083 $this->mRestrictions = [];
3084 $this->mOldRestrictions =
false;
3085 $this->mRedirect =
null;
3086 $this->mLength = -1;
3087 $this->mLatestID =
false;
3088 $this->mContentModel =
false;
3089 $this->mEstimateRevisions =
null;
3090 $this->mPageLanguage =
false;
3091 $this->mDbPageLanguage =
false;
3092 $this->mIsBigDeletion =
null;
3096 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
3097 $linkCache->clear();
3112 return MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $text );
3137 $titleCodec = MediaWikiServices::getInstance()->getTitleParser();
3139 $parts = $titleCodec->splitTitleString( $this->mDbkeyform, $this->mDefaultNamespace );
3143 $this->mInterwiki = $parts[
'interwiki'];
3144 $this->mLocalInterwiki = $parts[
'local_interwiki'];
3145 $this->mNamespace = $parts[
'namespace'];
3146 $this->mUserCaseDBKey = $parts[
'user_case_dbkey'];
3148 $this->mDbkeyform = $parts[
'dbkey'];
3149 $this->mUrlform =
wfUrlencode( $this->mDbkeyform );
3150 $this->mTextform = strtr( $this->mDbkeyform,
'_',
' ' );
3152 # We already know that some pages won't be in the database!
3154 $this->mArticleID = 0;
3181 self::getSelectFields(),
3183 "{$prefix}_from=page_id",
3184 "{$prefix}_namespace" => $this->mNamespace,
3185 "{$prefix}_title" => $this->mDbkeyform ],
3191 if (
$res->numRows() ) {
3192 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
3193 foreach (
$res as $row ) {
3194 $titleObj =
self::makeTitle( $row->page_namespace, $row->page_title );
3196 $linkCache->addGoodLinkObjFromRow( $titleObj, $row );
3197 $retVal[] = $titleObj;
3233 # If the page doesn't exist; there can't be any link from this page
3240 $blNamespace =
"{$prefix}_namespace";
3241 $blTitle =
"{$prefix}_title";
3245 [ $table,
'nestpage' => $pageQuery[
'tables'] ],
3247 [ $blNamespace, $blTitle ],
3248 $pageQuery[
'fields']
3250 [
"{$prefix}_from" => $id ],
3255 [
"page_namespace=$blNamespace",
"page_title=$blTitle" ]
3256 ] ] + $pageQuery[
'joins']
3260 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
3261 foreach (
$res as $row ) {
3262 if ( $row->page_id ) {
3266 $linkCache->addBadLinkObj( $titleObj );
3268 $retVal[] = $titleObj;
3298 # All links from article ID 0 are false positives
3304 [
'page',
'pagelinks' ],
3305 [
'pl_namespace',
'pl_title' ],
3308 'page_namespace IS NULL'
3314 [
'pl_namespace=page_namespace',
'pl_title=page_title' ]
3320 foreach (
$res as $row ) {
3339 if ( $pageLang->hasVariants() ) {
3340 $variants = $pageLang->getVariants();
3341 foreach ( $variants
as $vCode ) {
3348 $urls[] = $this->
getInternalURL(
'action=raw&ctype=text/javascript' );
3350 $urls[] = $this->
getInternalURL(
'action=raw&ctype=application/json' );
3355 Hooks::run(
'TitleSquidURLs', [ $this, &$urls ] );
3382 if ( !( $nt instanceof
Title ) ) {
3385 return [ [
'badtitletext' ] ];
3389 $errors = $mp->isValidMove()->getErrorsArray();
3393 $mp->checkPermissions( $wgUser, $reason )->getErrorsArray()
3397 return $errors ?:
true;
3413 public function moveTo( &$nt, $auth =
true, $reason =
'', $createRedirect =
true,
3414 array $changeTags = []
3418 if ( is_array( $err ) ) {
3420 $wgUser->spreadAnyEditBlock();
3424 if ( $auth && !$wgUser->isAllowed(
'suppressredirect' ) ) {
3425 $createRedirect =
true;
3429 $status = $mp->move( $wgUser, $reason, $createRedirect, $changeTags );
3433 return $status->getErrorsArray();
3451 public function moveSubpages( $nt, $auth =
true, $reason =
'', $createRedirect =
true,
3452 array $changeTags = []
3456 if ( !$this->
userCan(
'move-subpages' ) ) {
3458 [
'cant-move-subpages' ],
3473 $subpages = $this->
getSubpages( $wgMaximumMovedPages + 1 );
3476 foreach ( $subpages
as $oldSubpage ) {
3479 $retval[$oldSubpage->getPrefixedText()] = [
3488 if ( $oldSubpage->getArticleID() == $this->
getArticleID()
3489 || $oldSubpage->getArticleID() == $nt->getArticleID()
3495 $newPageName = preg_replace(
3496 '#^' . preg_quote( $this->mDbkeyform,
'#' ) .
'#',
3498 $oldSubpage->getDBkey() );
3499 if ( $oldSubpage->isTalkPage() ) {
3500 $newNs = $nt->getTalkPage()->getNamespace();
3502 $newNs = $nt->getSubjectPage()->getNamespace();
3504 # T16385: we need makeTitleSafe because the new page names may
3505 # be longer than 255 characters.
3508 $success = $oldSubpage->moveTo( $newSubpage, $auth, $reason, $createRedirect, $changeTags );
3510 $retval[$oldSubpage->getPrefixedText()] = $newSubpage->getPrefixedText();
3512 $retval[$oldSubpage->getPrefixedText()] =
$success;
3530 $fields = [
'page_is_redirect',
'page_latest',
'page_id' ];
3532 $fields[] =
'page_content_model';
3535 $row = $dbw->selectRow(
'page',
3541 # Cache some fields we may want
3542 $this->mArticleID = $row ? intval( $row->page_id ) : 0;
3543 $this->mRedirect = $row ? (bool)$row->page_is_redirect :
false;
3544 $this->mLatestID = $row ? intval( $row->page_latest ) :
false;
3545 $this->mContentModel = $row && isset( $row->page_content_model )
3546 ? strval( $row->page_content_model )
3549 if ( !$this->mRedirect ) {
3552 # Does the article have a history?
3553 $row = $dbw->selectField( [
'page',
'revision' ],
3555 [
'page_namespace' => $this->mNamespace,
3556 'page_title' => $this->mDbkeyform,
3558 'page_latest != rev_id'
3563 # Return true if there was no history
3564 return ( $row ===
false );
3576 # Is it an existing file?
3577 if ( $nt->getNamespace() ==
NS_FILE ) {
3579 $file->load( File::READ_LATEST );
3580 if (
$file->exists() ) {
3581 wfDebug( __METHOD__ .
": file exists\n" );
3585 # Is it a redirect with no history?
3586 if ( !$nt->isSingleRevRedirect() ) {
3587 wfDebug( __METHOD__ .
": not a one-rev redirect\n" );
3590 # Get the article text
3592 if ( !is_object(
$rev ) ) {
3596 # Does the redirect point to the source?
3597 # Or is it a broken self-redirect, usually caused by namespace collisions?
3600 if ( $redirTitle ) {
3602 $redirTitle->getPrefixedDBkey() != $nt->getPrefixedDBkey() ) {
3603 wfDebug( __METHOD__ .
": redirect points to other page\n" );
3609 # Fail safe (not a redirect after all. strange.)
3610 wfDebug( __METHOD__ .
": failsafe: database sais " . $nt->getPrefixedDBkey() .
3611 " is a redirect, but it doesn't contain a valid redirect.\n" );
3628 if ( $titleKey === 0 ) {
3637 [
'cl_from' => $titleKey ],
3641 if (
$res->numRows() > 0 ) {
3642 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
3643 foreach (
$res as $row ) {
3663 foreach ( $parents
as $parent => $current ) {
3664 if ( array_key_exists(
$parent, $children ) ) {
3665 # Circular reference
3670 $stack[
$parent] = $nt->getParentCategoryTree( $children + [
$parent => 1 ] );
3686 if ( $this->mArticleID > 0 ) {
3702 $revId = (int)$revId;
3703 if ( $dir ===
'next' ) {
3706 } elseif ( $dir ===
'prev' ) {
3710 throw new InvalidArgumentException(
'$dir must be "next" or "prev"' );
3713 if ( $flags & self::GAID_FOR_UPDATE ) {
3721 $ts = $db->selectField(
'revision',
'rev_timestamp', [
'rev_id' => $revId ], __METHOD__ );
3722 if ( $ts ===
false ) {
3723 $ts = $db->selectField(
'archive',
'ar_timestamp', [
'ar_rev_id' => $revId ], __METHOD__ );
3724 if ( $ts ===
false ) {
3729 $ts = $db->addQuotes( $ts );
3731 $revId = $db->selectField(
'revision',
'rev_id',
3734 "rev_timestamp $op $ts OR (rev_timestamp = $ts AND rev_id $op $revId)"
3738 'ORDER BY' =>
"rev_timestamp $sort, rev_id $sort",
3739 'IGNORE INDEX' =>
'rev_timestamp',
3743 if ( $revId ===
false ) {
3746 return intval( $revId );
3784 [
'rev_page' => $pageId ],
3787 'ORDER BY' =>
'rev_timestamp ASC, rev_id ASC',
3788 'IGNORE INDEX' => [
'revision' =>
'rev_timestamp' ],
3793 return new Revision( $row, 0, $this );
3807 return $rev ?
$rev->getTimestamp() :
null;
3817 return (
bool)
$dbr->selectField(
'page',
'page_is_new', $this->
pageCond(), __METHOD__ );
3832 if ( $this->mIsBigDeletion ===
null ) {
3835 $revCount =
$dbr->selectRowCount(
3855 if ( !$this->
exists() ) {
3859 if ( $this->mEstimateRevisions ===
null ) {
3861 $this->mEstimateRevisions =
$dbr->estimateRowCount(
'revision',
'*',
3878 if ( !( $old instanceof
Revision ) ) {
3881 if ( !( $new instanceof
Revision ) ) {
3884 if ( !$old || !$new ) {
3890 'rev_timestamp > ' .
$dbr->addQuotes(
$dbr->timestamp( $old->getTimestamp() ) ),
3891 'rev_timestamp < ' .
$dbr->addQuotes(
$dbr->timestamp( $new->getTimestamp() ) )
3893 if ( $max !==
null ) {
3894 return $dbr->selectRowCount(
'revision',
'1',
3897 [
'LIMIT' => $max + 1 ]
3900 return (
int)
$dbr->selectField(
'revision',
'count(*)', $conds, __METHOD__ );
3921 if ( !( $old instanceof
Revision ) ) {
3924 if ( !( $new instanceof
Revision ) ) {
3930 if ( !$old || !$new ) {
3937 if ( in_array(
'include_old',
$options ) ) {
3940 if ( in_array(
'include_new',
$options ) ) {
3943 if ( in_array(
'include_both',
$options ) ) {
3948 if ( $old->getId() === $new->getId() ) {
3949 return ( $old_cmp ===
'>' && $new_cmp ===
'<' ) ?
3952 } elseif ( $old->getId() === $new->getParentId() ) {
3953 if ( $old_cmp ===
'>=' && $new_cmp ===
'<=' ) {
3958 } elseif ( $old_cmp ===
'>=' ) {
3960 } elseif ( $new_cmp ===
'<=' ) {
3967 $authors =
$dbr->selectFieldValues(
3972 "rev_timestamp $old_cmp " .
$dbr->addQuotes(
$dbr->timestamp( $old->getTimestamp() ) ),
3973 "rev_timestamp $new_cmp " .
$dbr->addQuotes(
$dbr->timestamp( $new->getTimestamp() ) )
3975 [
'DISTINCT',
'LIMIT' => $limit + 1 ],
3997 return $authors ?
count( $authors ) : 0;
4008 return $this->mInterwiki ===
$title->mInterwiki
4009 && $this->mNamespace ==
$title->mNamespace
4010 && $this->mDbkeyform ===
$title->mDbkeyform;
4020 return $this->mInterwiki ===
$title->mInterwiki
4021 && $this->mNamespace ==
$title->mNamespace
4022 && strpos( $this->mDbkeyform,
$title->mDbkeyform .
'/' ) === 0;
4038 Hooks::run(
'TitleExists', [ $this, &$exists ] );
4071 Hooks::run(
'TitleIsAlwaysKnown', [ $this, &$isKnown ] );
4073 if ( !is_null( $isKnown ) ) {
4081 switch ( $this->mNamespace ) {
4088 return MediaWikiServices::getInstance()->getSpecialPageFactory()->
4089 exists( $this->mDbkeyform );
4092 return $this->mDbkeyform ==
'';
4131 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
4133 $contLang->lcfirst( $this->getText() )
4135 $message =
wfMessage(
$name )->inLanguage( $contLang )->useDatabase(
false );
4136 return $message->exists();
4185 MediaWikiServices::getInstance()->getContentLanguage()->lcfirst( $this->
getText() )
4189 if ( $message->exists() ) {
4190 return $message->plain();
4205 } elseif ( $this->mArticleID === 0 ) {
4210 $dbw->onTransactionPreCommitOrIdle(
4211 function ()
use ( $dbw ) {
4213 $this,
null,
null, $dbw->getDomainID() );
4224 $dbTimestamp = $dbw->
timestamp( $purgeTime ?: time() );
4227 [
'page_touched' => $dbTimestamp ],
4228 $conds + [
'page_touched < ' . $dbw->
addQuotes( $dbTimestamp ) ],
4231 MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $this );
4261 if ( $db ===
null ) {
4264 $touched = $db->selectField(
'page',
'page_touched', $this->
pageCond(), __METHOD__ );
4282 $uid =
$user->getId();
4287 if ( array_key_exists( $uid, $this->mNotificationTimestamp ) ) {
4288 return $this->mNotificationTimestamp[$uid];
4291 if (
count( $this->mNotificationTimestamp ) >= self::CACHE_MAX ) {
4292 $this->mNotificationTimestamp = [];
4295 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
4296 $watchedItem = $store->getWatchedItem(
$user, $this );
4297 if ( $watchedItem ) {
4298 $this->mNotificationTimestamp[$uid] = $watchedItem->getNotificationTimestamp();
4300 $this->mNotificationTimestamp[$uid] =
false;
4303 return $this->mNotificationTimestamp[$uid];
4317 if ( $namespaceKey ===
false ) {
4322 $namespaceKey = MediaWikiServices::getInstance()->getContentLanguage()->lc( $namespaceKey );
4324 if ( $namespaceKey ==
'' ) {
4325 $namespaceKey =
'main';
4328 if ( $namespaceKey ==
'file' ) {
4329 $namespaceKey =
'image';
4331 return $prepend . $namespaceKey;
4352 $where[] =
'rd_interwiki = ' .
$dbr->addQuotes(
'' ) .
' OR rd_interwiki IS NULL';
4354 if ( !is_null( $ns ) ) {
4355 $where[
'page_namespace'] = $ns;
4359 [
'redirect',
'page' ],
4360 [
'page_namespace',
'page_title' ],
4365 foreach (
$res as $row ) {
4381 if ( $this->
isSpecial(
'Userlogout' ) ) {
4385 foreach ( $wgInvalidRedirectTargets
as $target ) {
4414 return !in_array( $this->mNamespace, $bannedNamespaces );
4428 $unprefixed = $this->
getText();
4434 Hooks::run(
'GetDefaultSortkey', [ $this, &$unprefixed ] );
4435 if ( $prefix !==
'' ) {
4436 # Separate with a line feed, so the unprefixed part is only used as
4437 # a tiebreaker when two pages have the exact same prefix.
4438 # In UCA, tab is the only character that can sort above LF
4439 # so we strip both of them from the original prefix.
4440 $prefix = strtr( $prefix,
"\n\t",
' ' );
4441 return "$prefix\n$unprefixed";
4459 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
4460 $linkCache->addLinkObj( $this );
4461 $this->mDbPageLanguage = $linkCache->getGoodLinkFieldObj( $this,
'lang' );
4484 if ( $dbPageLanguage ) {
4488 if ( !$this->mPageLanguage || $this->mPageLanguage[1] !==
$wgLanguageCode ) {
4496 $langObj = $contentHandler->getPageLanguage( $this );
4519 $variant =
$wgLang->getPreferredVariant();
4520 if (
$wgLang->getCode() !== $variant ) {
4529 if ( $dbPageLanguage ) {
4531 $variant = $pageLang->getPreferredVariant();
4532 if ( $pageLang->getCode() !== $variant ) {
4543 $pageLang = $contentHandler->getPageViewLanguage( $this );
4563 if ( $msg->exists() ) {
4564 $html = $msg->parseAsBlock();
4566 if ( trim(
$html ) !==
'' ) {
4567 $notices[$editnotice_ns] = Html::rawElement(
4571 'mw-editnotice-namespace',
4572 Sanitizer::escapeClass(
"mw-$editnotice_ns" )
4581 $editnotice_base = $editnotice_ns;
4582 foreach ( explode(
'/', $this->mDbkeyform )
as $part ) {
4583 $editnotice_base .=
'-' . $part;
4585 if ( $msg->exists() ) {
4586 $html = $msg->parseAsBlock();
4587 if ( trim(
$html ) !==
'' ) {
4588 $notices[$editnotice_base] = Html::rawElement(
4592 'mw-editnotice-base',
4593 Sanitizer::escapeClass(
"mw-$editnotice_base" )
4602 $editnoticeText = $editnotice_ns .
'-' . strtr( $this->mDbkeyform,
'/',
'-' );
4604 if ( $msg->exists() ) {
4605 $html = $msg->parseAsBlock();
4606 if ( trim(
$html ) !==
'' ) {
4607 $notices[$editnoticeText] = Html::rawElement(
4611 'mw-editnotice-page',
4612 Sanitizer::escapeClass(
"mw-$editnoticeText" )
4620 Hooks::run(
'TitleGetEditNotices', [ $this, $oldid, &$notices ] );
4635 'mDefaultNamespace',
4640 $this->mArticleID = ( $this->mNamespace >= 0 ) ? -1 : 0;
4641 $this->mUrlform =
wfUrlencode( $this->mDbkeyform );
4642 $this->mTextform = strtr( $this->mDbkeyform,
'_',
' ' );
bool $mLocalInterwiki
Was this Title created from a string with a local interwiki prefix?
array $mRestrictions
Array of groups allowed to edit this article.
canHaveTalkPage()
Can this title have a corresponding talk page?
getTitleProtection()
Is this title subject to title protection? Title protection is the one applied against creation of su...
canUseNoindex()
Whether the magic words INDEX and NOINDEX function for this page.
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action, or null $user:User who performed the tagging when the tagging is subsequent to the action, or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'ContentSecurityPolicyDefaultSource':Modify the allowed CSP load sources. This affects all directives except for the script directive. If you want to add a script source, see ContentSecurityPolicyScriptSource hook. & $defaultSrc:Array of Content-Security-Policy allowed sources $policyConfig:Current configuration for the Content-Security-Policy header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyDirectives':Modify the content security policy directives. Use this only if ContentSecurityPolicyDefaultSource and ContentSecurityPolicyScriptSource do not meet your needs. & $directives:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyScriptSource':Modify the allowed CSP script sources. Note that you also have to use ContentSecurityPolicyDefaultSource if you want non-script sources to be loaded from whatever you add. & $scriptSrc:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
inNamespaces()
Returns true if the title is inside one of the specified namespaces.
getLocalURL( $query='', $query2=false)
Get a URL with no fragment or server name (relative URL) from a Title object.
isSemiProtected( $action='edit')
Is this page "semi-protected" - the only protection levels are listed in $wgSemiprotectedRestrictionL...
bool $mHasCascadingRestrictions
Are cascading restrictions in effect on this page?
isNamespaceProtected(User $user)
Determines if $user is unable to edit this page because it has been protected by $wgNamespaceProtecti...
getTalkNsText()
Get the namespace text of the talk page.
return true to allow those checks to and false if checking is done & $user
wfMergeErrorArrays(... $args)
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
getSubpageText()
Get the lowest-level subpage name, i.e.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static subjectEquals( $ns1, $ns2)
Returns whether the specified namespaces share the same subject.
isBigDeletion()
Check whether the number of revisions of this page surpasses $wgDeleteRevisionsLimit.
getNextRevisionID( $revId, $flags=0)
Get the revision ID of the next revision.
areCascadeProtectionSourcesLoaded( $getPages=true)
Determines whether cascading protection sources have already been loaded from the database.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
const TTL_UNCACHEABLE
Idiom for getWithSetCallback() callbacks to avoid calling set()
static getFilteredRestrictionTypes( $exists=true)
Get a filtered list of all restriction types supported by this wiki.
static makeName( $ns, $title, $fragment='', $interwiki='', $canonicalNamespace=false)
Make a prefixed DB key from a DB key and a namespace index.
processing should stop and the error should be shown to the user * false
getInternalURL( $query='', $query2=false)
Get the URL form for an internal link.
getFragment()
Get the Title fragment (i.e.
static isTalk( $index)
Is the given namespace a talk namespace?
$wgExemptFromUserRobotsControl
An array of namespace keys in which the INDEX/__NOINDEX__ magic words will not function,...
getTalkPageIfDefined()
Get a Title object associated with the talk page of this article, if such a talk page can exist.
inNamespace( $ns)
Returns true if the title is inside the specified namespace.
bool $mForcedContentModel
If a content model was forced via setContentModel() this will be true to avoid having other code path...
static newFromResult( $res)
isMovable()
Would anybody with sufficient privileges be able to move this page? Some pages just aren't movable.
$wgMaximumMovedPages
Maximum number of pages to move at once when moving subpages with a page.
wasLocalInterwiki()
Was this a local interwiki link?
if(!isset( $args[0])) $lang
isWikitextPage()
Does that page contain wikitext, or it is JS, CSS or whatever?
isUserCssConfigPage()
Is this a CSS "config" sub-page of a user page?
getBacklinkCache()
Get a backlink cache object.
getPartialURL()
Get the URL-encoded form of the main part.
$wgLegalTitleChars
Allowed title characters – regex character class Don't change this unless you know what you're doing.
static clearCaches()
Text form (spaces not underscores) of the main part.
Deferrable Update for closure/callback updates that should use auto-commit mode.
moveSubpages( $nt, $auth=true, $reason='', $createRedirect=true, array $changeTags=[])
Move this page's subpages to be subpages of $nt.
getTitleValue()
Get a TitleValue object representing this Title.
estimateRevisionCount()
Get the approximate revision count of this page.
countRevisionsBetween( $old, $new, $max=null)
Get the number of revisions between the given revision.
getPrefixedDBkey()
Get the prefixed database key form.
getDbPageLanguageCode()
Returns the page language code saved in the database, if $wgPageLanguageUseDB is set to true in Local...
getSkinFromConfigSubpage()
Trim down a .css, .json, or .js subpage title to get the corresponding skin name.
$wgScript
The URL path to index.php.
string $mUserCaseDBKey
Database key with the initial letter in the case specified by the user.
bool $mHasSubpages
Whether a page has any subpages.
getTalkPage()
Get a Title object associated with the talk page of this article.
static newMainPage()
Create a new Title for the Main Page.
const NEW_CLONE
Flag for use with factory methods like newFromLinkTarget() that have a $forceClone parameter.
getNotificationTimestamp( $user=null)
Get the timestamp when this page was updated since the user last saw it.
getParentCategoryTree( $children=[])
Get a tree of parent categories.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
static fixUrlQueryArgs( $query, $query2=false)
Helper to fix up the get{Canonical,Full,Link,Local,Internal}URL args get{Canonical,...
namespace and then decline to actually register it & $namespaces
fixSpecialName()
If the Title refers to a special page alias which is not the local default, resolve the alias,...
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
static getInterwikiLookup()
B/C kludge: provide an InterwikiLookup for use by Title.
isUserJsConfigPage()
Is this a JS "config" sub-page of a user page?
touchLinks()
Update page_touched timestamps and send CDN purge messages for pages linking to this title.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
getPrefixedText()
Get the prefixed title with spaces.
getTransWikiID()
Returns the DB name of the distant wiki which owns the object.
resultToError( $errors, $result)
Add the resulting error code to the errors array.
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
static escapeRegexReplacement( $string)
Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter.
getLinkURL( $query='', $query2=false, $proto=false)
Get a URL that's the simplest URL that will be valid to link, locally, to the current Title.
TitleValue null $mTitleValue
A corresponding TitleValue object.
secureAndSplit()
Secure and split - main initialisation function for this object.
quickUserCan( $action, $user=null)
Can $user perform $action on this page? This skips potentially expensive cascading permission checks ...
isTalkPage()
Is this a talk page of some sort?
wfReadOnly()
Check whether the wiki is in read-only mode.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
isExternal()
Is this Title interwiki?
loadRestrictionsFromRows( $rows, $oldFashionedRestrictions=null)
Compiles list of active page restrictions from both page table (pre 1.10) and page_restrictions table...
getDefaultMessageText()
Get the default (plain) message contents for an page that overrides an interface message key.
const CONTENT_MODEL_WIKITEXT
hasSourceText()
Does this page have source text?
loadFromRow( $row)
Load Title object fields from a DB row.
resetArticleID( $newid)
This clears some fields in this object, and clears any associated keys in the "bad links" section of ...
setFragment( $fragment)
Set the fragment for this title.
Interface for database access objects.
static getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility.
bool null $mIsBigDeletion
Would deleting this page be a big deletion?
static convertByteClassToUnicodeClass( $byteClass)
Utility method for converting a character sequence from bytes to Unicode.
__wakeup()
Text form (spaces not underscores) of the main part.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
getParentCategories()
Get categories to which this Title belongs and return an array of categories' names.
getLinksTo( $options=[], $table='pagelinks', $prefix='pl')
Get an array of Title objects linking to this Title Also stores the IDs in the link cache.
bool string $mContentModel
ID of the page's content model, i.e.
isSiteCssConfigPage()
Is this a sitewide CSS "config" page?
getNsText()
Get the namespace text.
string $mDbkeyform
Main part with underscores.
string $mUrlform
URL-encoded form of the main part.
getLinksFrom( $options=[], $table='pagelinks', $prefix='pl')
Get an array of Title objects linked from this Title Also stores the IDs in the link cache.
string bool $mOldRestrictions
Comma-separated set of permission keys indicating who can move or edit the page from the page table,...
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
isCascadeProtected()
Cascading protection: Return true if cascading restrictions apply to this page, false if not.
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
isValidMoveTarget( $nt)
Checks if $this can be moved to a given Title.
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
getCdnUrls()
Get a list of URLs to purge from the CDN cache when this page changes.
getOtherPage()
Get the other title for this page, if this is a subject page get the talk page, if it is a subject pa...
isSiteConfigPage()
Could this MediaWiki namespace page contain custom CSS, JSON, or JavaScript for the global UI.
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
isUserJsonConfigPage()
Is this a JSON "config" sub-page of a user page?
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title.
string[] $wgRawHtmlMessages
List of messages which might contain raw HTML.
getDBkey()
Get the main part with underscores.
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
static nameOf( $id)
Get the prefixed DB key associated with an ID.
string bool null $mDbPageLanguage
The page language code from the database, null if not saved in the database or false if not loaded,...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
isSpecial( $name)
Returns true if this title resolves to the named special page.
static getTitleFormatter()
B/C kludge: provide a TitleParser for use by Title.
namespace and then decline to actually register it file or subcat img or subcat $title
get( $key, $maxAge=0.0)
Get the value for a key.
isMainPage()
Is this the mainpage?
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
moveTo(&$nt, $auth=true, $reason='', $createRedirect=true, array $changeTags=[])
Move a title to a new location.
getSubpage( $text)
Get the title for a subpage of the current page.
getBaseTitle()
Get the base page name title, i.e.
getNamespace()
Get the namespace index, i.e.
static get(Title $title)
Create a new BacklinkCache or reuse any existing one.
static newFromRow( $row)
Make a Title object from a DB row.
isConversionTable()
Is this a conversion table for the LanguageConverter?
Handles the backend logic of moving a page from one title to another.
isProtected( $action='')
Does the title correspond to a protected article?
flushRestrictions()
Flush the protection cache in this object and force reload from the database.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
getCategorySortkey( $prefix='')
Returns the raw sort key to be used for categories, with the specified prefix.
getInterwiki()
Get the interwiki prefix.
isSiteJsonConfigPage()
Is this a sitewide JSON "config" page?
null for the wiki Added in
isValidRedirectTarget()
Check if this Title is a valid redirect target.
deleteTitleProtection()
Remove any title protection due to page existing.
userCan( $action, $user=null, $rigor=PermissionManager::RIGOR_SECURE)
Can $user perform $action on this page?
static isContent( $index)
Does this namespace contain content, for the purposes of calculating statistics, etc?
getBrokenLinksFrom()
Get an array of Title objects referring to non-existent articles linked from this page.
isUserConfigPage()
Is this a "config" (.css, .json, or .js) sub-page of a user page?
array $mCascadeSources
Where are the cascading restrictions coming from on this page?
getSubjectPage()
Get a title object associated with the subject page of this talk page.
Handles a simple LRU key/value map with a maximum number of entries.
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
loadRestrictions( $oldFashionedRestrictions=null, $flags=0)
Load restrictions from the page_restrictions table.
$wgInvalidRedirectTargets
Array of invalid page redirect targets.
getFullText()
Get the prefixed title with spaces, plus any fragment (part beginning with '#')
static hasTalkNamespace( $index)
Does this namespace ever have a talk namespace?
static hasSubpages( $index)
Does the namespace allow subpages?
hasFragment()
Check if a Title fragment is set.
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
getRedirectsHere( $ns=null)
Get all extant redirects to this Title.
static isMovable( $index)
Can pages in the given namespace be moved?
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
string $mInterwiki
Interwiki prefix.
bool $mCascadeRestriction
Cascade restrictions on this page to included templates and images?
equals(Title $title)
Compare with another title.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
getRootText()
Get the root page name text without a namespace, i.e.
$wgNamespaceProtection
Set the minimum permissions required to edit pages in each namespace.
canExist()
Is this in a namespace that allows actual pages?
$wgDeleteRevisionsLimit
Optional to restrict deletion of pages with higher revision counts to users with the 'bigdelete' perm...
string null $prefixedText
Text form including namespace/interwiki, initialised on demand.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
getCanonicalURL( $query='', $query2=false)
Get the URL for a canonical link, for use in things like IRC and e-mail notifications.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
static singleton()
Get the signleton instance of this class.
null $mRedirect
Is the article at this title a redirect?
createFragmentTarget( $fragment)
Creates a new Title for a different fragment of the same page.
int $mNamespace
Namespace index, i.e.
getDefaultNamespace()
Get the default namespace index, for when there is no namespace.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
static newFromTextThrow( $text, $defaultNamespace=NS_MAIN)
Like Title::newFromText(), but throws MalformedTitleException when the title is invalid,...
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
Allows to change the fields on the form that will be generated $name
isValid()
Returns true if the title is valid, false if it is invalid.
bool $mPageLanguage
The (string) language code of the page's language and content code.
Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
Class to invalidate the HTML cache of all the pages linking to a given title.
getPrefixedURL()
Get a URL-encoded title (not an actual URL) including interwiki.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
__toString()
Return a string representation of this title.
static hasFlags( $bitfield, $flags)
getTemplateLinksTo( $options=[])
Get an array of Title objects using this Title as a template Also stores the IDs in the link cache.
areRestrictionsCascading()
Returns cascading restrictions for the current article.
Handles purging appropriate CDN URLs given a title (or titles)
getLatestRevID( $flags=0)
What is the page_latest field for this page?
areRestrictionsLoaded()
Accessor for mRestrictionsLoaded.
getSubpages( $limit=-1)
Get all subpages of this page.
isSingleRevRedirect()
Checks if this page is just a one-rev redirect.
$wgServer
URL of the server.
const GAID_FOR_UPDATE
Used to be GAID_FOR_UPDATE define.
getPageViewLanguage()
Get the language in which the content of this page is written when viewed by user.
static newFromDBkey( $key)
Create a new Title from a prefixed DB key.
$wgLanguageCode
Site language code.
isSubpage()
Is this a subpage?
hasContentModel( $id)
Convenience method for checking a title's content model name.
getRestrictionExpiry( $action)
Get the expiry time for the restriction against a given action.
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
static invalidateModuleCache(Title $title, Revision $old=null, Revision $new=null, $domain)
Clear the preloadTitleInfo() cache for all wiki modules on this wiki on page change if it was a JS or...
isValidMoveOperation(&$nt, $auth=true, $reason='')
Check whether a given move operation would be valid.
array $mRestrictionsExpiry
When do the restrictions on this page expire?
set( $key, $value, $rank=self::RANK_TOP)
Set a key/value pair.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
isSubpageOf(Title $title)
Check if this title is a subpage of another title.
isLocal()
Determine whether the object refers to a page within this project (either this wiki or a wiki with a ...
string $mFragment
Title fragment (i.e.
getContentModel( $flags=0)
Get the page's content model id, see the CONTENT_MODEL_XXX constants.
array $mNotificationTimestamp
Associative array of user ID -> timestamp/false.
static exists( $index)
Returns whether the specified namespace exists.
static newFromIDs( $ids)
Make an array of titles from an array of IDs.
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new page object.
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
prefix( $name)
Prefix some arbitrary text with the namespace or interwiki prefix of this object.
getNamespaceKey( $prepend='nstab-')
Generate strings used for xml 'id' names in monobook tabs.
getEditURL()
Get the edit URL for this Title.
getFullURL( $query='', $query2=false, $proto=PROTO_RELATIVE)
Get a real URL referring to this title, with interwiki link and fragment.
wfFindFile( $title, $options=[])
Find a file.
isKnown()
Does this title refer to a page that can (or might) be meaningfully viewed? In particular,...
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of or an object and a method hook function The function part of a third party developers and administrators to define code that will be run at certain points in the mainline and to modify the data run by that mainline code Hooks can keep mainline code and make it easier to write extensions Hooks are a principled alternative to patches for two options in MediaWiki One reverses the order of a title before displaying the article
getFirstRevision( $flags=0)
Get the first revision of the page.
getAllRestrictions()
Accessor/initialisation for mRestrictions.
getEarliestRevTime( $flags=0)
Get the oldest revision timestamp of this page.
Represents a title within MediaWiki.
$mCascadingRestrictions
Caching the results of getCascadeProtectionSources.
getCascadeProtectionSources( $getPages=true)
Cascading protection: Get the source of any cascading restrictions on this page.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
$wgSemiprotectedRestrictionLevels
Restriction levels that should be considered "semiprotected".
getRestrictionTypes()
Returns restriction types for the current Title.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
getTitleProtectionInternal()
Fetch title protection settings.
getTemplateLinksFrom( $options=[])
Get an array of Title objects used on this Title as a template Also stores the IDs in the link cache.
isRedirect( $flags=0)
Is this an article that is a redirect page? Uses link cache, adding it if necessary.
static equals( $ns1, $ns2)
Returns whether the specified namespaces are the same namespace.
int $mArticleID
Article ID, fetched from the link cache on demand.
isDeleted()
Is there a version of this page in the deletion archive?
static capitalize( $text, $ns=NS_MAIN)
Capitalize a text string for a title if it belongs to a namespace that capitalizes.
int $mDefaultNamespace
Namespace index when there is no namespace.
int $mLength
The page length, 0 for special pages.
int $mEstimateRevisions
Estimated number of revisions; null of not loaded.
hasSubjectNamespace( $ns)
Returns true if the title has the same subject namespace as the namespace specified.
isSpecialPage()
Returns true if this is a special page.
purgeSquid()
Purge all applicable CDN URLs.
getPreviousRevisionID( $revId, $flags=0)
Get the revision ID of the previous revision.
The TitleArray class only exists to provide the newFromResult method at pre- sent.
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
getPageLanguage()
Get the language in which the content of this page is written in wikitext.
const CACHE_MAX
Title::newFromText maintains a cache to avoid expensive re-normalization of commonly used titles.
getEditNotices( $oldid=0)
Get a list of rendered edit notices for this page.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getTouched( $db=null)
Get the last touched timestamp.
static isCapitalized( $index)
Is the namespace first-letter capitalized?
$wgRestrictionLevels
Rights which can be required for each protection level (via action=protect)
getFragmentForURL()
Get the fragment in URL form, including the "#" character if there is one.
exists( $flags=0)
Check if page exists.
isAlwaysKnown()
Should links to this title be shown as potentially viewable (i.e.
isDeletedQuick()
Is there a version of this page in the deletion archive?
getSubpageUrlForm()
Get a URL-encoded form of the subpage text.
clear( $keys=null)
Clear one or several cache entries, or all cache entries.
static factory( $code)
Get a cached or new language object for a given language code.
isNewPage()
Check if this is a new page.
$wgRestrictionTypes
Set of available actions that can be restricted via action=protect You probably shouldn't change this...
setContentModel( $model)
Set a proposed content model for the page for permissions checking.
const CONTENT_MODEL_JAVASCRIPT
static compare(LinkTarget $a, LinkTarget $b)
Callback for usort() to do title sorts by (namespace, title)
countAuthorsBetween( $old, $new, $limit, $options=[])
Get the number of authors between the given revisions or revision IDs.
static legalChars()
Get a regex character class describing the legal characters in a link.
isSiteJsConfigPage()
Is this a sitewide JS "config" page?
static isWatchable( $index)
Can pages in a namespace be watched?
invalidateCache( $purgeTime=null)
Updates page_touched for this page; called from LinksUpdate.php.
if(! $wgDBerrorLogTZ) $wgRequest
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
isTrans()
Determine whether the object refers to a page within this project and is transcludable.
getRestrictions( $action)
Accessor/initialisation for mRestrictions.
static getTalk( $index)
Get the talk namespace index for a given namespace.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
static getSubject( $index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA,...
isContentPage()
Is this Title in a namespace which contains content? In other words, is this a content page,...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
wfLocalFile( $title)
Get an object referring to a locally registered file.
static MapCacheLRU null $titleCache
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
$wgVariantArticlePath
Like $wgArticlePath, but on multi-variant wikis, this provides a path format that describes which par...
getUserCaseDBKey()
Get the DB key with the initial letter case as specified by the user.
isRawHtmlMessage()
Is this a message which can contain raw HTML?
static getSelectFields()
Returns a list of fields that are to be selected for initializing Title objects or LinkCache entries.
hasSubpages()
Does this have subpages? (Warning, usually requires an extra DB query.)
getBaseText()
Get the base page name without a namespace, i.e.
pageCond()
Get an associative array for selecting this title from the "page" table.
getText()
Get the text form (spaces not underscores) of the main part.
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
string $mTextform
Text form (spaces not underscores) of the main part.
static purgeExpiredRestrictions()
Purge expired restrictions from the page_restrictions table.
$wgInternalServer
Internal server name as known to CDN, if different.
bool int $mLatestID
ID of most recent revision.
bool $mRestrictionsLoaded
Boolean for initialisation on demand.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
getSubjectNsText()
Get the namespace text of the subject (rather than talk) page.
getUserPermissionsErrors( $action, $user, $rigor=PermissionManager::RIGOR_SECURE, $ignoreErrors=[])
Can $user perform $action on this page?
mixed $mTitleProtection
Cached value for getTitleProtection (create protection)
Represents a page (or page fragment) title within MediaWiki.
static newFromTitleValue(TitleValue $titleValue, $forceClone='')
Returns a Title given a TitleValue.
getRelativeRevisionID( $revId, $flags, $dir)
Get next/previous revision ID relative to another revision ID.
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
getFullUrlForRedirect( $query='', $proto=PROTO_CURRENT)
Get a url appropriate for making redirects based on an untrusted url arg.
getRootTitle()
Get the root page name title, i.e.
getLength( $flags=0)
What is the length of this page? Uses link cache, adding it if necessary.
getAuthorsBetween( $old, $new, $limit, $options=[])
Get the authors between the given revisions or revision IDs.
isWatchable()
Can this title be added to a user's watchlist?