185 return MediaWikiServices::getInstance()->getTitleFormatter();
197 return MediaWikiServices::getInstance()->getInterwikiLookup();
216 $t->mDbkeyform = $key;
219 $t->secureAndSplit();
245 if ( $linkTarget instanceof
Title ) {
275 if ( $text !==
null && !is_string( $text ) && !is_int( $text ) ) {
276 throw new InvalidArgumentException(
'$text must be a string.' );
278 if ( $text ===
null ) {
307 if ( is_object( $text ) ) {
308 throw new MWException(
'$text must be a string, given an object' );
317 if ( $defaultNamespace ==
NS_MAIN ) {
328 $t->mDbkeyform = strtr( $filteredText,
' ',
'_' );
329 $t->mDefaultNamespace = intval( $defaultNamespace );
331 $t->secureAndSplit();
332 if ( $defaultNamespace ==
NS_MAIN ) {
356 # For compatibility with old buggy URLs. "+" is usually not valid in titles,
357 # but some URLs used it as a space replacement and they still come
358 # from some external search tools.
359 if ( strpos( self::legalChars(),
'+' ) ===
false ) {
360 $url = strtr( $url,
'+',
' ' );
363 $t->mDbkeyform = strtr( $url,
' ',
'_' );
366 $t->secureAndSplit();
377 if ( self::$titleCache ==
null ) {
378 self::$titleCache =
new HashBagOStuff( [
'maxKeys' => self::CACHE_MAX ] );
394 'page_namespace',
'page_title',
'page_id',
395 'page_len',
'page_is_redirect',
'page_latest',
399 $fields[] =
'page_content_model';
403 $fields[] =
'page_lang';
418 $row = $db->selectRow(
420 self::getSelectFields(),
421 [
'page_id' => $id ],
424 if ( $row !==
false ) {
439 if ( !count( $ids ) ) {
446 self::getSelectFields(),
447 [
'page_id' => $ids ],
452 foreach (
$res as $row ) {
466 $t->loadFromRow( $row );
478 if ( isset( $row->page_id ) ) {
479 $this->mArticleID = (int)$row->page_id;
481 if ( isset( $row->page_len ) ) {
482 $this->mLength = (int)$row->page_len;
484 if ( isset( $row->page_is_redirect ) ) {
485 $this->mRedirect = (bool)$row->page_is_redirect;
487 if ( isset( $row->page_latest ) ) {
488 $this->mLatestID = (int)$row->page_latest;
490 if ( !$this->mForcedContentModel && isset( $row->page_content_model ) ) {
491 $this->mContentModel = strval( $row->page_content_model );
492 } elseif ( !$this->mForcedContentModel ) {
495 if ( isset( $row->page_lang ) ) {
496 $this->mDbPageLanguage = (
string)$row->page_lang;
498 if ( isset( $row->page_restrictions ) ) {
499 $this->mOldRestrictions = $row->page_restrictions;
502 $this->mArticleID = 0;
504 $this->mRedirect =
false;
505 $this->mLatestID = 0;
506 if ( !$this->mForcedContentModel ) {
536 $t->mInterwiki = $interwiki;
537 $t->mFragment = $fragment;
538 $t->mNamespace = $ns = intval( $ns );
539 $t->mDbkeyform = strtr(
$title,
' ',
'_' );
540 $t->mArticleID = ( $ns >= 0 ) ? -1 : 0;
542 $t->mTextform = strtr(
$title,
'_',
' ' );
574 $t->secureAndSplit();
606 [
'page_namespace',
'page_title' ],
607 [
'page_id' => $id ],
610 if (
$s ===
false ) {
638 $length = strlen( $byteClass );
640 $x0 = $x1 = $x2 =
'';
642 $d0 = $d1 = $d2 =
'';
644 $ord0 = $ord1 = $ord2 = 0;
646 $r0 = $r1 = $r2 =
'';
650 $allowUnicode =
false;
651 for ( $pos = 0; $pos < $length; $pos++ ) {
662 $inChar = $byteClass[$pos];
663 if ( $inChar ==
'\\' ) {
664 if ( preg_match(
'/x([0-9a-fA-F]{2})/A', $byteClass, $m, 0, $pos + 1 ) ) {
665 $x0 = $inChar . $m[0];
666 $d0 = chr( hexdec( $m[1] ) );
667 $pos += strlen( $m[0] );
668 } elseif ( preg_match(
'/[0-7]{3}/A', $byteClass, $m, 0, $pos + 1 ) ) {
669 $x0 = $inChar . $m[0];
670 $d0 = chr( octdec( $m[0] ) );
671 $pos += strlen( $m[0] );
672 } elseif ( $pos + 1 >= $length ) {
675 $d0 = $byteClass[$pos + 1];
684 if ( $ord0 < 32 || $ord0 == 0x7f ) {
685 $r0 = sprintf(
'\x%02x', $ord0 );
686 } elseif ( $ord0 >= 0x80 ) {
688 $r0 = sprintf(
'\x%02x', $ord0 );
689 $allowUnicode =
true;
690 } elseif ( strpos(
'-\\[]^', $d0 ) !==
false ) {
696 if ( $x0 !==
'' && $x1 ===
'-' && $x2 !==
'' ) {
698 if ( $ord2 > $ord0 ) {
700 } elseif ( $ord0 >= 0x80 ) {
702 $allowUnicode =
true;
703 if ( $ord2 < 0x80 ) {
712 $x0 = $x1 = $d0 = $d1 = $r0 = $r1 =
'';
713 } elseif ( $ord2 < 0x80 ) {
718 if ( $ord1 < 0x80 ) {
721 if ( $ord0 < 0x80 ) {
724 if ( $allowUnicode ) {
725 $out .=
'\u0080-\uFFFF';
742 $canonicalNamespace =
false
746 if ( $canonicalNamespace ) {
751 $name = $namespace ==
'' ?
$title :
"$namespace:$title";
752 if ( strval( $interwiki ) !=
'' ) {
753 $name =
"$interwiki:$name";
755 if ( strval( $fragment ) !=
'' ) {
756 $name .=
'#' . $fragment;
771 # Note that we don't urlencode the fragment. urlencoded Unicode
772 # fragments appear not to work in IE (at least up to 7) or in at least
773 # one version of Opera 9.x. The W3C validator, for one, doesn't seem
774 # to care if they aren't encoded.
816 $parser = MediaWikiServices::getInstance()->getTitleParser();
835 return $iw->isLocal();
847 return $this->mInterwiki !==
'';
907 if ( $this->mTitleValue ===
null ) {
915 }
catch ( InvalidArgumentException $ex ) {
916 wfDebug( __METHOD__ .
': Can\'t create a TitleValue for [[' .
957 if ( !is_null( $this->mUserCaseDBKey ) ) {
981 if ( !$this->mForcedContentModel
982 && ( !$this->mContentModel || $flags === self::GAID_FOR_UPDATE )
986 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
987 $this->mContentModel = $linkCache->getGoodLinkFieldObj( $this,
'model' );
990 if ( !$this->mContentModel ) {
1019 $this->mContentModel = $model;
1020 $this->mForcedContentModel =
true;
1033 if ( $nsText !==
false ) {
1040 return $formatter->getNamespaceName( $this->mNamespace, $this->mDbkeyform );
1041 }
catch ( InvalidArgumentException $ex ) {
1042 wfDebug( __METHOD__ .
': ' . $ex->getMessage() .
"\n" );
1096 return $this->mNamespace >=
NS_MAIN;
1126 if (
$name == $thisName ) {
1142 if ( $canonicalName ) {
1144 if ( $localName != $this->mDbkeyform ) {
1244 return $this->
equals( self::newMainPage() );
1267 strpos( $this->
getText(),
'Conversiontable/' ) === 0;
1351 $subpage = explode(
'/', $this->mTextform );
1352 $subpage = $subpage[count( $subpage ) - 1];
1353 $lastdot = strrpos( $subpage,
'.' );
1354 if ( $lastdot ===
false ) {
1355 return $subpage; # Never happens: only called
for names ending
in '.css'/
'.json'/
'.js'
1357 return substr( $subpage, 0, $lastdot );
1489 throw new MWException(
'Special pages cannot have other pages' );
1495 throw new MWException(
"{$this->getPrefixedText()} does not have an other page" );
1528 return $this->mFragment !==
'';
1540 && !self::getInterwikiLookup()->fetch( $this->mInterwiki )->
isLocal()
1560 $this->mFragment = strtr( substr( $fragment, 1 ),
'_',
' ' );
1591 $p = $this->mInterwiki .
':';
1594 if ( 0 != $this->mNamespace ) {
1597 if ( $nsText ===
false ) {
1602 $p .= $nsText .
':';
1614 $s = $this->
prefix( $this->mDbkeyform );
1615 $s = strtr(
$s,
' ',
'_' );
1626 if ( $this->mPrefixedText ===
null ) {
1627 $s = $this->
prefix( $this->mTextform );
1628 $s = strtr(
$s,
'_',
' ' );
1629 $this->mPrefixedText =
$s;
1674 return strtok( $this->
getText(),
'/' );
1709 $parts = explode(
'/', $this->
getText() );
1710 # Don't discard the real title if there's no subpage involved
1711 if ( count( $parts ) > 1 ) {
1712 unset( $parts[count( $parts ) - 1] );
1714 return implode(
'/', $parts );
1748 $parts = explode(
'/', $this->mTextform );
1749 return $parts[count( $parts ) - 1];
1786 $s = $this->
prefix( $this->mDbkeyform );
1805 if ( $query2 !==
false ) {
1806 wfDeprecated(
"Title::get{Canonical,Full,Link,Local,Internal}URL " .
1807 "method called with a second parameter is deprecated. Add your " .
1808 "parameter to an array passed as the first parameter.",
"1.19" );
1810 if ( is_array(
$query ) ) {
1814 if ( is_string( $query2 ) ) {
1845 # Hand off all the decisions on urls to getLocalURL
1848 # Expand the url to make it a full url. Note that getLocalURL has the
1849 # potential to output full urls for a variety of reasons, so we use
1850 # wfExpandUrl instead of simply prepending $wgServer
1853 # Finally, add the fragment.
1885 return $target->getFullURL(
$query,
false, $proto );
1919 if ( $namespace !=
'' ) {
1920 # Can this actually happen? Interwikis shouldn't be parsed.
1921 # Yes! It can in interwiki transclusion. But... it probably shouldn't.
1924 $url = $interwiki->getURL( $namespace . $this->
getDBkey() );
1932 Hooks::run(
'GetLocalURL::Article', [ &$titleRef, &$url ] );
1939 && preg_match(
'/^(.*&|)action=([^&]*)(&(.*)|)$/',
$query,
$matches )
1941 $action = urldecode(
$matches[2] );
1960 $variant = urldecode(
$matches[1] );
1965 $url = str_replace(
'$1', $dbkey, $url );
1969 if ( $url ===
false ) {
1973 $url =
"{$wgScript}?title={$dbkey}&{$query}";
1982 if (
$wgRequest->getVal(
'action' ) ==
'render' ) {
2010 if ( $this->
isExternal() || $proto !==
false ) {
2133 $action,
$user, $rigor =
'secure', $ignoreErrors = []
2138 foreach ( $errors
as $index => $error ) {
2139 $errKey = is_array( $error ) ? $error[0] : $error;
2141 if ( in_array( $errKey, $ignoreErrors ) ) {
2142 unset( $errors[$index] );
2144 if ( $errKey instanceof
MessageSpecifier && in_array( $errKey->getKey(), $ignoreErrors ) ) {
2145 unset( $errors[$index] );
2165 [ $this,
$user, $action, &$errors, ( $rigor !==
'quick' ), $short ] )
2170 if ( $action ==
'create' ) {
2173 ( !$this->isTalkPage() && !
$user->isAllowed(
'createpage' ) )
2175 $errors[] =
$user->isAnon() ? [
'nocreatetext' ] : [
'nocreate-loggedin' ];
2177 } elseif ( $action ==
'move' ) {
2178 if ( !
$user->isAllowed(
'move-rootuserpages' )
2179 && $this->mNamespace ==
NS_USER && !$this->isSubpage() ) {
2181 $errors[] = [
'cant-move-user-page' ];
2185 if ( $this->mNamespace ==
NS_FILE && !
$user->isAllowed(
'movefile' ) ) {
2186 $errors[] = [
'movenotallowedfile' ];
2190 if ( $this->mNamespace ==
NS_CATEGORY && !
$user->isAllowed(
'move-categorypages' ) ) {
2191 $errors[] = [
'cant-move-category-page' ];
2194 if ( !
$user->isAllowed(
'move' ) ) {
2198 if (
$user->isAnon() && ( $userCanMove || $autoconfirmedCanMove ) ) {
2200 $errors[] = [
'movenologintext' ];
2202 $errors[] = [
'movenotallowed' ];
2205 } elseif ( $action ==
'move-target' ) {
2206 if ( !
$user->isAllowed(
'move' ) ) {
2208 $errors[] = [
'movenotallowed' ];
2209 } elseif ( !
$user->isAllowed(
'move-rootuserpages' )
2210 && $this->mNamespace ==
NS_USER && !$this->isSubpage() ) {
2212 $errors[] = [
'cant-move-to-user-page' ];
2213 } elseif ( !
$user->isAllowed(
'move-categorypages' )
2216 $errors[] = [
'cant-move-to-category-page' ];
2218 } elseif ( !
$user->isAllowed( $action ) ) {
2239 $errors = array_merge( $errors,
$result );
2246 } elseif (
$result ===
false ) {
2248 $errors[] = [
'badaccess-group0' ];
2270 return $result ? [] : [ [
'badaccess-group0' ] ];
2281 && !( $short && count( $errors ) > 0 )
2302 # Only 'createaccount' can be performed on special pages,
2303 # which don't actually exist in the DB.
2304 if ( $this->
isSpecialPage() && $action !==
'createaccount' ) {
2305 $errors[] = [
'ns-specialprotected' ];
2308 # Check $wgNamespaceProtection for restricted namespaces
2310 $ns = $this->mNamespace ==
NS_MAIN ?
2313 [
'protectedinterface', $action ] : [
'namespaceprotected', $ns, $action ];
2331 # Protect css/json/js subpages of user pages
2332 # XXX: this might be better using restrictions
2334 if ( $action !=
'patrol' ) {
2335 if ( preg_match(
'/^' . preg_quote(
$user->getName(),
'/' ) .
'\//', $this->mTextform ) ) {
2338 && !
$user->isAllowedAny(
'editmyusercss',
'editusercss' )
2340 $errors[] = [
'mycustomcssprotected', $action ];
2343 && !
$user->isAllowedAny(
'editmyuserjson',
'edituserjson' )
2345 $errors[] = [
'mycustomjsonprotected', $action ];
2348 && !
$user->isAllowedAny(
'editmyuserjs',
'edituserjs' )
2350 $errors[] = [
'mycustomjsprotected', $action ];
2355 && !
$user->isAllowed(
'editusercss' )
2357 $errors[] = [
'customcssprotected', $action ];
2360 && !
$user->isAllowed(
'edituserjson' )
2362 $errors[] = [
'customjsonprotected', $action ];
2365 && !
$user->isAllowed(
'edituserjs' )
2367 $errors[] = [
'customjsprotected', $action ];
2391 if ( $right ==
'sysop' ) {
2392 $right =
'editprotected';
2395 if ( $right ==
'autoconfirmed' ) {
2396 $right =
'editsemiprotected';
2398 if ( $right ==
'' ) {
2401 if ( !
$user->isAllowed( $right ) ) {
2402 $errors[] = [
'protectedpagetext', $right, $action ];
2403 } elseif ( $this->mCascadeRestriction && !
$user->isAllowed(
'protect' ) ) {
2404 $errors[] = [
'protectedpagetext',
'protect', $action ];
2424 # We /could/ use the protection level on the source page, but it's
2425 # fairly ugly as we have to establish a precedence hierarchy for pages
2426 # included by multiple cascade-protected pages. So just restrict
2427 # it to people with 'protect' permission, as they could remove the
2428 # protection anyway.
2430 # Cascading protection depends on more than this page...
2431 # Several cascading protected pages may include this page...
2432 # Check each cascading level
2433 # This is only for protection restrictions, not for all actions
2434 if ( isset( $restrictions[$action] ) ) {
2435 foreach ( $restrictions[$action]
as $right ) {
2437 if ( $right ==
'sysop' ) {
2438 $right =
'editprotected';
2441 if ( $right ==
'autoconfirmed' ) {
2442 $right =
'editsemiprotected';
2444 if ( $right !=
'' && !
$user->isAllowedAll(
'protect', $right ) ) {
2446 foreach ( $cascadingSources
as $page ) {
2447 $pages .=
'* [[:' . $page->getPrefixedText() .
"]]\n";
2449 $errors[] = [
'cascadeprotected', count( $cascadingSources ), $pages, $action ];
2472 if ( $action ==
'protect' ) {
2475 $errors[] = [
'protect-cantedit' ];
2477 } elseif ( $action ==
'create' ) {
2479 if ( $title_protection ) {
2480 if ( $title_protection[
'permission'] ==
''
2481 || !
$user->isAllowed( $title_protection[
'permission'] )
2486 $title_protection[
'reason']
2490 } elseif ( $action ==
'move' ) {
2494 $errors[] = [
'immobile-source-namespace', $this->
getNsText() ];
2497 $errors[] = [
'immobile-source-page' ];
2499 } elseif ( $action ==
'move-target' ) {
2501 $errors[] = [
'immobile-target-namespace', $this->
getNsText() ];
2503 $errors[] = [
'immobile-target-page' ];
2505 } elseif ( $action ==
'delete' ) {
2507 if ( !$tempErrors ) {
2509 $user, $tempErrors, $rigor,
true );
2511 if ( $tempErrors ) {
2513 $errors[] = [
'deleteprotected' ];
2520 } elseif ( $action ===
'undelete' ) {
2523 $errors[] = [
'undelete-cantedit' ];
2529 $errors[] = [
'undelete-cantcreate' ];
2550 if ( $rigor ===
'quick' || in_array( $action, [
'createaccount',
'unblock' ] ) ) {
2560 && !
$user->isEmailConfirmed()
2561 && $action ===
'edit'
2563 $errors[] = [
'confirmedittext' ];
2566 $useSlave = ( $rigor !==
'secure' );
2567 if ( ( $action ==
'edit' || $action ==
'create' )
2568 && !
$user->isBlockedFrom( $this, $useSlave )
2572 } elseif (
$user->isBlocked() &&
$user->getBlock()->prevents( $action ) !==
false ) {
2594 $whitelisted =
false;
2596 # Shortcut for public wikis, allows skipping quite a bit of code
2597 $whitelisted =
true;
2598 } elseif (
$user->isAllowed(
'read' ) ) {
2599 # If the user is allowed to read pages, he is allowed to read all pages
2600 $whitelisted =
true;
2601 } elseif ( $this->
isSpecial(
'Userlogin' )
2605 # Always grant access to the login page.
2606 # Even anons need to be able to log in.
2607 $whitelisted =
true;
2609 # Time to check the whitelist
2610 # Only do these checks is there's something to check against
2616 $whitelisted =
true;
2618 # Old settings might have the title prefixed with
2619 # a colon for main-namespace pages
2621 $whitelisted =
true;
2624 # If it's a special page, ditch the subpage bit and check again
2630 $whitelisted =
true;
2639 foreach ( $wgWhitelistReadRegexp
as $listItem ) {
2640 if ( preg_match( $listItem,
$name ) ) {
2641 $whitelisted =
true;
2647 if ( !$whitelisted ) {
2648 # If the title is not whitelisted, give extensions a chance to do so...
2650 if ( !$whitelisted ) {
2669 return [
'badaccess-group0' ];
2690 $action,
$user, $rigor =
'secure', $short =
false
2692 if ( $rigor ===
true ) {
2694 } elseif ( $rigor ===
false ) {
2696 } elseif ( !in_array( $rigor, [
'quick',
'full',
'secure' ] ) ) {
2697 throw new Exception(
"Invalid rigor parameter '$rigor'." );
2700 # Read has special handling
2701 if ( $action ==
'read' ) {
2703 'checkPermissionHooks',
2704 'checkReadPermissions',
2707 # Don't call checkSpecialsAndNSPermissions or checkUserConfigPermissions
2708 # here as it will lead to duplicate error messages. This is okay to do
2709 # since anywhere that checks for create will also check for edit, and
2710 # those checks are called for edit.
2711 } elseif ( $action ==
'create' ) {
2713 'checkQuickPermissions',
2714 'checkPermissionHooks',
2715 'checkPageRestrictions',
2716 'checkCascadingSourcesRestrictions',
2717 'checkActionPermissions',
2722 'checkQuickPermissions',
2723 'checkPermissionHooks',
2724 'checkSpecialsAndNSPermissions',
2725 'checkUserConfigPermissions',
2726 'checkPageRestrictions',
2727 'checkCascadingSourcesRestrictions',
2728 'checkActionPermissions',
2734 while ( count( $checks ) > 0 &&
2735 !( $short && count( $errors ) > 0 ) ) {
2736 $method = array_shift( $checks );
2737 $errors = $this->$method( $action,
$user, $errors, $rigor, $short );
2754 # Remove the create restriction for existing titles
2755 $types = array_diff( $types, [
'create' ] );
2757 # Only the create and upload restrictions apply to non-existing titles
2758 $types = array_intersect( $types, [
'create',
'upload' ] );
2776 # Remove the upload restriction for non-file titles
2777 $types = array_diff( $types, [
'upload' ] );
2780 Hooks::run(
'TitleGetRestrictionTypes', [ $this, &$types ] );
2782 wfDebug( __METHOD__ .
': applicable restrictions to [[' .
2783 $this->
getPrefixedText() .
']] are {' . implode(
',', $types ) .
"}\n" );
2797 if ( $protection ) {
2798 if ( $protection[
'permission'] ==
'sysop' ) {
2799 $protection[
'permission'] =
'editprotected';
2801 if ( $protection[
'permission'] ==
'autoconfirmed' ) {
2802 $protection[
'permission'] =
'editsemiprotected';
2829 if ( $this->mTitleProtection ===
null ) {
2832 $commentQuery = $commentStore->getJoin(
'pt_reason' );
2834 [
'protected_titles' ] + $commentQuery[
'tables'],
2836 'user' =>
'pt_user',
2837 'expiry' =>
'pt_expiry',
2838 'permission' =>
'pt_create_perm'
2839 ] + $commentQuery[
'fields'],
2843 $commentQuery[
'joins']
2849 $this->mTitleProtection = [
2850 'user' => $row[
'user'],
2851 'expiry' =>
$dbr->decodeExpiry( $row[
'expiry'] ),
2852 'permission' => $row[
'permission'],
2853 'reason' => $commentStore->getComment(
'pt_reason', $row )->text,
2856 $this->mTitleProtection =
false;
2873 $this->mTitleProtection =
false;
2888 if ( !$restrictions || !$semi ) {
2894 foreach ( array_keys( $semi,
'autoconfirmed' )
as $key ) {
2895 $semi[$key] =
'editsemiprotected';
2897 foreach ( array_keys( $restrictions,
'autoconfirmed' )
as $key ) {
2898 $restrictions[$key] =
'editsemiprotected';
2901 return !array_diff( $restrictions, $semi );
2916 # Special pages have inherent protection
2921 # Check regular protection levels
2922 foreach ( $restrictionTypes
as $type ) {
2923 if ( $action ==
$type || $action ==
'' ) {
2926 if ( in_array( $level, $r ) && $level !=
'' ) {
2948 if ( $right !=
'' && !
$user->isAllowed( $right ) ) {
2963 return ( $sources > 0 );
2976 return $getPages ? $this->mCascadeSources !== null : $this->mHasCascadingRestrictions !==
null;
2993 $pagerestrictions = [];
2995 if ( $this->mCascadeSources !==
null && $getPages ) {
2997 } elseif ( $this->mHasCascadingRestrictions !==
null && !$getPages ) {
3004 $tables = [
'imagelinks',
'page_restrictions' ];
3011 $tables = [
'templatelinks',
'page_restrictions' ];
3021 $cols = [
'pr_page',
'page_namespace',
'page_title',
3022 'pr_expiry',
'pr_type',
'pr_level' ];
3023 $where_clauses[] =
'page_id=pr_page';
3026 $cols = [
'pr_expiry' ];
3031 $sources = $getPages ? [] :
false;
3034 foreach (
$res as $row ) {
3035 $expiry =
$dbr->decodeExpiry( $row->pr_expiry );
3036 if ( $expiry > $now ) {
3038 $page_id = $row->pr_page;
3039 $page_ns = $row->page_namespace;
3040 $page_title = $row->page_title;
3042 # Add groups needed for each restriction type if its not already there
3043 # Make sure this restriction type still exists
3045 if ( !isset( $pagerestrictions[$row->pr_type] ) ) {
3046 $pagerestrictions[$row->pr_type] = [];
3050 isset( $pagerestrictions[$row->pr_type] )
3051 && !in_array( $row->pr_level, $pagerestrictions[$row->pr_type] )
3053 $pagerestrictions[$row->pr_type][] = $row->pr_level;
3062 $this->mCascadeSources = $sources;
3063 $this->mCascadingRestrictions = $pagerestrictions;
3065 $this->mHasCascadingRestrictions = $sources;
3068 return [ $sources, $pagerestrictions ];
3092 if ( !$this->mRestrictionsLoaded ) {
3095 return isset( $this->mRestrictions[$action] )
3096 ? $this->mRestrictions[$action]
3108 if ( !$this->mRestrictionsLoaded ) {
3122 if ( !$this->mRestrictionsLoaded ) {
3125 return isset( $this->mRestrictionsExpiry[$action] ) ? $this->mRestrictionsExpiry[$action] :
false;
3134 if ( !$this->mRestrictionsLoaded ) {
3157 foreach ( $restrictionTypes
as $type ) {
3158 $this->mRestrictions[
$type] = [];
3159 $this->mRestrictionsExpiry[
$type] =
'infinity';
3162 $this->mCascadeRestriction =
false;
3164 # Backwards-compatibility: also load the restrictions from the page record (old format).
3165 if ( $oldFashionedRestrictions !==
null ) {
3166 $this->mOldRestrictions = $oldFashionedRestrictions;
3169 if ( $this->mOldRestrictions ===
false ) {
3170 $this->mOldRestrictions =
$dbr->selectField(
'page',
'page_restrictions',
3174 if ( $this->mOldRestrictions !=
'' ) {
3175 foreach ( explode(
':', trim( $this->mOldRestrictions ) )
as $restrict ) {
3176 $temp = explode(
'=', trim( $restrict ) );
3177 if ( count( $temp ) == 1 ) {
3179 $this->mRestrictions[
'edit'] = explode(
',', trim( $temp[0] ) );
3180 $this->mRestrictions[
'move'] = explode(
',', trim( $temp[0] ) );
3182 $restriction = trim( $temp[1] );
3183 if ( $restriction !=
'' ) {
3184 $this->mRestrictions[$temp[0]] = explode(
',', $restriction );
3190 if ( count(
$rows ) ) {
3191 # Current system - load second to make them override.
3194 # Cycle through all the restrictions.
3197 if ( !in_array( $row->pr_type, $restrictionTypes ) ) {
3201 $expiry =
$dbr->decodeExpiry( $row->pr_expiry );
3204 if ( !$expiry || $expiry > $now ) {
3205 $this->mRestrictionsExpiry[$row->pr_type] = $expiry;
3206 $this->mRestrictions[$row->pr_type] = explode(
',', trim( $row->pr_level ) );
3208 $this->mCascadeRestriction |= $row->pr_cascade;
3213 $this->mRestrictionsLoaded =
true;
3225 if ( $this->mRestrictionsLoaded ) {
3234 $cache->makeKey(
'page-restrictions', $id, $this->getLatestRevID() ),
3239 $setOpts += Database::getCacheSetOptions(
$dbr );
3241 return iterator_to_array(
3243 'page_restrictions',
3244 [
'pr_type',
'pr_expiry',
'pr_level',
'pr_cascade' ],
3245 [
'pr_page' => $this->getArticleID() ],
3256 if ( $title_protection ) {
3260 if ( !$expiry || $expiry > $now ) {
3262 $this->mRestrictionsExpiry[
'create'] = $expiry;
3263 $this->mRestrictions[
'create'] =
3264 explode(
',', trim( $title_protection[
'permission'] ) );
3266 $this->mTitleProtection =
false;
3269 $this->mRestrictionsExpiry[
'create'] =
'infinity';
3271 $this->mRestrictionsLoaded =
true;
3280 $this->mRestrictionsLoaded =
false;
3281 $this->mTitleProtection =
null;
3298 $config = MediaWikiServices::getInstance()->getMainConfig();
3300 'page_restrictions',
3304 [
'LIMIT' => $config->get(
'UpdateRowsPerQuery' ) ]
3307 $dbw->
delete(
'page_restrictions', [
'pr_id' => $ids ],
$fname );
3336 # We dynamically add a member variable for the purpose of this method
3337 # alone to cache the result. There's no point in having it hanging
3338 # around uninitialized in every Title object; therefore we only add it
3339 # if needed and don't declare it statically.
3340 if ( $this->mHasSubpages ===
null ) {
3341 $this->mHasSubpages =
false;
3344 $this->mHasSubpages = (bool)$subpages->count();
3365 $conds[] =
'page_title ' .
$dbr->buildLike( $this->
getDBkey() .
'/',
$dbr->anyString() );
3367 if ( $limit > -1 ) {
3371 $dbr->select(
'page',
3372 [
'page_id',
'page_namespace',
'page_title',
'page_is_redirect' ],
3391 $n =
$dbr->selectField(
'archive',
'COUNT(*)',
3396 $n +=
$dbr->selectField(
'filearchive',
'COUNT(*)',
3397 [
'fa_name' => $this->
getDBkey() ],
3415 $deleted = (bool)
$dbr->selectField(
'archive',
'1',
3416 [
'ar_namespace' => $this->getNamespace(),
'ar_title' => $this->
getDBkey() ],
3420 $deleted = (bool)
$dbr->selectField(
'filearchive',
'1',
3421 [
'fa_name' => $this->getDBkey() ],
3438 $this->mArticleID = 0;
3442 if ( $flags & self::GAID_FOR_UPDATE ) {
3443 $oldUpdate = $linkCache->forUpdate(
true );
3444 $linkCache->clearLink( $this );
3445 $this->mArticleID = $linkCache->addLinkObj( $this );
3446 $linkCache->forUpdate( $oldUpdate );
3448 if ( -1 == $this->mArticleID ) {
3449 $this->mArticleID = $linkCache->addLinkObj( $this );
3463 if ( !is_null( $this->mRedirect ) ) {
3467 $this->mRedirect =
false;
3472 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
3473 $cached = $linkCache->getGoodLinkFieldObj( $this,
'redirect' );
3474 if ( $cached ===
null ) {
3475 # Trust LinkCache's state over our own
3476 # LinkCache is telling us that the page doesn't exist, despite there being cached
3477 # data relating to an existing page in $this->mArticleID. Updaters should clear
3478 # LinkCache as appropriate, or use $flags = Title::GAID_FOR_UPDATE. If that flag is
3479 # set, then LinkCache will definitely be up to date here, since getArticleID() forces
3480 # LinkCache to refresh its data from the master.
3481 $this->mRedirect =
false;
3485 $this->mRedirect = (bool)$cached;
3498 if ( $this->mLength != -1 ) {
3506 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
3507 $cached = $linkCache->getGoodLinkFieldObj( $this,
'length' );
3508 if ( $cached ===
null ) {
3509 # Trust LinkCache's state over our own, as for isRedirect()
3514 $this->mLength = intval( $cached );
3526 if ( !( $flags & self::GAID_FOR_UPDATE ) && $this->mLatestID !==
false ) {
3527 return intval( $this->mLatestID );
3530 $this->mLatestID = 0;
3534 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
3535 $cached = $linkCache->getGoodLinkFieldObj( $this,
'revision' );
3536 if ( $cached ===
null ) {
3537 # Trust LinkCache's state over our own, as for isRedirect()
3538 $this->mLatestID = 0;
3542 $this->mLatestID = intval( $cached );
3559 $linkCache->clearLink( $this );
3561 if ( $newid ===
false ) {
3562 $this->mArticleID = -1;
3564 $this->mArticleID = intval( $newid );
3566 $this->mRestrictionsLoaded =
false;
3567 $this->mRestrictions = [];
3568 $this->mOldRestrictions =
false;
3569 $this->mRedirect =
null;
3570 $this->mLength = -1;
3571 $this->mLatestID =
false;
3572 $this->mContentModel =
false;
3573 $this->mEstimateRevisions =
null;
3574 $this->mPageLanguage =
false;
3575 $this->mDbPageLanguage =
false;
3576 $this->mIsBigDeletion =
null;
3581 $linkCache->clear();
3618 $this->mInterwiki =
'';
3619 $this->mFragment =
'';
3629 $titleCodec = MediaWikiServices::getInstance()->getTitleParser();
3635 $this->mInterwiki = $parts[
'interwiki'];
3636 $this->mLocalInterwiki = $parts[
'local_interwiki'];
3637 $this->mNamespace = $parts[
'namespace'];
3638 $this->mUserCaseDBKey = $parts[
'user_case_dbkey'];
3640 $this->mDbkeyform = $parts[
'dbkey'];
3641 $this->mUrlform =
wfUrlencode( $this->mDbkeyform );
3642 $this->mTextform = strtr( $this->mDbkeyform,
'_',
' ' );
3644 # We already know that some pages won't be in the database!
3646 $this->mArticleID = 0;
3673 self::getSelectFields(),
3675 "{$prefix}_from=page_id",
3677 "{$prefix}_title" => $this->
getDBkey() ],
3683 if (
$res->numRows() ) {
3685 foreach (
$res as $row ) {
3686 $titleObj =
self::makeTitle( $row->page_namespace, $row->page_title );
3688 $linkCache->addGoodLinkObjFromRow( $titleObj, $row );
3689 $retVal[] = $titleObj;
3725 # If the page doesn't exist; there can't be any link from this page
3732 $blNamespace =
"{$prefix}_namespace";
3733 $blTitle =
"{$prefix}_title";
3737 [ $table,
'nestpage' => $pageQuery[
'tables'] ],
3739 [ $blNamespace, $blTitle ],
3740 $pageQuery[
'fields']
3742 [
"{$prefix}_from" => $id ],
3747 [
"page_namespace=$blNamespace",
"page_title=$blTitle" ]
3748 ] ] + $pageQuery[
'joins']
3753 foreach (
$res as $row ) {
3754 if ( $row->page_id ) {
3758 $linkCache->addBadLinkObj( $titleObj );
3760 $retVal[] = $titleObj;
3790 # All links from article ID 0 are false positives
3796 [
'page',
'pagelinks' ],
3797 [
'pl_namespace',
'pl_title' ],
3800 'page_namespace IS NULL'
3806 [
'pl_namespace=page_namespace',
'pl_title=page_title' ]
3812 foreach (
$res as $row ) {
3831 if ( $pageLang->hasVariants() ) {
3832 $variants = $pageLang->getVariants();
3833 foreach ( $variants
as $vCode ) {
3881 if ( !( $nt instanceof
Title ) ) {
3884 return [ [
'badtitletext' ] ];
3888 $errors = $mp->isValidMove()->getErrorsArray();
3892 $mp->checkPermissions(
$wgUser, $reason )->getErrorsArray()
3896 return $errors ?:
true;
3911 $destFile->load( File::READ_LATEST );
3912 if ( !
$wgUser->isAllowed(
'reupload-shared' )
3915 $errors[] = [
'file-exists-sharedrepo' ];
3934 public function moveTo( &$nt, $auth =
true, $reason =
'', $createRedirect =
true,
3935 array $changeTags = []
3939 if ( is_array( $err ) ) {
3941 $wgUser->spreadAnyEditBlock();
3945 if ( $auth && !
$wgUser->isAllowed(
'suppressredirect' ) ) {
3946 $createRedirect =
true;
3950 $status = $mp->move(
$wgUser, $reason, $createRedirect, $changeTags );
3954 return $status->getErrorsArray();
3972 public function moveSubpages( $nt, $auth =
true, $reason =
'', $createRedirect =
true,
3973 array $changeTags = []
3977 if ( !$this->
userCan(
'move-subpages' ) ) {
3979 [
'cant-move-subpages' ],
3994 $subpages = $this->
getSubpages( $wgMaximumMovedPages + 1 );
3997 foreach ( $subpages
as $oldSubpage ) {
4000 $retval[$oldSubpage->getPrefixedText()] = [
4009 if ( $oldSubpage->getArticleID() == $this->getArticleID()
4010 || $oldSubpage->getArticleID() == $nt->getArticleID()
4016 $newPageName = preg_replace(
4017 '#^' . preg_quote( $this->
getDBkey(),
'#' ) .
'#',
4019 $oldSubpage->getDBkey() );
4020 if ( $oldSubpage->isTalkPage() ) {
4021 $newNs = $nt->getTalkPage()->getNamespace();
4023 $newNs = $nt->getSubjectPage()->getNamespace();
4025 # T16385: we need makeTitleSafe because the new page names may
4026 # be longer than 255 characters.
4029 $success = $oldSubpage->moveTo( $newSubpage, $auth, $reason, $createRedirect, $changeTags );
4031 $retval[$oldSubpage->getPrefixedText()] = $newSubpage->getPrefixedText();
4051 $fields = [
'page_is_redirect',
'page_latest',
'page_id' ];
4053 $fields[] =
'page_content_model';
4056 $row = $dbw->selectRow(
'page',
4062 # Cache some fields we may want
4063 $this->mArticleID = $row ? intval( $row->page_id ) : 0;
4064 $this->mRedirect = $row ? (bool)$row->page_is_redirect :
false;
4065 $this->mLatestID = $row ? intval( $row->page_latest ) :
false;
4066 $this->mContentModel = $row && isset( $row->page_content_model )
4067 ? strval( $row->page_content_model )
4070 if ( !$this->mRedirect ) {
4073 # Does the article have a history?
4074 $row = $dbw->selectField( [
'page',
'revision' ],
4079 'page_latest != rev_id'
4084 # Return true if there was no history
4085 return ( $row ===
false );
4097 # Is it an existing file?
4098 if ( $nt->getNamespace() ==
NS_FILE ) {
4100 $file->load( File::READ_LATEST );
4101 if ( $file->exists() ) {
4102 wfDebug( __METHOD__ .
": file exists\n" );
4106 # Is it a redirect with no history?
4107 if ( !$nt->isSingleRevRedirect() ) {
4108 wfDebug( __METHOD__ .
": not a one-rev redirect\n" );
4111 # Get the article text
4113 if ( !is_object(
$rev ) ) {
4116 $content =
$rev->getContent();
4117 # Does the redirect point to the source?
4118 # Or is it a broken self-redirect, usually caused by namespace collisions?
4119 $redirTitle = $content ? $content->getRedirectTarget() :
null;
4121 if ( $redirTitle ) {
4122 if ( $redirTitle->getPrefixedDBkey() != $this->getPrefixedDBkey() &&
4123 $redirTitle->getPrefixedDBkey() != $nt->getPrefixedDBkey() ) {
4124 wfDebug( __METHOD__ .
": redirect points to other page\n" );
4130 # Fail safe (not a redirect after all. strange.)
4131 wfDebug( __METHOD__ .
": failsafe: database sais " . $nt->getPrefixedDBkey() .
4132 " is a redirect, but it doesn't contain a valid redirect.\n" );
4151 if ( $titleKey === 0 ) {
4160 [
'cl_from' => $titleKey ],
4164 if (
$res->numRows() > 0 ) {
4165 foreach (
$res as $row ) {
4184 foreach ( $parents
as $parent => $current ) {
4185 if ( array_key_exists( $parent, $children ) ) {
4186 # Circular reference
4187 $stack[$parent] = [];
4191 $stack[$parent] = $nt->getParentCategoryTree( $children + [ $parent => 1 ] );
4207 if ( $this->mArticleID > 0 ) {
4223 $revId = (int)$revId;
4224 if ( $dir ===
'next' ) {
4227 } elseif ( $dir ===
'prev' ) {
4231 throw new InvalidArgumentException(
'$dir must be "next" or "prev"' );
4234 if ( $flags & self::GAID_FOR_UPDATE ) {
4242 $ts = $db->selectField(
'revision',
'rev_timestamp', [
'rev_id' => $revId ], __METHOD__ );
4243 if ( $ts ===
false ) {
4244 $ts = $db->selectField(
'archive',
'ar_timestamp', [
'ar_rev_id' => $revId ], __METHOD__ );
4245 if ( $ts ===
false ) {
4250 $ts = $db->addQuotes( $ts );
4252 $revId = $db->selectField(
'revision',
'rev_id',
4255 "rev_timestamp $op $ts OR (rev_timestamp = $ts AND rev_id $op $revId)"
4259 'ORDER BY' =>
"rev_timestamp $sort, rev_id $sort",
4260 'IGNORE INDEX' =>
'rev_timestamp',
4264 if ( $revId ===
false ) {
4267 return intval( $revId );
4305 [
'rev_page' => $pageId ],
4308 'ORDER BY' =>
'rev_timestamp ASC, rev_id ASC',
4309 'IGNORE INDEX' => [
'revision' =>
'rev_timestamp' ],
4328 return $rev ?
$rev->getTimestamp() :
null;
4338 return (
bool)
$dbr->selectField(
'page',
'page_is_new', $this->
pageCond(), __METHOD__ );
4353 if ( $this->mIsBigDeletion ===
null ) {
4356 $revCount =
$dbr->selectRowCount(
4376 if ( !$this->
exists() ) {
4380 if ( $this->mEstimateRevisions ===
null ) {
4382 $this->mEstimateRevisions =
$dbr->estimateRowCount(
'revision',
'*',
4399 if ( !( $old instanceof
Revision ) ) {
4402 if ( !( $new instanceof
Revision ) ) {
4405 if ( !$old || !$new ) {
4411 'rev_timestamp > ' .
$dbr->addQuotes(
$dbr->timestamp( $old->getTimestamp() ) ),
4412 'rev_timestamp < ' .
$dbr->addQuotes(
$dbr->timestamp( $new->getTimestamp() ) )
4414 if ( $max !==
null ) {
4415 return $dbr->selectRowCount(
'revision',
'1',
4418 [
'LIMIT' => $max + 1 ]
4421 return (
int)
$dbr->selectField(
'revision',
'count(*)', $conds, __METHOD__ );
4442 if ( !( $old instanceof
Revision ) ) {
4445 if ( !( $new instanceof
Revision ) ) {
4451 if ( !$old || !$new ) {
4458 if ( in_array(
'include_old',
$options ) ) {
4461 if ( in_array(
'include_new',
$options ) ) {
4464 if ( in_array(
'include_both',
$options ) ) {
4469 if ( $old->getId() === $new->getId() ) {
4470 return ( $old_cmp ===
'>' && $new_cmp ===
'<' ) ?
4473 } elseif ( $old->getId() === $new->getParentId() ) {
4474 if ( $old_cmp ===
'>=' && $new_cmp ===
'<=' ) {
4479 } elseif ( $old_cmp ===
'>=' ) {
4481 } elseif ( $new_cmp ===
'<=' ) {
4488 $authors =
$dbr->selectFieldValues(
4493 "rev_timestamp $old_cmp " .
$dbr->addQuotes(
$dbr->timestamp( $old->getTimestamp() ) ),
4494 "rev_timestamp $new_cmp " .
$dbr->addQuotes(
$dbr->timestamp( $new->getTimestamp() ) )
4496 [
'DISTINCT',
'LIMIT' => $limit + 1 ],
4518 return $authors ? count( $authors ) : 0;
4559 Hooks::run(
'TitleExists', [ $this, &$exists ] );
4592 Hooks::run(
'TitleIsAlwaysKnown', [ $this, &$isKnown ] );
4594 if ( !is_null( $isKnown ) ) {
4602 switch ( $this->mNamespace ) {
4612 return $this->mDbkeyform ==
'';
4656 return $message->exists();
4675 $wgContLang->lcfirst( $this->getText() )
4679 if ( $message->exists() ) {
4680 return $message->plain();
4695 } elseif ( $this->mArticleID === 0 ) {
4700 $dbw->onTransactionPreCommitOrIdle(
function () {
4710 $dbTimestamp = $dbw->
timestamp( $purgeTime ?: time() );
4713 [
'page_touched' => $dbTimestamp ],
4714 $conds + [
'page_touched < ' . $dbw->
addQuotes( $dbTimestamp ) ],
4717 MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $this );
4747 if ( $db ===
null ) {
4750 $touched = $db->selectField(
'page',
'page_touched', $this->
pageCond(), __METHOD__ );
4768 $uid =
$user->getId();
4773 if ( array_key_exists( $uid, $this->mNotificationTimestamp ) ) {
4774 return $this->mNotificationTimestamp[$uid];
4777 if ( count( $this->mNotificationTimestamp ) >= self::CACHE_MAX ) {
4778 $this->mNotificationTimestamp = [];
4781 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
4782 $watchedItem = $store->getWatchedItem(
$user, $this );
4783 if ( $watchedItem ) {
4784 $this->mNotificationTimestamp[$uid] = $watchedItem->getNotificationTimestamp();
4786 $this->mNotificationTimestamp[$uid] =
false;
4789 return $this->mNotificationTimestamp[$uid];
4804 if ( $namespaceKey ===
false ) {
4811 if ( $namespaceKey ==
'' ) {
4812 $namespaceKey =
'main';
4815 if ( $namespaceKey ==
'file' ) {
4816 $namespaceKey =
'image';
4818 return $prepend . $namespaceKey;
4839 $where[] =
'rd_interwiki = ' .
$dbr->addQuotes(
'' ) .
' OR rd_interwiki IS NULL';
4841 if ( !is_null( $ns ) ) {
4842 $where[
'page_namespace'] = $ns;
4846 [
'redirect',
'page' ],
4847 [
'page_namespace',
'page_title' ],
4852 foreach (
$res as $row ) {
4868 if ( $this->
isSpecial(
'Userlogout' ) ) {
4872 foreach ( $wgInvalidRedirectTargets
as $target ) {
4903 return !in_array( $this->mNamespace, $bannedNamespaces );
4917 $unprefixed = $this->
getText();
4923 Hooks::run(
'GetDefaultSortkey', [ $this, &$unprefixed ] );
4924 if ( $prefix !==
'' ) {
4925 # Separate with a line feed, so the unprefixed part is only used as
4926 # a tiebreaker when two pages have the exact same prefix.
4927 # In UCA, tab is the only character that can sort above LF
4928 # so we strip both of them from the original prefix.
4929 $prefix = strtr( $prefix,
"\n\t",
' ' );
4930 return "$prefix\n$unprefixed";
4949 $linkCache->addLinkObj( $this );
4950 $this->mDbPageLanguage = $linkCache->getGoodLinkFieldObj( $this,
'lang' );
4973 if ( $dbPageLanguage ) {
4977 if ( !$this->mPageLanguage || $this->mPageLanguage[1] !==
$wgLanguageCode ) {
4985 $langObj = $contentHandler->getPageLanguage( $this );
5008 $variant =
$wgLang->getPreferredVariant();
5009 if (
$wgLang->getCode() !== $variant ) {
5018 if ( $dbPageLanguage ) {
5020 $variant = $pageLang->getPreferredVariant();
5021 if ( $pageLang->getCode() !== $variant ) {
5032 $pageLang = $contentHandler->getPageViewLanguage( $this );
5050 $editnotice_ns =
'editnotice-' . $this->
getNamespace();
5052 if ( $msg->exists() ) {
5053 $html = $msg->parseAsBlock();
5055 if ( trim(
$html ) !==
'' ) {
5060 'mw-editnotice-namespace',
5070 $parts = explode(
'/', $this->
getDBkey() );
5071 $editnotice_base = $editnotice_ns;
5072 while ( count( $parts ) > 0 ) {
5073 $editnotice_base .=
'-' . array_shift( $parts );
5075 if ( $msg->exists() ) {
5076 $html = $msg->parseAsBlock();
5077 if ( trim(
$html ) !==
'' ) {
5082 'mw-editnotice-base',
5092 $editnoticeText = $editnotice_ns .
'-' . strtr( $this->
getDBkey(),
'/',
'-' );
5094 if ( $msg->exists() ) {
5095 $html = $msg->parseAsBlock();
5096 if ( trim(
$html ) !==
'' ) {
5101 'mw-editnotice-page',
5110 Hooks::run(
'TitleGetEditNotices', [ $this, $oldid, &$notices ] );
5125 'mDefaultNamespace',
5130 $this->mArticleID = ( $this->mNamespace >= 0 ) ? -1 : 0;
5131 $this->mUrlform =
wfUrlencode( $this->mDbkeyform );
5132 $this->mTextform = strtr( $this->mDbkeyform,
'_',
' ' );
within a display generated by the Derivative if and wherever such third party notices normally appear The contents of the NOTICE file are for informational purposes only and do not modify the License You may add Your own attribution notices within Derivative Works that You alongside or as an addendum to the NOTICE text from the provided that such additional attribution notices cannot be construed as modifying the License You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for or distribution of Your or for any such Derivative Works as a provided Your and distribution of the Work otherwise complies with the conditions stated in this License Submission of Contributions Unless You explicitly state any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this without any additional terms or conditions Notwithstanding the nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions Trademarks This License does not grant permission to use the trade names
$wgRestrictionLevels
Rights which can be required for each protection level (via action=protect)
$wgExemptFromUserRobotsControl
An array of namespace keys in which the INDEX/__NOINDEX__ magic words will not function,...
$wgLegalTitleChars
Allowed title characters – regex character class Don't change this unless you know what you're doing.
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
$wgSemiprotectedRestrictionLevels
Restriction levels that should be considered "semiprotected".
$wgLanguageCode
Site language code.
$wgMaximumMovedPages
Maximum number of pages to move at once when moving subpages with a page.
$wgScript
The URL path to index.php.
$wgInternalServer
Internal server name as known to CDN, if different.
$wgInvalidRedirectTargets
Array of invalid page redirect targets.
$wgNamespaceProtection
Set the minimum permissions required to edit pages in each namespace.
$wgRestrictionTypes
Set of available actions that can be restricted via action=protect You probably shouldn't change this...
$wgWhitelistRead
Pages anonymous user may see, set as an array of pages titles.
$wgWhitelistReadRegexp
Pages anonymous user may see, set as an array of regular expressions.
$wgDeleteRevisionsLimit
Optional to restrict deletion of pages with higher revision counts to users with the 'bigdelete' perm...
$wgBlockDisablesLogin
If true, blocked users will not be allowed to login.
$wgEmailConfirmToEdit
Should editors be required to have a validated e-mail address before being allowed to edit?
$wgVariantArticlePath
Like $wgArticlePath, but on multi-variant wikis, this provides a path format that describes which par...
$wgServer
URL of the server.
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility.
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfReadOnly()
Check whether the wiki is in read-only mode.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfMergeErrorArrays()
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
wfLocalFile( $title)
Get an object referring to a locally registered file.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfFindFile( $title, $options=[])
Find a file.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
if(! $wgDBerrorLogTZ) $wgRequest
Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
Deferrable Update for closure/callback updates that should use auto-commit mode.
static get(Title $title)
Create a new BacklinkCache or reuse any existing one.
get( $key, $flags=0, $oldFlags=null)
Get an item with the given key.
Handles purging appropriate CDN URLs given a title (or titles)
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title.
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
Class to invalidate the HTML cache of all the pages linking to a given title.
Simple store for keeping values in an associative array for the current process.
set( $key, $value, $exptime=0, $flags=0)
Set an item.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static factory( $code)
Get a cached or new language object for a given language code.
static singleton()
Get an instance of this class.
static getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
static getSubject( $index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA,...
static exists( $index)
Returns whether the specified namespace exists.
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
static isCapitalized( $index)
Is the namespace first-letter capitalized?
static isWatchable( $index)
Can pages in a namespace be watched?
static hasSubpages( $index)
Does the namespace allow subpages?
static isTalk( $index)
Is the given namespace a talk namespace?
static getTalk( $index)
Get the talk namespace index for a given namespace.
static hasTalkNamespace( $index)
Does this namespace ever have a talk namespace?
static equals( $ns1, $ns2)
Returns whether the specified namespaces are the same namespace.
static subjectEquals( $ns1, $ns2)
Returns whether the specified namespaces share the same subject.
static isContent( $index)
Does this namespace contain content, for the purposes of calculating statistics, etc?
static isMovable( $index)
Can pages in the given namespace be moved?
static singleton()
Get the signleton instance of this class.
Handles the backend logic of moving a page from one title to another.
static getMainWANInstance()
Get the main WAN cache object.
static getMain()
Get the RequestContext object associated with the main request.
static invalidateModuleCache(Title $title, Revision $old=null, Revision $new=null, $wikiId)
Clear the preloadTitleInfo() cache for all wiki modules on this wiki on page change if it was a JS or...
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
static escapeIdForLink( $id)
Given a section name or other user-generated or otherwise unsafe string, escapes it to be a valid URL...
static escapeClass( $class)
Given a value, escape it so that it can be used as a CSS class and return it.
static decodeCharReferencesAndNormalize( $text)
Decode any character references, numeric or named entities, in the next and normalize the resulting s...
static escapeId( $id, $options=[])
Given a value, escape it so that it can be used in an id attribute and return it.
static escapeIdForExternalInterwiki( $id)
Given a section name or other user-generated or otherwise unsafe string, escapes it to be a valid URL...
static getLocalNameFor( $name, $subpage=false)
Get the local name for a specified canonical name.
static exists( $name)
Check if a given name exist as a special page or as a special page alias.
static resolveAlias( $alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
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 escapeRegexReplacement( $string)
Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter.
The TitleArray class only exists to provide the newFromResult method at pre- sent.
static newFromResult( $res)
Represents a page (or page fragment) title within MediaWiki.
Represents a title within MediaWiki.
string $mInterwiki
Interwiki prefix.
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
inNamespaces()
Returns true if the title is inside one of the specified namespaces.
checkUserConfigPermissions( $action, $user, $errors, $rigor, $short)
Check CSS/JSON/JS sub-page permissions.
getSubpages( $limit=-1)
Get all subpages of this page.
isWatchable()
Can this title be added to a user's watchlist?
getTalkPageIfDefined()
Get a Title object associated with the talk page of this article, if such a talk page can exist.
getNamespace()
Get the namespace index, i.e.
estimateRevisionCount()
Get the approximate revision count of this page.
__wakeup()
Text form (spaces not underscores) of the main part.
static newFromDBkey( $key)
Create a new Title from a prefixed DB key.
isProtected( $action='')
Does the title correspond to a protected article?
getTitleProtectionInternal()
Fetch title protection settings.
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.
bool $mPageLanguage
The (string) language code of the page's language and content code.
array $mCascadeSources
Where are the cascading restrictions coming from on this page?
isSingleRevRedirect()
Checks if this page is just a one-rev redirect.
wasLocalInterwiki()
Was this a local interwiki link?
getInternalURL( $query='', $query2=false)
Get the URL form for an internal link.
purgeSquid()
Purge all applicable CDN URLs.
getFullURL( $query='', $query2=false, $proto=PROTO_RELATIVE)
Get a real URL referring to this title, with interwiki link and fragment.
getRestrictions( $action)
Accessor/initialisation for mRestrictions.
isKnown()
Does this title refer to a page that can (or might) be meaningfully viewed? In particular,...
int $mEstimateRevisions
Estimated number of revisions; null of not loaded.
getBacklinkCache()
Get a backlink cache object.
static getInterwikiLookup()
B/C kludge: provide an InterwikiLookup for use by Title.
static getTitleFormatter()
B/C kludge: provide a TitleParser for use by Title.
inNamespace( $ns)
Returns true if the title is inside the specified namespace.
equals(Title $title)
Compare with another title.
isDeletedQuick()
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.
checkQuickPermissions( $action, $user, $errors, $rigor, $short)
Permissions checks that fail most often, and which are easiest to test.
getTalkPage()
Get a Title object associated with the talk page of this article.
secureAndSplit()
Secure and split - main initialisation function for this object.
getAllRestrictions()
Accessor/initialisation for mRestrictions.
hasContentModel( $id)
Convenience method for checking a title's content model name.
getSkinFromCssJsSubpage()
static clearCaches()
Text form (spaces not underscores) of the main part.
createFragmentTarget( $fragment)
Creates a new Title for a different fragment of the same page.
getDefaultNamespace()
Get the default namespace index, for when there is no namespace.
moveTo(&$nt, $auth=true, $reason='', $createRedirect=true, array $changeTags=[])
Move a title to a new location.
isConversionTable()
Is this a conversion table for the LanguageConverter?
getFragment()
Get the Title fragment (i.e.
isCascadeProtected()
Cascading protection: Return true if cascading restrictions apply to this page, false if not.
static getFilteredRestrictionTypes( $exists=true)
Get a filtered list of all restriction types supported by this wiki.
getPrefixedURL()
Get a URL-encoded title (not an actual URL) including interwiki.
TitleValue $mTitleValue
A corresponding TitleValue object.
checkUserBlock( $action, $user, $errors, $rigor, $short)
Check that the user isn't blocked from editing.
isWikitextPage()
Does that page contain wikitext, or it is JS, CSS or whatever?
validateFileMoveOperation( $nt)
Check if the requested move target is a valid file move target.
getTalkNsText()
Get the namespace text of the talk page.
areRestrictionsCascading()
Returns cascading restrictions for the current article.
hasFragment()
Check if a Title fragment is set.
static nameOf( $id)
Get the prefixed DB key associated with an ID.
isSpecial( $name)
Returns true if this title resolves to the named special page.
getRedirectsHere( $ns=null)
Get all extant redirects to this Title.
getLength( $flags=0)
What is the length of this page? Uses link cache, adding it if necessary.
array $mNotificationTimestamp
Associative array of user ID -> timestamp/false.
isValidMoveOperation(&$nt, $auth=true, $reason='')
Check whether a given move operation would be valid.
getFullText()
Get the prefixed title with spaces, plus any fragment (part beginning with '#')
areRestrictionsLoaded()
Accessor for mRestrictionsLoaded.
canUseNoindex()
Whether the magic words INDEX and NOINDEX function for this page.
exists( $flags=0)
Check if page exists.
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
static newFromTextThrow( $text, $defaultNamespace=NS_MAIN)
Like Title::newFromText(), but throws MalformedTitleException when the title is invalid,...
isLocal()
Determine whether the object refers to a page within this project (either this wiki or a wiki with a ...
int $mLength
The page length, 0 for special pages.
loadFromRow( $row)
Load Title object fields from a DB row.
getPageLanguage()
Get the language in which the content of this page is written in wikitext.
bool $mLocalInterwiki
Was this Title created from a string with a local interwiki prefix?
getUserCaseDBKey()
Get the DB key with the initial letter case as specified by the user.
isMovable()
Would anybody with sufficient privileges be able to move this page? Some pages just aren't movable.
const CACHE_MAX
Title::newFromText maintains a cache to avoid expensive re-normalization of commonly used titles.
getRestrictionExpiry( $action)
Get the expiry time for the restriction against a given action.
getUserPermissionsErrors( $action, $user, $rigor='secure', $ignoreErrors=[])
Can $user perform $action on this page?
getSubjectPage()
Get a title object associated with the subject page of this talk page.
getTemplateLinksTo( $options=[])
Get an array of Title objects using this Title as a template Also stores the IDs in the link cache.
fixSpecialName()
If the Title refers to a special page alias which is not the local default, resolve the alias,...
getRestrictionTypes()
Returns restriction types for the current Title.
static legalChars()
Get a regex character class describing the legal characters in a link.
__toString()
Return a string representation of this title.
hasSubjectNamespace( $ns)
Returns true if the title has the same subject namespace as the namespace specified.
isSemiProtected( $action='edit')
Is this page "semi-protected" - the only protection levels are listed in $wgSemiprotectedRestrictionL...
getPrefixedDBkey()
Get the prefixed database key form.
areCascadeProtectionSourcesLoaded( $getPages=true)
Determines whether cascading protection sources have already been loaded from the database.
getPreviousRevisionID( $revId, $flags=0)
Get the revision ID of the previous revision.
getNsText()
Get the namespace text.
canExist()
Is this in a namespace that allows actual pages?
static purgeExpiredRestrictions()
Purge expired restrictions from the page_restrictions table.
getDefaultMessageText()
Get the default message text or false if the message doesn't exist.
getDbPageLanguageCode()
Returns the page language code saved in the database, if $wgPageLanguageUseDB is set to true in Local...
countRevisionsBetween( $old, $new, $max=null)
Get the number of revisions between the given revision.
checkPermissionHooks( $action, $user, $errors, $rigor, $short)
Check various permission hooks.
bool $mForcedContentModel
If a content model was forced via setContentModel() this will be true to avoid having other code path...
getNotificationTimestamp( $user=null)
Get the timestamp when this page was updated since the user last saw it.
isTrans()
Determine whether the object refers to a page within this project and is transcludable.
resetArticleID( $newid)
This clears some fields in this object, and clears any associated keys in the "bad links" section of ...
isNewPage()
Check if this is a new page.
touchLinks()
Update page_touched timestamps and send CDN purge messages for pages linking to this title.
isExternal()
Is this Title interwiki?
bool $mRestrictionsLoaded
Boolean for initialisation on demand.
isMainPage()
Is this the mainpage?
isUserConfigPage()
Is this a "config" (.css, .json, or .js) sub-page of a user page?
getFragmentForURL()
Get the fragment in URL form, including the "#" character if there is one.
string bool null $mDbPageLanguage
The page language code from the database, null if not saved in the database or false if not loaded,...
getAuthorsBetween( $old, $new, $limit, $options=[])
Get the authors between the given revisions or revision IDs.
isSpecialPage()
Returns true if this is a special page.
isNamespaceProtected(User $user)
Determines if $user is unable to edit this page because it has been protected by $wgNamespaceProtecti...
isUserJsConfigPage()
Is this a JS "config" sub-page of a user page?
static newFromLinkTarget(LinkTarget $linkTarget)
Create a new Title from a LinkTarget.
getSubpageUrlForm()
Get a URL-encoded form of the subpage text.
canHaveTalkPage()
Can this title have a corresponding talk page?
isTalkPage()
Is this a talk page of some sort?
getRootTitle()
Get the root page name title, i.e.
bool int $mLatestID
ID of most recent revision.
getBrokenLinksFrom()
Get an array of Title objects referring to non-existent articles linked from this page.
getDBkey()
Get the main part with underscores.
missingPermissionError( $action, $short)
Get a description array when the user doesn't have the right to perform $action (i....
prefix( $name)
Prefix some arbitrary text with the namespace or interwiki prefix of this object.
getEarliestRevTime( $flags=0)
Get the oldest revision timestamp of this page.
checkActionPermissions( $action, $user, $errors, $rigor, $short)
Check action permissions not already checked in checkQuickPermissions.
string $mFragment
Title fragment (i.e.
getRootText()
Get the root page name text without a namespace, i.e.
getFullUrlForRedirect( $query='', $proto=PROTO_CURRENT)
Get a url appropriate for making redirects based on an untrusted url arg.
static newFromTitleValue(TitleValue $titleValue)
Create a new Title from a TitleValue.
string $mPrefixedText
Text form including namespace/interwiki, initialised on demand.
bool string $mContentModel
ID of the page's content model, i.e.
getLatestRevID( $flags=0)
What is the page_latest field for this page?
static convertByteClassToUnicodeClass( $byteClass)
Utility method for converting a character sequence from bytes to Unicode.
isValidRedirectTarget()
Check if this Title is a valid redirect target.
static HashBagOStuff $titleCache
getLinksFrom( $options=[], $table='pagelinks', $prefix='pl')
Get an array of Title objects linked from this Title Also stores the IDs in the link cache.
static makeName( $ns, $title, $fragment='', $interwiki='', $canonicalNamespace=false)
Make a prefixed DB key from a DB key and a namespace index.
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 $mHasCascadingRestrictions
Are cascading restrictions in effect on this page?
getPartialURL()
Get the URL-encoded form of the main part.
getBaseText()
Get the base page name without a namespace, i.e.
isContentPage()
Is this Title in a namespace which contains content? In other words, is this a content page,...
getText()
Get the text form (spaces not underscores) of the main part.
getTouched( $db=null)
Get the last touched timestamp.
getTitleValue()
Get a TitleValue object representing this Title.
pageCond()
Get an associative array for selecting this title from the "page" table.
bool $mCascadeRestriction
Cascade restrictions on this page to included templates and images?
string $mUrlform
URL-encoded form of the main part.
getFirstRevision( $flags=0)
Get the first revision of the page.
string $mTextform
Text form (spaces not underscores) of the main part.
getOtherPage()
Get the other title for this page, if this is a subject page get the talk page, if it is a subject pa...
static newFromIDs( $ids)
Make an array of titles from an array of IDs.
getUserPermissionsErrorsInternal( $action, $user, $rigor='secure', $short=false)
Can $user perform $action on this page? This is an internal function, with multiple levels of checks ...
quickUserCan( $action, $user=null)
Can $user perform $action on this page? This skips potentially expensive cascading permission checks ...
static getSelectFields()
Returns a list of fields that are to be selected for initializing Title objects or LinkCache entries.
isSubpageOf(Title $title)
Check if this title is a subpage of another title.
getBaseTitle()
Get the base page name title, i.e.
static newMainPage()
Create a new Title for the Main Page.
getParentCategoryTree( $children=[])
Get a tree of parent categories.
checkSpecialsAndNSPermissions( $action, $user, $errors, $rigor, $short)
Check permissions on special pages & namespaces.
bool $mHasSubpages
Whether a page has any subpages.
getNextRevisionID( $revId, $flags=0)
Get the revision ID of the next revision.
array $mRestrictionsExpiry
When do the restrictions on this page expire?
loadRestrictionsFromRows( $rows, $oldFashionedRestrictions=null)
Compiles list of active page restrictions from both page table (pre 1.10) and page_restrictions table...
static fixUrlQueryArgs( $query, $query2=false)
Helper to fix up the get{Canonical,Full,Link,Local,Internal}URL args get{Canonical,...
isUserJsonConfigPage()
Is this a JSON "config" sub-page of a user page?
isValidMoveTarget( $nt)
Checks if $this can be moved to a given Title.
loadRestrictions( $oldFashionedRestrictions=null)
Load restrictions from the page_restrictions table.
isRedirect( $flags=0)
Is this an article that is a redirect page? Uses link cache, adding it if necessary.
checkPageRestrictions( $action, $user, $errors, $rigor, $short)
Check against page_restrictions table requirements on this page.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
invalidateCache( $purgeTime=null)
Updates page_touched for this page; called from LinksUpdate.php.
$mCascadingRestrictions
Caching the results of getCascadeProtectionSources.
static escapeFragmentForURL( $fragment)
Escape a text fragment, say from a link, for a URL.
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
getSubjectNsText()
Get the namespace text of the subject (rather than talk) page.
bool $mIsBigDeletion
Would deleting this page be a big deletion?
int $mNamespace
Namespace index, i.e.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
null $mRedirect
Is the article at this title a redirect?
countAuthorsBetween( $old, $new, $limit, $options=[])
Get the number of authors between the given revisions or revision IDs.
static compare(LinkTarget $a, LinkTarget $b)
Callback for usort() to do title sorts by (namespace, title)
getCanonicalURL( $query='', $query2=false)
Get the URL for a canonical link, for use in things like IRC and e-mail notifications.
checkCascadingSourcesRestrictions( $action, $user, $errors, $rigor, $short)
Check restrictions on cascading pages.
isDeleted()
Is there a version of this page in the deletion archive?
getPageViewLanguage()
Get the language in which the content of this page is written when viewed by user.
const GAID_FOR_UPDATE
Used to be GAID_FOR_UPDATE define.
getSkinFromConfigSubpage()
Trim down a .css, .json, or .js subpage title to get the corresponding skin name.
checkReadPermissions( $action, $user, $errors, $rigor, $short)
Check that the user is allowed to read this page.
userCan( $action, $user=null, $rigor='secure')
Can $user perform $action on this page?
array $mRestrictions
Array of groups allowed to edit this article.
isSiteConfigPage()
Could this MediaWiki namespace page contain custom CSS, JSON, or JavaScript for the global UI.
int $mDefaultNamespace
Namespace index when there is no namespace.
moveSubpages( $nt, $auth=true, $reason='', $createRedirect=true, array $changeTags=[])
Move this page's subpages to be subpages of $nt.
getRelativeRevisionID( $revId, $flags, $dir)
Get next/previous revision ID relative to another revision ID.
deleteTitleProtection()
Remove any title protection due to page existing.
getSubpage( $text)
Get the title for a subpage of the current page.
getTitleProtection()
Is this title subject to title protection? Title protection is the one applied against creation of su...
getEditURL()
Get the edit URL for this Title.
getParentCategories()
Get categories to which this Title belongs and return an array of categories' names.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
int $mArticleID
Article ID, fetched from the link cache on demand.
getTemplateLinksFrom( $options=[])
Get an array of Title objects used on this Title as a template Also stores the IDs in the link cache.
getTransWikiID()
Returns the DB name of the distant wiki which owns the object.
isSubpage()
Is this a subpage?
isValid()
Returns true if the title is valid, false if it is invalid.
setFragment( $fragment)
Set the fragment for this title.
getLocalURL( $query='', $query2=false)
Get a URL with no fragment or server name (relative URL) from a Title object.
getContentModel( $flags=0)
Get the page's content model id, see the CONTENT_MODEL_XXX constants.
isBigDeletion()
Check whether the number of revisions of this page surpasses $wgDeleteRevisionsLimit.
getCdnUrls()
Get a list of URLs to purge from the CDN cache when this page changes.
string $mUserCaseDBKey
Database key with the initial letter in the case specified by the user.
getInterwiki()
Get the interwiki prefix.
getEditNotices( $oldid=0)
Get a list of rendered edit notices for this page.
setContentModel( $model)
Set a proposed content model for the page for permissions checking.
getCascadeProtectionSources( $getPages=true)
Cascading protection: Get the source of any cascading restrictions on this page.
mixed $mTitleProtection
Cached value for getTitleProtection (create protection)
getSubpageText()
Get the lowest-level subpage name, i.e.
string $mDbkeyform
Main part with underscores.
hasSourceText()
Does this page have source text?
flushRestrictions()
Flush the protection cache in this object and force reload from the database.
getPrefixedText()
Get the prefixed title with spaces.
hasSubpages()
Does this have subpages? (Warning, usually requires an extra DB query.)
string bool $mOldRestrictions
Comma-separated set of permission keys indicating who can move or edit the page from the page table,...
canTalk()
Can this title have a corresponding talk page?
resultToError( $errors, $result)
Add the resulting error code to the errors array.
isAlwaysKnown()
Should links to this title be shown as potentially viewable (i.e.
getNamespaceKey( $prepend='nstab-')
Generate strings used for xml 'id' names in monobook tabs.
getCategorySortkey( $prefix='')
Returns the raw sort key to be used for categories, with the specified prefix.
static newFromRow( $row)
Make a Title object from a DB row.
isUserCssConfigPage()
Is this a CSS "config" sub-page of a user page?
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static isEveryoneAllowed( $right)
Check if all users may be assumed to have the given permission.
static groupHasPermission( $group, $role)
Check, if the given group has the given permission.
static whoIs( $id)
Get the username corresponding to a given user ID.
static newFatalPermissionDeniedStatus( $permission)
Factory function for fatal permission-denied errors.
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new page object.
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
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an article
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
when a variable name is used in a it is silently declared as a new masking the global
when a variable name is used in a function
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
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
the array() calling protocol came about after MediaWiki 1.4rc1.
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
do that in ParserLimitReportFormat instead $parser
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. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. '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. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) '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 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) '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! 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
this hook is for auditing only RecentChangesLinked and Watchlist 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
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
namespace and then decline to actually register it & $namespaces
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account incomplete not yet checked for validity & $retval
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
namespace and then decline to actually register it file or subcat img or subcat $title
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 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 "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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
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
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. '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
Allows to change the fields on the form that will be generated $name
null for the wiki Added in
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
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
processing should stop and the error should be shown to the user * false
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
The MIT 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
const CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_JAVASCRIPT
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
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
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
if(!isset( $args[0])) $lang