24use \MediaWiki\Logger\LoggerFactory;
25use \MediaWiki\MediaWikiServices;
122 $ns =
$title->getNamespace();
125 throw new MWException(
"NS_MEDIA is a virtual namespace; use NS_FILE." );
126 } elseif ( $ns < 0 ) {
127 throw new MWException(
"Invalid or virtual namespace $ns given." );
131 if ( !Hooks::run(
'WikiPageFactory', [
$title, &$page ] ) ) {
159 public static function newFromID( $id, $from =
'fromdb' ) {
167 $row = $db->selectRow(
168 'page', self::selectFields(), [
'page_id' => $id ], __METHOD__ );
186 public static function newFromRow( $row, $from =
'fromdb' ) {
188 $page->loadFromRow( $row, $from );
201 return self::READ_NORMAL;
203 return self::READ_LATEST;
248 $this->mDataLoaded =
false;
260 $this->mRedirectTarget =
null;
261 $this->mLastRevision =
null;
262 $this->mTouched =
'19700101000000';
263 $this->mLinksUpdated =
'19700101000000';
264 $this->mTimestamp =
'';
265 $this->mIsRedirect =
false;
266 $this->mLatest =
false;
279 $this->mPreparedEdit =
false;
300 'page_links_updated',
306 $fields[] =
'page_content_model';
310 $fields[] =
'page_lang';
329 Hooks::run(
'ArticlePageDataBefore', [ &$wikiPage, &$fields ] );
331 $row =
$dbr->selectRow(
'page', $fields, $conditions, __METHOD__,
$options );
333 Hooks::run(
'ArticlePageDataAfter', [ &$wikiPage, &$row ] );
349 'page_namespace' =>
$title->getNamespace(),
379 if ( is_int( $from ) && $from <= $this->mDataLoadedFrom ) {
384 if ( is_int( $from ) ) {
387 $loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
391 && $loadBalancer->getServerCount() > 1
392 && $loadBalancer->hasOrMadeRecentMasterChanges()
394 $from = self::READ_LATEST;
401 $from = self::READ_NORMAL;
419 $lc = LinkCache::singleton();
420 $lc->clearLink( $this->mTitle );
423 $lc->addGoodLinkObjFromRow( $this->mTitle, $data );
425 $this->mTitle->loadFromRow( $data );
428 $this->mTitle->loadRestrictions( $data->page_restrictions );
430 $this->mId = intval( $data->page_id );
431 $this->mTouched =
wfTimestamp( TS_MW, $data->page_touched );
433 $this->mIsRedirect = intval( $data->page_is_redirect );
434 $this->mLatest = intval( $data->page_latest );
437 if ( $this->mLastRevision && $this->mLastRevision->getId() != $this->mLatest ) {
438 $this->mLastRevision =
null;
439 $this->mTimestamp =
'';
442 $lc->addBadLinkObj( $this->mTitle );
444 $this->mTitle->loadFromRow(
false );
451 $this->mDataLoaded =
true;
459 if ( !$this->mDataLoaded ) {
469 if ( !$this->mDataLoaded ) {
472 return $this->mId > 0;
484 return $this->mTitle->isKnown();
493 if ( !$this->mDataLoaded ) {
512 $cache = ObjectCache::getMainWANInstance();
514 return $cache->getWithSetCallback(
515 $cache->makeKey(
'page',
'content-model', $this->getLatest() ),
521 return $rev->getContentModel();
523 $title = $this->mTitle->getPrefixedDBkey();
524 wfWarn(
"Page $title exists but has no (visible) revisions!" );
525 return $this->mTitle->getContentModel();
532 return $this->mTitle->getContentModel();
540 if ( !$this->mDataLoaded ) {
543 return ( $this->mId && !$this->mIsRedirect );
551 if ( !$this->mDataLoaded ) {
562 if ( !$this->mDataLoaded ) {
573 if ( !$this->mDataLoaded ) {
585 $rev = $this->mTitle->getFirstRevision();
587 $rev = $this->mTitle->getFirstRevision( Title::GAID_FOR_UPDATE );
597 if ( $this->mLastRevision !==
null ) {
606 if ( $this->mDataLoadedFrom == self::READ_LOCKING ) {
616 } elseif ( $this->mDataLoadedFrom == self::READ_LATEST ) {
620 $flags = Revision::READ_LATEST;
637 $this->mLastRevision = $revision;
647 if ( $this->mLastRevision ) {
668 if ( $this->mLastRevision ) {
669 return $this->mLastRevision->getContent( $audience,
$user );
679 if ( !$this->mTimestamp ) {
706 if ( $this->mLastRevision ) {
707 return $this->mLastRevision->getUser( $audience,
$user );
726 $userName = $revision->getUserText( $audience,
$user );
727 return User::newFromName( $userName,
false );
744 if ( $this->mLastRevision ) {
745 return $this->mLastRevision->getUserText( $audience,
$user );
762 if ( $this->mLastRevision ) {
763 return $this->mLastRevision->getComment( $audience,
$user );
776 if ( $this->mLastRevision ) {
777 return $this->mLastRevision->isMinor();
794 if ( !$this->mTitle->isContentPage() ) {
799 $content = $editInfo->pstContent;
804 if ( !$content || $content->isRedirect() ) {
818 $hasLinks = (bool)count( $editInfo->output->getLinks() );
821 [
'pl_from' => $this->
getId() ], __METHOD__ );
825 return $content->isCountable( $hasLinks );
836 if ( !$this->mTitle->isRedirect() ) {
840 if ( $this->mRedirectTarget !==
null ) {
846 $row =
$dbr->selectRow(
'redirect',
847 [
'rd_namespace',
'rd_title',
'rd_fragment',
'rd_interwiki' ],
848 [
'rd_from' => $this->
getId() ],
853 if ( $row && !is_null( $row->rd_fragment ) && !is_null( $row->rd_interwiki ) ) {
854 $this->mRedirectTarget = Title::makeTitle(
855 $row->rd_namespace, $row->rd_title,
856 $row->rd_fragment, $row->rd_interwiki
876 $retval = $content ? $content->getUltimateRedirectTarget() :
null;
883 DeferredUpdates::addCallableUpdate(
887 DeferredUpdates::POSTSEND,
901 $dbw->startAtomic( __METHOD__ );
907 'rd_from' => $this->
getId(),
924 $dbw->endAtomic( __METHOD__ );
948 if ( $rt->isExternal() ) {
949 if ( $rt->isLocal() ) {
953 $source = $this->mTitle->getFullURL(
'redirect=no' );
954 return $rt->getFullURL( [
'rdfrom' =>
$source ] );
962 if ( $rt->isSpecialPage() ) {
966 if ( $rt->isValidRedirectTarget() ) {
967 return $rt->getFullURL();
986 if (
$dbr->implicitGroupby() ) {
987 $realNameField =
'user_real_name';
989 $realNameField =
'MIN(user_real_name) AS user_real_name';
992 $tables = [
'revision',
'user' ];
995 'user_id' =>
'rev_user',
996 'user_name' =>
'rev_user_text',
998 'timestamp' =>
'MAX(rev_timestamp)',
1001 $conds = [
'rev_page' => $this->
getId() ];
1007 $conds[] =
"rev_user != $user";
1009 $conds[] =
"rev_user_text != {$dbr->addQuotes( $this->getUserText() )}";
1013 $conds[] =
"{$dbr->bitAnd( 'rev_deleted', Revision::DELETED_USER )} = 0";
1016 'user' => [
'LEFT JOIN',
'rev_user = user_id' ],
1020 'GROUP BY' => [
'rev_user',
'rev_user_text' ],
1021 'ORDER BY' =>
'timestamp DESC',
1038 && ( $oldId ===
null || $oldId === 0 || $oldId === $this->
getLatest() )
1056 ParserOptions $parserOptions, $oldid =
null, $forceParse =
false
1061 if ( $useParserCache && !$parserOptions->
isSafeToCache() ) {
1062 throw new InvalidArgumentException(
1063 'The supplied ParserOptions are not safe to cache. Fix the options or set $forceParse = true.'
1068 ': using parser cache: ' . ( $useParserCache ?
'yes' :
'no' ) .
"\n" );
1073 if ( $useParserCache ) {
1074 $parserOutput = MediaWikiServices::getInstance()->getParserCache()
1075 ->get( $this, $parserOptions );
1076 if ( $parserOutput !==
false ) {
1077 return $parserOutput;
1081 if ( $oldid ===
null || $oldid === 0 ) {
1088 return $pool->getParserOutput();
1101 Hooks::run(
'PageViewUpdates', [ $this,
$user ] );
1104 $user->clearNotification( $this->mTitle, $oldid );
1107 MWExceptionHandler::logException(
$e );
1121 if ( !Hooks::run(
'ArticlePurge', [ &$wikiPage ] ) ) {
1125 $this->mTitle->invalidateCache();
1130 DeferredUpdates::addUpdate(
1132 DeferredUpdates::PRESEND
1137 $messageCache->updateMessageOverride( $this->mTitle, $this->
getContent() );
1170 $pageIdForInsert = $pageId ? [
'page_id' => $pageId ] : [];
1174 'page_namespace' => $this->mTitle->getNamespace(),
1175 'page_title' => $this->mTitle->getDBkey(),
1176 'page_restrictions' =>
'',
1177 'page_is_redirect' => 0,
1180 'page_touched' => $dbw->timestamp(),
1183 ] + $pageIdForInsert,
1188 if ( $dbw->affectedRows() > 0 ) {
1189 $newid = $pageId ? (int)$pageId : $dbw->insertId();
1190 $this->mId = $newid;
1191 $this->mTitle->resetArticleID( $newid );
1213 $lastRevIsRedirect =
null
1218 if ( (
int)$revision->getId() === 0 ) {
1219 throw new InvalidArgumentException(
1220 __METHOD__ .
': Revision has ID ' . var_export( $revision->getId(), 1 )
1224 $content = $revision->getContent();
1225 $len = $content ? $content->getSize() : 0;
1226 $rt = $content ? $content->getUltimateRedirectTarget() :
null;
1228 $conditions = [
'page_id' => $this->
getId() ];
1230 if ( !is_null( $lastRevision ) ) {
1232 $conditions[
'page_latest'] = $lastRevision;
1236 'page_latest' => $revision->getId(),
1237 'page_touched' => $dbw->timestamp( $revision->getTimestamp() ),
1238 'page_is_new' => ( $lastRevision === 0 ) ? 1 : 0,
1239 'page_is_redirect' => $rt !==
null ? 1 : 0,
1244 $row[
'page_content_model'] = $revision->getContentModel();
1247 $dbw->update(
'page',
1252 $result = $dbw->affectedRows() > 0;
1256 $this->mLatest = $revision->getId();
1257 $this->mIsRedirect = (bool)$rt;
1259 LinkCache::singleton()->addGoodLinkObj(
1265 $revision->getContentModel()
1287 $isRedirect = !is_null( $redirectTitle );
1289 if ( !$isRedirect && $lastRevIsRedirect ===
false ) {
1293 if ( $isRedirect ) {
1297 $where = [
'rd_from' => $this->
getId() ];
1298 $dbw->delete(
'redirect', $where, __METHOD__ );
1305 return ( $dbw->affectedRows() != 0 );
1319 $row = $dbw->selectRow(
1320 [
'revision',
'page' ],
1321 [
'rev_id',
'rev_timestamp',
'page_is_redirect' ],
1323 'page_id' => $this->
getId(),
1324 'page_latest=rev_id' ],
1328 if (
wfTimestamp( TS_MW, $row->rev_timestamp ) >= $revision->getTimestamp() ) {
1331 $prev = $row->rev_id;
1332 $lastRevIsRedirect = (bool)$row->page_is_redirect;
1336 $lastRevIsRedirect =
null;
1388 $sectionId,
Content $sectionContent, $sectionTitle =
'', $edittime =
null
1391 if ( $edittime && $sectionId !==
'new' ) {
1398 &&
wfGetLB()->getServerCount() > 1
1399 &&
wfGetLB()->hasOrMadeRecentMasterChanges()
1405 $baseRevId =
$rev->getId();
1409 return $this->
replaceSectionAtRev( $sectionId, $sectionContent, $sectionTitle, $baseRevId );
1426 $sectionTitle =
'', $baseRevId =
null
1428 if ( strval( $sectionId ) ===
'' ) {
1430 $newContent = $sectionContent;
1433 throw new MWException(
"sections not supported for content model " .
1438 if ( is_null( $baseRevId ) || $sectionId ===
'new' ) {
1443 wfDebug( __METHOD__ .
" asked for bogus section (page: " .
1444 $this->
getId() .
"; section: $sectionId)\n" );
1448 $oldContent =
$rev->getContent();
1451 if ( !$oldContent ) {
1452 wfDebug( __METHOD__ .
": no page text\n" );
1456 $newContent = $oldContent->replaceSection( $sectionId, $sectionContent, $sectionTitle );
1539 User $user =
null, $serialFormat =
null, $tags = [], $undidRevId = 0
1544 if ( $tags ===
null ) {
1549 if ( $this->mTitle->getText() ===
'' ) {
1550 throw new MWException(
'Something is trying to edit an article with an empty title' );
1554 return Status::newFatal(
'content-not-allowed-here',
1556 $this->mTitle->getPrefixedText()
1572 $hookStatus = Status::newGood( [] );
1573 $hook_args = [ &$wikiPage, &
$user, &$content, &$summary,
1576 if ( !Hooks::run(
'PageContentSave', $hook_args ) ) {
1577 if ( $hookStatus->isOK() ) {
1579 $hookStatus->fatal(
'edit-hook-aborted' );
1588 if ( $old_content && $old_content->getModel() !== $content->
getModel() ) {
1589 $tags[] =
'mw-contentmodelchange';
1595 $summary =
$handler->getAutosummary( $old_content, $content,
$flags );
1607 $pstContent = $editInfo->pstContent;
1611 'serialized' => $pstContent->serialize( $serialFormat ),
1612 'serialFormat' => $serialFormat,
1613 'baseRevId' => $baseRevId,
1614 'oldRevision' => $old_revision,
1615 'oldContent' => $old_content,
1619 'tags' => ( $tags !== null ) ? (
array)$tags : [],
1620 'undidRevId' => $undidRevId
1631 DeferredUpdates::addCallableUpdate(
function ()
use (
$user ) {
1632 $user->addAutopromoteOnceGroups(
'onEdit' );
1633 $user->addAutopromoteOnceGroups(
'onView' );
1657 $status = Status::newGood( [
'new' =>
false,
'revision' =>
null ] );
1661 $oldid = $meta[
'oldId'];
1663 $oldContent = $meta[
'oldContent'];
1664 $newsize = $content->
getSize();
1668 $status->fatal(
'edit-gone-missing' );
1671 } elseif ( !$oldContent ) {
1673 throw new MWException(
"Could not find text for current revision {$oldid}." );
1678 'page' => $this->
getId(),
1679 'title' => $this->mTitle,
1680 'comment' => $summary,
1681 'minor_edit' => $meta[
'minor'],
1682 'text' => $meta[
'serialized'],
1684 'parent_id' => $oldid,
1685 'user' =>
$user->getId(),
1686 'user_text' =>
$user->getName(),
1687 'timestamp' => $now,
1688 'content_model' => $content->
getModel(),
1689 'content_format' => $meta[
'serialFormat'],
1692 $changed = !$content->
equals( $oldContent );
1698 $status->merge( $prepStatus );
1703 $dbw->startAtomic( __METHOD__ );
1708 if ( $latestNow != $oldid ) {
1709 $dbw->endAtomic( __METHOD__ );
1711 $status->fatal(
'edit-conflict' );
1722 $revisionId = $revision->insertOn( $dbw );
1724 if ( !$this->
updateRevisionOn( $dbw, $revision,
null, $meta[
'oldIsRedirect'] ) ) {
1725 throw new MWException(
"Failed to update page row to use new revision." );
1728 Hooks::run(
'NewRevisionFromEditComplete',
1729 [ $this, $revision, $meta[
'baseRevId'],
$user ] );
1735 $this->mTitle->getUserPermissionsErrors(
'autopatrol',
$user ) );
1740 $revision->isMinor(),
1744 $this->getTimestamp(),
1747 $oldContent ? $oldContent->getSize() : 0,
1755 $user->incEditCount();
1757 $dbw->endAtomic( __METHOD__ );
1758 $this->mTimestamp = $now;
1763 $revision->setUserIdAndName(
1771 $status->value[
'revision'] = $revision;
1773 $status->warning(
'edit-no-change' );
1776 $this->mTitle->invalidateCache( $now );
1780 DeferredUpdates::addUpdate(
1793 'changed' => $changed,
1794 'oldcountable' => $meta[
'oldCountable'],
1795 'oldrevision' => $meta[
'oldRevision']
1802 null,
null, &
$flags, $revision, &
$status, $meta[
'baseRevId'],
1803 $meta[
'undidRevId'] ];
1804 Hooks::run(
'PageContentSaveComplete',
$params );
1807 DeferredUpdates::PRESEND
1830 $status = Status::newGood( [
'new' =>
true,
'revision' =>
null ] );
1833 $newsize = $content->
getSize();
1835 $status->merge( $prepStatus );
1841 $dbw->startAtomic( __METHOD__ );
1845 if ( $newid ===
false ) {
1846 $dbw->endAtomic( __METHOD__ );
1847 $status->fatal(
'edit-already-exists' );
1860 'title' => $this->mTitle,
1861 'comment' => $summary,
1862 'minor_edit' => $meta[
'minor'],
1863 'text' => $meta[
'serialized'],
1865 'user' =>
$user->getId(),
1866 'user_text' =>
$user->getName(),
1867 'timestamp' => $now,
1868 'content_model' => $content->
getModel(),
1869 'content_format' => $meta[
'serialFormat'],
1873 $revisionId = $revision->insertOn( $dbw );
1876 throw new MWException(
"Failed to update page row to use new revision." );
1879 Hooks::run(
'NewRevisionFromEditComplete', [ $this, $revision,
false,
$user ] );
1885 !count( $this->mTitle->getUserPermissionsErrors(
'autopatrol',
$user ) );
1890 $revision->isMinor(),
1902 $user->incEditCount();
1904 $dbw->endAtomic( __METHOD__ );
1905 $this->mTimestamp = $now;
1908 $status->value[
'revision'] = $revision;
1911 DeferredUpdates::addUpdate(
1925 Hooks::run(
'PageContentInsertComplete',
$params );
1928 Hooks::run(
'PageContentSaveComplete',
$params );
1931 DeferredUpdates::PRESEND
1954 if ( $this->
getTitle()->isConversionTable() ) {
1957 $options->disableContentConversion();
1981 Content $content, $revision =
null,
User $user =
null,
1982 $serialFormat =
null, $useCache =
true
1986 if ( is_object( $revision ) ) {
1987 $revid = $revision->getId();
1992 if ( $revid !==
null ) {
1993 wfDeprecated( __METHOD__ .
' with $revision = revision ID',
'1.25' );
2004 if ( $serialFormat ===
null ) {
2008 if ( $this->mPreparedEdit
2009 && isset( $this->mPreparedEdit->newContent )
2010 && $this->mPreparedEdit->newContent->equals( $content )
2011 && $this->mPreparedEdit->revid == $revid
2012 && $this->mPreparedEdit->format == $serialFormat
2025 Hooks::run(
'ArticlePrepareTextForEdit', [ $this, $popts ] );
2028 if ( $cachedEdit ) {
2029 $edit->timestamp = $cachedEdit->timestamp;
2034 $edit->revid = $revid;
2036 if ( $cachedEdit ) {
2037 $edit->pstContent = $cachedEdit->pstContent;
2039 $edit->pstContent = $content
2044 $edit->format = $serialFormat;
2046 if ( $cachedEdit ) {
2047 $edit->output = $cachedEdit->output;
2054 $oldCallback = $edit->popts->getCurrentRevisionCallback();
2055 $edit->popts->setCurrentRevisionCallback(
2057 if (
$title->equals( $revision->getTitle() ) ) {
2060 return call_user_func( $oldCallback, $title, $parser );
2066 $dbIndex = ( $this->mDataLoadedFrom & self::READ_LATEST ) === self::READ_LATEST
2070 $edit->popts->setSpeculativeRevIdCallback(
function ()
use ( $dbIndex ) {
2071 return 1 + (int)
wfGetDB( $dbIndex )->selectField(
2079 $edit->output = $edit->pstContent
2080 ? $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts )
2084 $edit->newContent = $content;
2088 $edit->newText = $edit->newContent
2091 $edit->oldText = $edit->oldContent
2094 $edit->pst = $edit->pstContent ? $edit->pstContent->serialize( $serialFormat ) :
'';
2096 if ( $edit->output ) {
2101 $this->mPreparedEdit = $edit;
2134 'restored' =>
false,
2135 'oldrevision' =>
null,
2136 'oldcountable' => null
2140 $logger = LoggerFactory::getInstance(
'SaveParse' );
2144 if ( !$this->mPreparedEdit ) {
2145 $logger->debug( __METHOD__ .
": No prepared edit...\n" );
2146 } elseif ( $this->mPreparedEdit->output->getFlag(
'vary-revision' ) ) {
2147 $logger->info( __METHOD__ .
": Prepared edit has vary-revision...\n" );
2148 } elseif ( $this->mPreparedEdit->output->getFlag(
'vary-revision-id' )
2149 && $this->mPreparedEdit->output->getSpeculativeRevIdUsed() !== $revision->
getId()
2151 $logger->info( __METHOD__ .
": Prepared edit has vary-revision-id with wrong ID...\n" );
2152 } elseif ( $this->mPreparedEdit->output->getFlag(
'vary-user' ) && !
$options[
'changed'] ) {
2153 $logger->info( __METHOD__ .
": Prepared edit has vary-user and is null...\n" );
2155 wfDebug( __METHOD__ .
": Using prepared edit...\n" );
2168 MediaWikiServices::getInstance()->getParserCache()->save(
2169 $editInfo->output, $this, $editInfo->popts,
2176 $updates = $content->getSecondaryDataUpdates(
2177 $this->
getTitle(),
null, $recursive, $editInfo->output
2179 foreach ( $updates
as $update ) {
2181 $update->setRevision( $revision );
2182 $update->setTriggeringUser(
$user );
2184 DeferredUpdates::addUpdate( $update );
2197 'pageId' => $this->
getId(),
2207 Hooks::run(
'ArticleEditUpdates', [ &$wikiPage, &$editInfo,
$options[
'changed'] ] );
2209 if ( Hooks::run(
'ArticleEditUpdatesDeleteFromRecentchanges', [ &$wikiPage ] ) ) {
2211 if ( mt_rand( 0, 9 ) == 0 ) {
2216 if ( !$this->
exists() ) {
2220 $id = $this->
getId();
2221 $title = $this->mTitle->getPrefixedDBkey();
2222 $shortTitle = $this->mTitle->getDBkey();
2224 if (
$options[
'oldcountable'] ===
'no-change' ||
2230 } elseif (
$options[
'oldcountable'] !==
null ) {
2235 $edits =
$options[
'changed'] ? 1 : 0;
2236 $total =
$options[
'created'] ? 1 : 0;
2238 DeferredUpdates::addUpdate(
new SiteStatsUpdate( 0, $edits, $good, $total ) );
2246 && $shortTitle !=
$user->getTitleKey()
2247 && !( $revision->
isMinor() &&
$user->isAllowed(
'nominornewtalk' ) )
2249 $recipient = User::newFromName( $shortTitle,
false );
2250 if ( !$recipient ) {
2251 wfDebug( __METHOD__ .
": invalid username\n" );
2258 if ( Hooks::run(
'ArticleEditUpdateNewTalk', [ &$wikiPage, $recipient ] ) ) {
2259 if ( User::isIP( $shortTitle ) ) {
2261 $recipient->setNewtalk(
true, $revision );
2262 } elseif ( $recipient->isLoggedIn() ) {
2263 $recipient->setNewtalk(
true, $revision );
2265 wfDebug( __METHOD__ .
": don't need to notify a nonexistent user\n" );
2301 &$cascade, $reason,
User $user, $tags =
null
2310 $restrictionTypes = $this->mTitle->getRestrictionTypes();
2311 $id = $this->
getId();
2318 Title::purgeExpiredRestrictions();
2322 $isProtected =
false;
2328 foreach ( $restrictionTypes
as $action ) {
2329 if ( !isset( $expiry[$action] ) || $expiry[$action] === $dbw->getInfinity() ) {
2330 $expiry[$action] =
'infinity';
2332 if ( !isset( $limit[$action] ) ) {
2333 $limit[$action] =
'';
2334 } elseif ( $limit[$action] !=
'' ) {
2339 $current = implode(
'', $this->mTitle->getRestrictions( $action ) );
2340 if ( $current !=
'' ) {
2341 $isProtected =
true;
2344 if ( $limit[$action] != $current ) {
2346 } elseif ( $limit[$action] !=
'' ) {
2350 if ( $this->mTitle->getRestrictionExpiry( $action ) != $expiry[$action] ) {
2356 if ( !$changed && $protect && $this->mTitle->areRestrictionsCascading() != $cascade ) {
2362 return Status::newGood();
2366 $revCommentMsg =
'unprotectedarticle-comment';
2367 $logAction =
'unprotect';
2368 } elseif ( $isProtected ) {
2369 $revCommentMsg =
'modifiedarticleprotection-comment';
2370 $logAction =
'modify';
2372 $revCommentMsg =
'protectedarticle-comment';
2373 $logAction =
'protect';
2376 $logRelationsValues = [];
2377 $logRelationsField =
null;
2378 $logParamsDetails = [];
2381 $nullRevision =
null;
2387 if ( !Hooks::run(
'ArticleProtect', [ &$wikiPage, &
$user, $limit, $reason ] ) ) {
2388 return Status::newGood();
2392 $editrestriction = isset( $limit[
'edit'] )
2393 ? [ $limit[
'edit'] ]
2394 : $this->mTitle->getRestrictions(
'edit' );
2395 foreach ( array_keys( $editrestriction,
'sysop' )
as $key ) {
2396 $editrestriction[$key] =
'editprotected';
2398 foreach ( array_keys( $editrestriction,
'autoconfirmed' )
as $key ) {
2399 $editrestriction[$key] =
'editsemiprotected';
2403 foreach ( array_keys( $cascadingRestrictionLevels,
'sysop' )
as $key ) {
2404 $cascadingRestrictionLevels[$key] =
'editprotected';
2406 foreach ( array_keys( $cascadingRestrictionLevels,
'autoconfirmed' )
as $key ) {
2407 $cascadingRestrictionLevels[$key] =
'editsemiprotected';
2411 if ( !array_intersect( $editrestriction, $cascadingRestrictionLevels ) ) {
2426 if ( $nullRevision ===
null ) {
2427 return Status::newFatal(
'no-null-revision', $this->mTitle->getPrefixedText() );
2430 $logRelationsField =
'pr_id';
2433 foreach ( $limit
as $action => $restrictions ) {
2435 'page_restrictions',
2438 'pr_type' => $action
2442 if ( $restrictions !=
'' ) {
2443 $cascadeValue = ( $cascade && $action ==
'edit' ) ? 1 : 0;
2445 'page_restrictions',
2448 'pr_type' => $action,
2449 'pr_level' => $restrictions,
2450 'pr_cascade' => $cascadeValue,
2451 'pr_expiry' => $dbw->encodeExpiry( $expiry[$action] )
2455 $logRelationsValues[] = $dbw->insertId();
2456 $logParamsDetails[] = [
2458 'level' => $restrictions,
2459 'expiry' => $expiry[$action],
2460 'cascade' => (bool)$cascadeValue,
2468 [
'page_restrictions' =>
'' ],
2469 [
'page_id' => $id ],
2476 Hooks::run(
'NewRevisionFromEditComplete',
2477 [ $this, $nullRevision, $latest,
$user ] );
2478 Hooks::run(
'ArticleProtectComplete', [ &$wikiPage, &
$user, $limit, $reason ] );
2483 if ( $limit[
'create'] !=
'' ) {
2485 $dbw->replace(
'protected_titles',
2486 [ [
'pt_namespace',
'pt_title' ] ],
2488 'pt_namespace' => $this->mTitle->getNamespace(),
2489 'pt_title' => $this->mTitle->getDBkey(),
2490 'pt_create_perm' => $limit[
'create'],
2491 'pt_timestamp' => $dbw->timestamp(),
2492 'pt_expiry' => $dbw->encodeExpiry( $expiry[
'create'] ),
2493 'pt_user' =>
$user->getId(),
2494 ] + $commentFields, __METHOD__
2496 $logParamsDetails[] = [
2498 'level' => $limit[
'create'],
2499 'expiry' => $expiry[
'create'],
2502 $dbw->delete(
'protected_titles',
2504 'pt_namespace' => $this->mTitle->getNamespace(),
2505 'pt_title' => $this->mTitle->getDBkey()
2511 $this->mTitle->flushRestrictions();
2514 if ( $logAction ==
'unprotect' ) {
2519 '4::description' => $protectDescriptionLog,
2520 '5:bool:cascade' => $cascade,
2521 'details' => $logParamsDetails,
2527 $logEntry->setTarget( $this->mTitle );
2528 $logEntry->setComment( $reason );
2529 $logEntry->setPerformer(
$user );
2530 $logEntry->setParameters(
$params );
2531 if ( !is_null( $nullRevision ) ) {
2532 $logEntry->setAssociatedRevId( $nullRevision->getId() );
2534 $logEntry->setTags( $tags );
2535 if ( $logRelationsField !==
null && count( $logRelationsValues ) ) {
2536 $logEntry->setRelations( [ $logRelationsField => $logRelationsValues ] );
2538 $logId = $logEntry->insert();
2539 $logEntry->publish( $logId );
2541 return Status::newGood( $logId );
2556 array $expiry, $cascade, $reason, $user =
null
2563 $this->mTitle->getPrefixedText(),
2565 )->inContentLanguage()->text();
2567 $editComment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() . $reason;
2570 if ( $protectDescription ) {
2571 $editComment .=
wfMessage(
'word-separator' )->inContentLanguage()->text();
2572 $editComment .=
wfMessage(
'parentheses' )->params( $protectDescription )
2573 ->inContentLanguage()->text();
2576 $editComment .=
wfMessage(
'word-separator' )->inContentLanguage()->text();
2577 $editComment .=
wfMessage(
'brackets' )->params(
2578 wfMessage(
'protect-summary-cascade' )->inContentLanguage()->
text()
2579 )->inContentLanguage()->text();
2584 $nullRev->insertOn( $dbw );
2587 $oldLatest = $nullRev->getParentId();
2601 if ( $expiry !=
'infinity' ) {
2604 $wgContLang->timeanddate( $expiry,
false,
false ),
2607 )->inContentLanguage()->text();
2609 return wfMessage(
'protect-expiry-indefinite' )
2610 ->inContentLanguage()->text();
2622 $protectDescription =
'';
2624 foreach ( array_filter( $limit )
as $action => $restrictions ) {
2625 # $action is one of $wgRestrictionTypes = [ 'create', 'edit', 'move', 'upload' ].
2626 # All possible message keys are listed here for easier grepping:
2627 # * restriction-create
2628 # * restriction-edit
2629 # * restriction-move
2630 # * restriction-upload
2631 $actionText =
wfMessage(
'restriction-' . $action )->inContentLanguage()->text();
2632 # $restrictions is one of $wgRestrictionLevels = [ '', 'autoconfirmed', 'sysop' ],
2633 # with '' filtered out. All possible message keys are listed below:
2634 # * protect-level-autoconfirmed
2635 # * protect-level-sysop
2636 $restrictionsText =
wfMessage(
'protect-level-' . $restrictions )
2637 ->inContentLanguage()->text();
2641 if ( $protectDescription !==
'' ) {
2642 $protectDescription .=
wfMessage(
'word-separator' )->inContentLanguage()->text();
2644 $protectDescription .=
wfMessage(
'protect-summary-desc' )
2645 ->params( $actionText, $restrictionsText, $expiryText )
2646 ->inContentLanguage()->text();
2649 return $protectDescription;
2666 $protectDescriptionLog =
'';
2668 foreach ( array_filter( $limit )
as $action => $restrictions ) {
2670 $protectDescriptionLog .=
$wgContLang->getDirMark() .
2671 "[$action=$restrictions] ($expiryText)";
2674 return trim( $protectDescriptionLog );
2687 if ( !is_array( $limit ) ) {
2688 throw new MWException( __METHOD__ .
' given non-array restriction set' );
2694 foreach ( array_filter( $limit )
as $action => $restrictions ) {
2695 $bits[] =
"$action=$restrictions";
2698 return implode(
':', $bits );
2718 $reason, $suppress =
false, $u1 =
null, $u2 =
null, &$error =
'',
User $user =
null
2744 $reason, $suppress =
false, $u1 =
null, $u2 =
null, &$error =
'',
User $user =
null,
2745 $tags = [], $logsubtype =
'delete'
2753 if ( $this->mTitle->getDBkey() ===
'' ) {
2754 $status->error(
'cannotdelete',
2763 if ( !Hooks::run(
'ArticleDelete',
2764 [ &$wikiPage, &
$user, &$reason, &$error, &
$status, $suppress ]
2768 $status->fatal(
'delete-hook-aborted' );
2774 $dbw->startAtomic( __METHOD__ );
2777 $id = $this->
getId();
2783 if ( $id == 0 || $this->
getLatest() != $lockedLatest ) {
2784 $dbw->endAtomic( __METHOD__ );
2786 $status->error(
'cannotdelete',
2792 $namespace = $this->
getTitle()->getNamespace();
2793 $dbKey = $this->
getTitle()->getDBkey();
2804 }
catch ( Exception $ex ) {
2805 wfLogWarning( __METHOD__ .
': failed to load content during deletion! '
2806 . $ex->getMessage() );
2820 $fields = array_diff( $fields, [
'rev_deleted' ] );
2831 $commentQuery = $revCommentStore->getJoin();
2832 $res = $dbw->select(
2833 [
'revision' ] + $commentQuery[
'tables'],
2834 $fields + $commentQuery[
'fields'],
2835 [
'rev_page' => $id ],
2838 $commentQuery[
'joins']
2848 foreach (
$res as $row ) {
2849 $comment = $revCommentStore->getComment( $row );
2851 'ar_namespace' => $namespace,
2852 'ar_title' => $dbKey,
2853 'ar_user' => $row->rev_user,
2854 'ar_user_text' => $row->rev_user_text,
2855 'ar_timestamp' => $row->rev_timestamp,
2856 'ar_minor_edit' => $row->rev_minor_edit,
2857 'ar_rev_id' => $row->rev_id,
2858 'ar_parent_id' => $row->rev_parent_id,
2859 'ar_text_id' => $row->rev_text_id,
2862 'ar_len' => $row->rev_len,
2863 'ar_page_id' => $id,
2864 'ar_deleted' => $suppress ? $bitfield : $row->rev_deleted,
2865 'ar_sha1' => $row->rev_sha1,
2866 ] + $arCommentStore->insert( $dbw, $comment );
2868 $rowInsert[
'ar_content_model'] = $row->rev_content_model;
2869 $rowInsert[
'ar_content_format'] = $row->rev_content_format;
2871 $rowsInsert[] = $rowInsert;
2872 $revids[] = $row->rev_id;
2876 if ( (
int)$row->rev_user === 0 && IP::isValid( $row->rev_user_text ) ) {
2877 $ipRevIds[] = $row->rev_id;
2881 $dbw->insert(
'archive', $rowsInsert, __METHOD__ );
2883 $archivedRevisionCount = $dbw->affectedRows();
2888 $wikiPageBeforeDelete = clone $this;
2891 $dbw->delete(
'page', [
'page_id' => $id ], __METHOD__ );
2892 $dbw->delete(
'revision', [
'rev_page' => $id ], __METHOD__ );
2894 $dbw->delete(
'revision_comment_temp', [
'revcomment_rev' => $revids ], __METHOD__ );
2898 if ( count( $ipRevIds ) > 0 ) {
2899 $dbw->delete(
'ip_changes', [
'ipc_rev_id' => $ipRevIds ], __METHOD__ );
2903 $logtype = $suppress ?
'suppress' :
'delete';
2906 $logEntry->setPerformer(
$user );
2907 $logEntry->setTarget( $logTitle );
2908 $logEntry->setComment( $reason );
2909 $logEntry->setTags( $tags );
2910 $logid = $logEntry->insert();
2912 $dbw->onTransactionPreCommitOrIdle(
2913 function ()
use ( $dbw, $logEntry, $logid ) {
2915 $logEntry->publish( $logid );
2920 $dbw->endAtomic( __METHOD__ );
2924 Hooks::run(
'ArticleDeleteComplete', [
2925 &$wikiPageBeforeDelete,
2931 $archivedRevisionCount
2936 $cache = MediaWikiServices::getInstance()->getMainObjectStash();
2937 $key =
$cache->makeKey(
'page-recent-delete', md5( $logTitle->getPrefixedText() ) );
2938 $cache->set( $key, 1, $cache::TTL_DAY );
2954 'page_id' => $this->
getId(),
2957 'page_namespace' => $this->
getTitle()->getNamespace(),
2958 'page_title' => $this->
getTitle()->getDBkey()
2977 }
catch ( Exception $ex ) {
2984 DeferredUpdates::addUpdate(
new SiteStatsUpdate( 0, 1, - (
int)$countable, -1 ) );
2988 foreach ( $updates
as $update ) {
2989 DeferredUpdates::addUpdate( $update );
2996 if ( $this->mTitle->getNamespace() ==
NS_FILE ) {
3003 $this->mTitle, $revision,
null,
wfWikiID()
3010 DeferredUpdates::addUpdate(
new SearchUpdate( $id, $this->mTitle ) );
3043 $fromP, $summary, $token, $bot, &$resultDetails,
User $user, $tags =
null
3045 $resultDetails =
null;
3048 $editErrors = $this->mTitle->getUserPermissionsErrors(
'edit',
$user );
3049 $rollbackErrors = $this->mTitle->getUserPermissionsErrors(
'rollback',
$user );
3050 $errors = array_merge( $editErrors,
wfArrayDiff2( $rollbackErrors, $editErrors ) );
3052 if ( !
$user->matchEditToken( $token,
'rollback' ) ) {
3053 $errors[] = [
'sessionfailure' ];
3056 if (
$user->pingLimiter(
'rollback' ) ||
$user->pingLimiter() ) {
3057 $errors[] = [
'actionthrottledtext' ];
3061 if ( !empty( $errors ) ) {
3089 &$resultDetails,
User $guser, $tags =
null
3096 return [ [
'readonlytext' ] ];
3101 if ( is_null( $current ) ) {
3103 return [ [
'notanarticle' ] ];
3106 $from = str_replace(
'_',
' ', $fromP );
3109 if ( $from != $current->getUserText() ) {
3110 $resultDetails = [
'current' => $current ];
3111 return [ [
'alreadyrolled',
3112 htmlspecialchars( $this->mTitle->getPrefixedText() ),
3113 htmlspecialchars( $fromP ),
3114 htmlspecialchars( $current->getUserText() )
3121 $user_text = $dbw->addQuotes( $current->getUserText(
Revision::RAW ) );
3122 $s = $dbw->selectRow(
'revision',
3123 [
'rev_id',
'rev_timestamp',
'rev_deleted' ],
3124 [
'rev_page' => $current->getPage(),
3125 "rev_user != {$user} OR rev_user_text != {$user_text}"
3127 [
'USE INDEX' =>
'page_timestamp',
3128 'ORDER BY' =>
'rev_timestamp DESC' ]
3130 if (
$s ===
false ) {
3132 return [ [
'cantrollback' ] ];
3137 return [ [
'notvisiblerev' ] ];
3142 if ( empty( $summary ) ) {
3143 if ( $from ==
'' ) {
3144 $summary =
wfMessage(
'revertpage-nouser' );
3152 $target->getUserText(), $from,
$s->rev_id,
3154 $current->getId(),
$wgContLang->timeanddate( $current->getTimestamp() )
3156 if ( $summary instanceof
Message ) {
3157 $summary = $summary->params(
$args )->inContentLanguage()->text();
3163 $summary = trim( $summary );
3168 if ( $guser->
isAllowed(
'minoredit' ) ) {
3172 if ( $bot && ( $guser->
isAllowedAny(
'markbotedits',
'bot' ) ) ) {
3176 $targetContent = $target->getContent();
3177 $changingContentModel = $targetContent->getModel() !== $current->getContentModel();
3193 if ( $bot && $guser->
isAllowed(
'markbotedits' ) ) {
3200 $set[
'rc_patrolled'] = 1;
3203 if ( count( $set ) ) {
3204 $dbw->update(
'recentchanges', $set,
3206 'rc_cur_id' => $current->getPage(),
3207 'rc_user_text' => $current->getUserText(),
3208 'rc_timestamp > ' . $dbw->addQuotes(
$s->rev_timestamp ),
3215 return $status->getErrorsArray();
3219 $statusRev = isset(
$status->value[
'revision'] )
3222 if ( !( $statusRev instanceof
Revision ) ) {
3223 $resultDetails = [
'current' => $current ];
3224 return [ [
'alreadyrolled',
3225 htmlspecialchars( $this->mTitle->getPrefixedText() ),
3226 htmlspecialchars( $fromP ),
3227 htmlspecialchars( $current->getUserText() )
3231 if ( $changingContentModel ) {
3235 $log->setPerformer( $guser );
3236 $log->setTarget( $this->mTitle );
3237 $log->setComment( $summary );
3238 $log->setParameters( [
3239 '4::oldmodel' => $current->getContentModel(),
3240 '5::newmodel' => $targetContent->getModel(),
3243 $logId = $log->insert( $dbw );
3244 $log->publish( $logId );
3247 $revId = $statusRev->getId();
3249 Hooks::run(
'ArticleRollbackComplete', [ $this, $guser, $target, $current ] );
3252 'summary' => $summary,
3253 'current' => $current,
3254 'target' => $target,
3274 $other =
$title->getOtherPage();
3276 $other->purgeSquid();
3280 $title->deleteTitleProtection();
3282 MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle(
$title );
3292 Category::newFromTitle(
$title )->getID();
3303 $other =
$title->getOtherPage();
3305 $other->purgeSquid();
3310 MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle(
$title );
3328 $user = User::newFromName(
$title->getText(),
false );
3330 $user->setNewtalk(
false );
3351 MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle(
$title );
3358 $revid = $revision ? $revision->getId() :
null;
3359 DeferredUpdates::addCallableUpdate(
function ()
use (
$title, $revid ) {
3373 $id = $this->
getId();
3379 $res =
$dbr->select(
'categorylinks',
3380 [
'cl_to AS page_title, ' .
NS_CATEGORY .
' AS page_namespace' ],
3383 [
'cl_from' => $id ],
3397 $id = $this->
getId();
3404 $res =
$dbr->select( [
'categorylinks',
'page_props',
'page' ],
3406 [
'cl_from' => $id,
'pp_page=page_id',
'pp_propname' =>
'hiddencat',
3407 'page_namespace' =>
NS_CATEGORY,
'page_title=cl_to' ],
3410 if (
$res !==
false ) {
3411 foreach (
$res as $row ) {
3441 $id = $id ?: $this->
getId();
3442 $ns = $this->
getTitle()->getNamespace();
3444 $addFields = [
'cat_pages = cat_pages + 1' ];
3445 $removeFields = [
'cat_pages = cat_pages - 1' ];
3447 $addFields[] =
'cat_subcats = cat_subcats + 1';
3448 $removeFields[] =
'cat_subcats = cat_subcats - 1';
3450 $addFields[] =
'cat_files = cat_files + 1';
3451 $removeFields[] =
'cat_files = cat_files - 1';
3456 if ( count( $added ) ) {
3457 $existingAdded = $dbw->selectFieldValues(
3460 [
'cat_title' => $added ],
3467 if ( count( $existingAdded ) ) {
3471 [
'cat_title' => $existingAdded ],
3476 $missingAdded = array_diff( $added, $existingAdded );
3477 if ( count( $missingAdded ) ) {
3479 foreach ( $missingAdded
as $cat ) {
3481 'cat_title' => $cat,
3484 'cat_files' => ( $ns ==
NS_FILE ) ? 1 : 0,
3497 if ( count( $deleted ) ) {
3501 [
'cat_title' => $deleted ],
3506 foreach ( $added
as $catName ) {
3507 $cat = Category::newFromName( $catName );
3508 Hooks::run(
'CategoryAfterPageAdded', [ $cat, $this ] );
3511 foreach ( $deleted
as $catName ) {
3512 $cat = Category::newFromName( $catName );
3513 Hooks::run(
'CategoryAfterPageRemoved', [ $cat, $this, $id ] );
3519 if ( count( $deleted ) ) {
3520 $rows = $dbw->select(
3522 [
'cat_id',
'cat_title',
'cat_pages',
'cat_subcats',
'cat_files' ],
3523 [
'cat_title' => $deleted,
'cat_pages <= 0' ],
3527 $cat = Category::newFromRow( $row );
3529 DeferredUpdates::addCallableUpdate(
function ()
use ( $cat ) {
3530 $cat->refreshCounts();
3547 if ( !Hooks::run(
'OpportunisticLinksUpdate',
3548 [ $this, $this->mTitle, $parserOutput ]
3556 'isOpportunistic' =>
true,
3560 if ( $this->mTitle->areRestrictionsCascading() ) {
3565 } elseif ( !$config->get(
'MiserMode' ) && $parserOutput->
hasDynamicContent() ) {
3575 $cache = ObjectCache::getLocalClusterInstance();
3576 $key =
$cache->makeKey(
'dynamic-linksupdate',
'last', $this->
getId() );
3578 if (
$cache->add( $key, time(), $ttl ) ) {
3602 }
catch ( Exception $ex ) {
3613 $updates = $content->getDeletionUpdates( $this );
3616 Hooks::run(
'WikiPageDeletionUpdates', [ $this, $content, &$updates ] );
3654 return $this->
getTitle()->getCanonicalURL();
3663 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
3665 return $linkCache->getMutableCacheKeys(
$cache, $this->
getTitle()->getTitleValue() );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
$wgCascadingRestrictionLevels
Restriction levels that can be used with cascading protection.
$wgUseAutomaticEditSummaries
If user doesn't specify any edit summary when making a an edit, MediaWiki will try to automatically c...
$wgSitename
Name of the site.
$wgUseRCPatrol
Use RC Patrolling to check for vandalism (from recent changes and watchlists) New pages and new files...
$wgUseNPPatrol
Use new page patrolling to check new pages on Special:Newpages.
$wgArticleCountMethod
Method used to determine if a page in a content namespace should be counted as a valid article.
$wgAjaxEditStash
Have clients send edits to be prepared when filling in edit summaries.
int $wgCommentTableSchemaMigrationStage
Comment table schema migration stage.
$wgRCWatchCategoryMembership
Treat category membership changes as a RecentChange.
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfRandom()
Get a random decimal value between 0 and 1, in a way not likely to give duplicate values for any real...
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfIncrStats( $key, $count=1)
Increment a statistics counter.
wfGetLB( $wiki=false)
Get a load balancer object.
wfReadOnly()
Check whether the wiki is in read-only mode.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfArrayDiff2( $a, $b)
Like array_diff( $a, $b ) except that it works with two-dimensional arrays.
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
wfMsgReplaceArgs( $message, $args)
Replace message parameter keys on the given formatted output.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
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.
static checkCache(Title $title, Content $content, User $user)
Check that a prepared edit is in cache and still up-to-date.
Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
getCacheExpiry()
Returns the number of seconds after which this object should expire.
Job to add recent change entries mentioning category membership changes.
Handles purging appropriate CDN URLs given a title (or titles)
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
static getLocalizedName( $name, Language $lang=null)
Returns the localized name for a given content model.
static getContentText(Content $content=null)
Convenience function for getting flat text from a Content object.
static getDBOptions( $bitfield)
Get an appropriate DB index, options, and fallback DB index for a query.
Class to invalidate the HTML cache of all the pages linking to a given title.
static clearFileCache(Title $title)
Clear the file caches for a page for all actions.
static invalidateCache(Title $title, $revid=null)
Clear the info cache for a given Title.
static singleton( $wiki=false)
Class the manages updates of *_link tables as well as similar extension-managed tables.
static queueRecursiveJobsForTable(Title $title, $table)
Queue a RefreshLinks job for any table.
Class for creating log entries manually, to inject them into the database.
static singleton()
Get the signleton instance of this class.
The Message class provides methods which fulfil two basic services:
Set options of the Parser.
getStubThreshold()
Thumb size preferred by the user.
isSafeToCache()
Test whether these options are safe to cache.
hasDynamicContent()
Check whether the cache TTL was lowered due to dynamic content.
static notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot, $ip='', $size=0, $newId=0, $patrol=0, $tags=[])
Makes an entry in the database corresponding to page creation Note: the title object must be loaded w...
static notifyEdit( $timestamp, &$title, $minor, &$user, $comment, $oldId, $lastTimestamp, $bot, $ip='', $oldSize=0, $newSize=0, $newId=0, $patrol=0, $tags=[])
Makes an entry in the database corresponding to an edit.
static newPrioritized(Title $title, array $params)
static newDynamic(Title $title, array $params)
static singleton()
Get a RepoGroup instance.
static getMain()
Static methods.
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 newKnownCurrent(IDatabase $db, $pageId, $revId)
Load a revision based on a known page ID and current revision ID from the DB.
getContentHandler()
Returns the content handler appropriate for this revision's content model.
static newFromPageId( $pageId, $revId=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given page ID.
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
static loadFromTimestamp( $db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
static newNullRevision( $dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Database independant search index updater.
Class for handling updates to the site_stats table.
static newFromResult( $res)
Represents a title within MediaWiki.
getNamespace()
Get the namespace index, i.e.
getFragment()
Get the Title fragment (i.e.
getDBkey()
Get the main part with underscores.
getInterwiki()
Get the interwiki prefix.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
isAllowed( $action='')
Internal mechanics of testing a permission.
isAllowedAny()
Check if user is allowed to access a feature / make an action.
Multi-datacenter aware caching interface.
Special handling for category pages.
Special handling for file pages.
Class representing a MediaWiki article and history.
static newFromID( $id, $from='fromdb')
Constructor from a page id.
doUpdateRestrictions(array $limit, array $expiry, &$cascade, $reason, User $user, $tags=null)
Update the article's restriction field, and leave a log entry.
getContributors()
Get a list of users who have edited this article, not including the user who made the most recent rev...
doPurge()
Perform the actions of a page purging.
followRedirect()
Get the Title object or URL this page redirects to.
insertOn( $dbw, $pageId=null)
Insert a new empty page record for this article.
updateCategoryCounts(array $added, array $deleted, $id=0)
Update all the appropriate counts in the category table, given that we've added the categories $added...
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
doEditContent(Content $content, $summary, $flags=0, $baseRevId=false, User $user=null, $serialFormat=null, $tags=[], $undidRevId=0)
Change an existing article or create a new article.
pageDataFromTitle( $dbr, $title, $options=[])
Fetch a page record matching the Title object's namespace and title using a sanitized title string.
checkFlags( $flags)
Check flags and add EDIT_NEW or EDIT_UPDATE to them as needed.
static onArticleEdit(Title $title, Revision $revision=null)
Purge caches on page update etc.
isLocal()
Whether this content displayed on this page comes from the local database.
getRevision()
Get the latest revision.
getLinksTimestamp()
Get the page_links_updated field.
getMinorEdit()
Returns true if last revision was marked as "minor edit".
getUndoContent(Revision $undo, Revision $undoafter=null)
Get the content that needs to be saved in order to undo all revisions between $undo and $undoafter.
clearCacheFields()
Clear the object cache fields.
clearPreparedEdit()
Clear the mPreparedEdit cache field, as may be needed by mutable content types.
getLatest()
Get the page_latest field.
PreparedEdit $mPreparedEdit
Map of cache fields (text, parser output, ect) for a proposed/new edit.
doViewUpdates(User $user, $oldid=0)
Do standard deferred updates after page view (existing or missing page)
updateIfNewerOn( $dbw, $revision)
If the given revision is newer than the currently set page_latest, update the page record.
__clone()
Makes sure that the mTitle object is cloned to the newly cloned WikiPage.
loadFromRow( $data, $from)
Load the object from a database row.
supportsSections()
Returns true if this page's content model supports sections.
getRedirectTarget()
If this page is a redirect, get its target.
setTimestamp( $ts)
Set the page timestamp (use only to avoid DB queries)
protectDescriptionLog(array $limit, array $expiry)
Builds the description to serve as comment for the log entry.
getUser( $audience=Revision::FOR_PUBLIC, User $user=null)
makeParserOptions( $context)
Get parser options suitable for rendering the primary article wikitext.
pageData( $dbr, $conditions, $options=[])
Fetch a page record with the given conditions.
getSourceURL()
Get the source URL for the content on this page, typically the canonical URL, but may be a remote lin...
getOldestRevision()
Get the Revision object of the oldest revision.
replaceSectionAtRev( $sectionId, Content $sectionContent, $sectionTitle='', $baseRevId=null)
setLastEdit(Revision $revision)
Set the latest revision.
updateRevisionOn( $dbw, $revision, $lastRevision=null, $lastRevIsRedirect=null)
Update the page record to point to a newly saved revision.
shouldCheckParserCache(ParserOptions $parserOptions, $oldId)
Should the parser cache be used?
loadLastEdit()
Loads everything except the text This isn't necessary for all uses, so it's only done if needed.
getUserText( $audience=Revision::FOR_PUBLIC, User $user=null)
doModify(Content $content, $flags, User $user, $summary, array $meta)
getContentModel()
Returns the page's content model id (see the CONTENT_MODEL_XXX constants).
pageDataFromId( $dbr, $id, $options=[])
Fetch a page record matching the requested ID.
const PURGE_CLUSTER_PCACHE
doEditUpdates(Revision $revision, User $user, array $options=[])
Do standard deferred updates after page edit.
insertRedirectEntry(Title $rt, $oldLatest=null)
Insert or update the redirect table entry for this page to indicate it redirects to $rt.
doDeleteArticle( $reason, $suppress=false, $u1=null, $u2=null, &$error='', User $user=null)
Same as doDeleteArticleReal(), but returns a simple boolean.
string $mTimestamp
Timestamp of the current revision or empty string if not loaded.
getHiddenCategories()
Returns a list of hidden categories this page is a member of.
getComment( $audience=Revision::FOR_PUBLIC, User $user=null)
static newFromRow( $row, $from='fromdb')
Constructor from a database row.
getAutoDeleteReason(&$hasHistory)
Auto-generates a deletion reason.
lockAndGetLatest()
Lock the page row for this title+id and return page_latest (or 0)
const PURGE_GLOBAL_PCACHE
static flattenRestrictions( $limit)
Take an array of page restrictions and flatten it to a string suitable for insertion into the page_re...
getParserOutput(ParserOptions $parserOptions, $oldid=null, $forceParse=false)
Get a ParserOutput for the given ParserOptions and revision ID.
updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect=null)
Add row to the redirect table if this is a redirect, remove otherwise.
prepareContentForEdit(Content $content, $revision=null, User $user=null, $serialFormat=null, $useCache=true)
Prepare content which is about to be saved.
hasViewableContent()
Check if this page is something we're going to be showing some sort of sensible content for.
triggerOpportunisticLinksUpdate(ParserOutput $parserOutput)
Opportunistically enqueue link update jobs given fresh parser output if useful.
getDeletionUpdates(Content $content=null)
Returns a list of updates to be performed when this page is deleted.
insertRedirect()
Insert an entry for this page into the redirect table if the content is a redirect.
getContent( $audience=Revision::FOR_PUBLIC, User $user=null)
Get the content of the current revision.
int $mDataLoadedFrom
One of the READ_* constants.
static onArticleDelete(Title $title)
Clears caches when article is deleted.
replaceSectionContent( $sectionId, Content $sectionContent, $sectionTitle='', $edittime=null)
static selectFields()
Return the list of revision fields that should be selected to create a new page.
insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user=null)
Insert a new null revision for this page.
doDeleteUpdates( $id, Content $content=null, Revision $revision=null)
Do some database updates after deletion.
getTitle()
Get the title object of the article.
isRedirect()
Tests if the article content represents a redirect.
static onArticleCreate(Title $title)
The onArticle*() functions are supposed to be a kind of hooks which should be called whenever any of ...
commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser, $tags=null)
Backend implementation of doRollback(), please refer there for parameter and return value documentati...
getRedirectURL( $rt)
Get the Title object or URL to use for a redirect.
loadPageData( $from='fromdb')
Load the object from a given source by title.
doCreate(Content $content, $flags, User $user, $summary, array $meta)
checkTouched()
Loads page_touched and returns a value indicating if it should be used.
getLastPurgeTimestamp()
Get the last time a user explicitly purged the page via action=purge.
isCountable( $editInfo=false)
Determine whether a page would be suitable for being counted as an article in the site_stats table ba...
doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user, $tags=null)
Roll back the most recent consecutive set of edits to a page from the same user; fails if there are n...
getContentHandler()
Returns the ContentHandler instance to be used to deal with the content of this WikiPage.
getWikiDisplayName()
The display name for the site this content come from.
static convertSelectType( $type)
Convert 'fromdb', 'fromdbmaster' and 'forupdate' to READ_* constants.
getCreator( $audience=Revision::FOR_PUBLIC, User $user=null)
Get the User object of the user who created the page.
getMutableCacheKeys(WANObjectCache $cache)
protectDescription(array $limit, array $expiry)
Builds the description to serve as comment for the edit.
getTouched()
Get the page_touched field.
__construct(Title $title)
Constructor and clear the article.
doDeleteArticleReal( $reason, $suppress=false, $u1=null, $u2=null, &$error='', User $user=null, $tags=[], $logsubtype='delete')
Back-end article deletion Deletes the article with database consistency, writes logs,...
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
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 local content language as $wgContLang
when a variable name is used in a function
when a variable name is used in a it is silently declared as a new local masking the global
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 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
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). '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
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. '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 '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
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 local account incomplete not yet checked for validity & $retval
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
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
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 you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
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
it s the revision text itself In either if gzip is the revision text is gzipped $flags
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 modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
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
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 local account $user
returning false will NOT prevent logging $e
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
Base interface for content objects.
getContentHandler()
Convenience method that returns the ContentHandler singleton for handling the content model that this...
getModel()
Returns the ID of the content model used by this Content object.
preSaveTransform(Title $title, User $user, ParserOptions $parserOptions)
Returns a Content object with pre-save transformations applied (or this object if no transformations ...
getSize()
Returns the content's nominal size in "bogo-bytes".
equals(Content $that=null)
Returns true if this Content objects is conceptually equivalent to the given Content object.
prepareSave(WikiPage $page, $flags, $parentRevId, User $user)
Prepare Content for saving.
Interface for database access objects.
const READ_LOCKING
Constants for object loading bitfield flags (higher => higher QoS)
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)