26 use Wikimedia\Assert\Assert;
116 $ns =
$title->getNamespace();
119 throw new MWException(
"NS_MEDIA is a virtual namespace; use NS_FILE." );
120 } elseif ( $ns < 0 ) {
121 throw new MWException(
"Invalid or virtual namespace $ns given." );
153 public static function newFromID( $id, $from =
'fromdb' ) {
162 $row = $db->selectRow(
163 $pageQuery[
'tables'], $pageQuery[
'fields'], [
'page_id' => $id ], __METHOD__,
164 [], $pageQuery[
'joins']
183 public static function newFromRow( $row, $from =
'fromdb' ) {
185 $page->loadFromRow( $row, $from );
198 return self::READ_NORMAL;
200 return self::READ_LATEST;
245 $this->mDataLoaded =
false;
257 $this->mRedirectTarget =
null;
258 $this->mLastRevision =
null;
259 $this->mTouched =
'19700101000000';
260 $this->mLinksUpdated =
'19700101000000';
261 $this->mTimestamp =
'';
262 $this->mIsRedirect =
false;
263 $this->mLatest =
false;
276 $this->mPreparedEdit =
false;
300 'page_links_updated',
306 $fields[] =
'page_content_model';
310 $fields[] =
'page_lang';
329 'tables' => [
'page' ],
339 'page_links_updated',
347 $ret[
'fields'][] =
'page_content_model';
351 $ret[
'fields'][] =
'page_lang';
371 &$wikiPage, &$pageQuery[
'fields'], &$pageQuery[
'tables'], &$pageQuery[
'joins']
374 $row =
$dbr->selectRow(
375 $pageQuery[
'tables'],
376 $pageQuery[
'fields'],
383 Hooks::run(
'ArticlePageDataAfter', [ &$wikiPage, &$row ] );
399 'page_namespace' =>
$title->getNamespace(),
429 if ( is_int( $from ) && $from <= $this->mDataLoadedFrom ) {
434 if ( is_int( $from ) ) {
436 $loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
437 $db = $loadBalancer->getConnection( $index );
442 && $loadBalancer->getServerCount() > 1
443 && $loadBalancer->hasOrMadeRecentMasterChanges()
445 $from = self::READ_LATEST;
447 $db = $loadBalancer->getConnection( $index );
453 $from = self::READ_NORMAL;
472 $lc->clearLink( $this->mTitle );
475 $lc->addGoodLinkObjFromRow( $this->mTitle, $data );
477 $this->mTitle->loadFromRow( $data );
480 $this->mTitle->loadRestrictions( $data->page_restrictions );
482 $this->mId = intval( $data->page_id );
483 $this->mTouched =
wfTimestamp( TS_MW, $data->page_touched );
485 $this->mIsRedirect = intval( $data->page_is_redirect );
486 $this->mLatest = intval( $data->page_latest );
489 if ( $this->mLastRevision && $this->mLastRevision->getId() != $this->mLatest ) {
490 $this->mLastRevision =
null;
491 $this->mTimestamp =
'';
494 $lc->addBadLinkObj( $this->mTitle );
496 $this->mTitle->loadFromRow(
false );
503 $this->mDataLoaded =
true;
511 if ( !$this->mDataLoaded ) {
521 if ( !$this->mDataLoaded ) {
524 return $this->mId > 0;
536 return $this->mTitle->isKnown();
545 if ( !$this->mDataLoaded ) {
566 return $cache->getWithSetCallback(
567 $cache->makeKey(
'page-content-model', $this->getLatest() ),
573 return $rev->getContentModel();
575 $title = $this->mTitle->getPrefixedDBkey();
576 wfWarn(
"Page $title exists but has no (visible) revisions!" );
577 return $this->mTitle->getContentModel();
584 return $this->mTitle->getContentModel();
592 if ( !$this->mDataLoaded ) {
595 return ( $this->mId && !$this->mIsRedirect );
603 if ( !$this->mDataLoaded ) {
614 if ( !$this->mDataLoaded ) {
625 if ( !$this->mDataLoaded ) {
637 $rev = $this->mTitle->getFirstRevision();
649 if ( $this->mLastRevision !==
null ) {
658 if ( $this->mDataLoadedFrom == self::READ_LOCKING ) {
668 } elseif ( $this->mDataLoadedFrom == self::READ_LATEST ) {
672 $flags = Revision::READ_LATEST;
689 $this->mLastRevision = $revision;
699 if ( $this->mLastRevision ) {
720 if ( $this->mLastRevision ) {
721 return $this->mLastRevision->getContent( $audience,
$user );
731 if ( !$this->mTimestamp ) {
758 if ( $this->mLastRevision ) {
759 return $this->mLastRevision->getUser( $audience,
$user );
778 $userName = $revision->getUserText( $audience,
$user );
796 if ( $this->mLastRevision ) {
797 return $this->mLastRevision->getUserText( $audience,
$user );
814 if ( $this->mLastRevision ) {
815 return $this->mLastRevision->getComment( $audience,
$user );
828 if ( $this->mLastRevision ) {
829 return $this->mLastRevision->isMinor();
846 if ( !$this->mTitle->isContentPage() ) {
851 $content = $editInfo->pstContent;
856 if ( !$content || $content->isRedirect() ) {
870 $hasLinks = (bool)count( $editInfo->output->getLinks() );
873 [
'pl_from' => $this->
getId() ], __METHOD__ );
877 return $content->isCountable( $hasLinks );
888 if ( !$this->mTitle->isRedirect() ) {
892 if ( $this->mRedirectTarget !==
null ) {
898 $row =
$dbr->selectRow(
'redirect',
899 [
'rd_namespace',
'rd_title',
'rd_fragment',
'rd_interwiki' ],
900 [
'rd_from' => $this->
getId() ],
905 if ( $row && !is_null( $row->rd_fragment ) && !is_null( $row->rd_interwiki ) ) {
907 $row->rd_namespace, $row->rd_title,
908 $row->rd_fragment, $row->rd_interwiki
928 $retval = $content ? $content->getUltimateRedirectTarget() :
null;
953 $dbw->startAtomic( __METHOD__ );
959 'rd_from' => $this->
getId(),
976 $dbw->endAtomic( __METHOD__ );
1000 if ( $rt->isExternal() ) {
1001 if ( $rt->isLocal() ) {
1005 $source = $this->mTitle->getFullURL(
'redirect=no' );
1006 return $rt->getFullURL( [
'rdfrom' =>
$source ] );
1014 if ( $rt->isSpecialPage() ) {
1018 if ( $rt->isValidRedirectTarget() ) {
1019 return $rt->getFullURL();
1039 $actorQuery = $actorMigration->getJoin(
'rev_user' );
1041 $tables = array_merge( [
'revision' ], $actorQuery[
'tables'], [
'user' ] );
1044 'user_id' => $actorQuery[
'fields'][
'rev_user'],
1045 'user_name' => $actorQuery[
'fields'][
'rev_user_text'],
1046 'actor_id' => $actorQuery[
'fields'][
'rev_actor'],
1047 'user_real_name' =>
'MIN(user_real_name)',
1048 'timestamp' =>
'MAX(rev_timestamp)',
1051 $conds = [
'rev_page' => $this->
getId() ];
1058 $conds[] =
'NOT(' . $actorMigration->getWhere(
$dbr,
'rev_user',
$user )[
'conds'] .
')';
1061 $conds[] =
"{$dbr->bitAnd( 'rev_deleted', Revision::DELETED_USER )} = 0";
1064 'user' => [
'LEFT JOIN', $actorQuery[
'fields'][
'rev_user'] .
' = user_id' ],
1065 ] + $actorQuery[
'joins'];
1068 'GROUP BY' => [ $fields[
'user_id'], $fields[
'user_name'] ],
1069 'ORDER BY' =>
'timestamp DESC',
1086 && ( $oldId ===
null || $oldId === 0 || $oldId === $this->
getLatest() )
1104 ParserOptions $parserOptions, $oldid =
null, $forceParse =
false
1109 if ( $useParserCache && !$parserOptions->
isSafeToCache() ) {
1110 throw new InvalidArgumentException(
1111 'The supplied ParserOptions are not safe to cache. Fix the options or set $forceParse = true.'
1116 ': using parser cache: ' . ( $useParserCache ?
'yes' :
'no' ) .
"\n" );
1121 if ( $useParserCache ) {
1122 $parserOutput = MediaWikiServices::getInstance()->getParserCache()
1123 ->get( $this, $parserOptions );
1124 if ( $parserOutput !==
false ) {
1125 return $parserOutput;
1129 if ( $oldid ===
null || $oldid === 0 ) {
1136 return $pool->getParserOutput();
1152 function ()
use (
$user, $oldid ) {
1155 $user->clearNotification( $this->mTitle, $oldid );
1171 if ( !
Hooks::run(
'ArticlePurge', [ &$wikiPage ] ) ) {
1175 $this->mTitle->invalidateCache();
1187 $messageCache->updateMessageOverride( $this->mTitle, $this->
getContent() );
1208 $pageIdForInsert = $pageId ? [
'page_id' => $pageId ] : [];
1212 'page_namespace' => $this->mTitle->getNamespace(),
1213 'page_title' => $this->mTitle->getDBkey(),
1214 'page_restrictions' =>
'',
1215 'page_is_redirect' => 0,
1218 'page_touched' => $dbw->timestamp(),
1221 ] + $pageIdForInsert,
1226 if ( $dbw->affectedRows() > 0 ) {
1227 $newid = $pageId ? (int)$pageId : $dbw->insertId();
1228 $this->mId = $newid;
1229 $this->mTitle->resetArticleID( $newid );
1251 $lastRevIsRedirect =
null
1256 if ( (
int)$revision->getId() === 0 ) {
1257 throw new InvalidArgumentException(
1258 __METHOD__ .
': Revision has ID ' . var_export( $revision->getId(), 1 )
1262 $content = $revision->getContent();
1263 $len = $content ? $content->getSize() : 0;
1264 $rt = $content ? $content->getUltimateRedirectTarget() :
null;
1266 $conditions = [
'page_id' => $this->
getId() ];
1268 if ( !is_null( $lastRevision ) ) {
1270 $conditions[
'page_latest'] = $lastRevision;
1273 $revId = $revision->getId();
1274 Assert::parameter( $revId > 0,
'$revision->getId()',
'must be > 0' );
1277 'page_latest' => $revId,
1278 'page_touched' => $dbw->timestamp( $revision->getTimestamp() ),
1279 'page_is_new' => ( $lastRevision === 0 ) ? 1 : 0,
1280 'page_is_redirect' => $rt !==
null ? 1 : 0,
1285 $row[
'page_content_model'] = $revision->getContentModel();
1288 $dbw->update(
'page',
1293 $result = $dbw->affectedRows() > 0;
1297 $this->mLatest = $revision->getId();
1298 $this->mIsRedirect = (bool)$rt;
1306 $revision->getContentModel()
1328 $isRedirect = !is_null( $redirectTitle );
1330 if ( !$isRedirect && $lastRevIsRedirect ===
false ) {
1334 if ( $isRedirect ) {
1338 $where = [
'rd_from' => $this->
getId() ];
1339 $dbw->delete(
'redirect', $where, __METHOD__ );
1346 return ( $dbw->affectedRows() != 0 );
1360 $row = $dbw->selectRow(
1361 [
'revision',
'page' ],
1362 [
'rev_id',
'rev_timestamp',
'page_is_redirect' ],
1364 'page_id' => $this->
getId(),
1365 'page_latest=rev_id' ],
1369 if (
wfTimestamp( TS_MW, $row->rev_timestamp ) >= $revision->getTimestamp() ) {
1372 $prev = $row->rev_id;
1373 $lastRevIsRedirect = (bool)$row->page_is_redirect;
1377 $lastRevIsRedirect =
null;
1429 $sectionId,
Content $sectionContent, $sectionTitle =
'', $edittime =
null
1432 if ( $edittime && $sectionId !==
'new' ) {
1433 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
1440 && $lb->getServerCount() > 1
1441 && $lb->hasOrMadeRecentMasterChanges()
1447 $baseRevId =
$rev->getId();
1451 return $this->
replaceSectionAtRev( $sectionId, $sectionContent, $sectionTitle, $baseRevId );
1468 $sectionTitle =
'', $baseRevId =
null
1470 if ( strval( $sectionId ) ===
'' ) {
1472 $newContent = $sectionContent;
1475 throw new MWException(
"sections not supported for content model " .
1480 if ( is_null( $baseRevId ) || $sectionId ===
'new' ) {
1485 wfDebug( __METHOD__ .
" asked for bogus section (page: " .
1486 $this->
getId() .
"; section: $sectionId)\n" );
1490 $oldContent =
$rev->getContent();
1493 if ( !$oldContent ) {
1494 wfDebug( __METHOD__ .
": no page text\n" );
1498 $newContent = $oldContent->replaceSection( $sectionId, $sectionContent, $sectionTitle );
1580 Content $content, $summary, $flags = 0, $baseRevId =
false,
1581 User $user =
null, $serialFormat =
null, $tags = [], $undidRevId = 0
1586 if ( $tags ===
null ) {
1591 if ( $this->mTitle->getText() ===
'' ) {
1592 throw new MWException(
'Something is trying to edit an article with an empty title' );
1598 $this->mTitle->getPrefixedText()
1615 $hook_args = [ &$wikiPage, &
$user, &$content, &$summary,
1616 $flags &
EDIT_MINOR,
null,
null, &$flags, &$hookStatus ];
1618 if ( !
Hooks::run(
'PageContentSave', $hook_args ) ) {
1619 if ( $hookStatus->isOK() ) {
1621 $hookStatus->fatal(
'edit-hook-aborted' );
1631 $tag =
$handler->getChangeTag( $old_content, $content, $flags );
1639 $tags[] =
'mw-undo';
1644 $summary =
$handler->getAutosummary( $old_content, $content, $flags );
1656 $pstContent = $editInfo->pstContent;
1659 'minor' => ( $flags &
EDIT_MINOR ) &&
$user->isAllowed(
'minoredit' ),
1660 'serialized' => $pstContent->serialize( $serialFormat ),
1661 'serialFormat' => $serialFormat,
1662 'baseRevId' => $baseRevId,
1663 'oldRevision' => $old_revision,
1664 'oldContent' => $old_content,
1668 'tags' => ( $tags !== null ) ? (
array)$tags : [],
1669 'undidRevId' => $undidRevId
1681 $user->addAutopromoteOnceGroups(
'onEdit' );
1682 $user->addAutopromoteOnceGroups(
'onView' );
1710 $oldid = $meta[
'oldId'];
1712 $oldContent = $meta[
'oldContent'];
1713 $newsize = $content->
getSize();
1717 $status->fatal(
'edit-gone-missing' );
1720 } elseif ( !$oldContent ) {
1722 throw new MWException(
"Could not find text for current revision {$oldid}." );
1725 $changed = !$content->
equals( $oldContent );
1732 'page' => $this->
getId(),
1733 'title' => $this->mTitle,
1734 'comment' => $summary,
1735 'minor_edit' => $meta[
'minor'],
1736 'text' => $meta[
'serialized'],
1738 'parent_id' => $oldid,
1739 'user' =>
$user->getId(),
1740 'user_text' =>
$user->getName(),
1741 'timestamp' => $now,
1742 'content_model' => $content->
getModel(),
1743 'content_format' => $meta[
'serialFormat'],
1747 $status->merge( $prepStatus );
1752 $dbw->startAtomic( __METHOD__ );
1757 if ( $latestNow != $oldid ) {
1758 $dbw->endAtomic( __METHOD__ );
1760 $status->fatal(
'edit-conflict' );
1771 $revisionId = $revision->insertOn( $dbw );
1773 if ( !$this->
updateRevisionOn( $dbw, $revision,
null, $meta[
'oldIsRedirect'] ) ) {
1774 throw new MWException(
"Failed to update page row to use new revision." );
1777 $tags = $meta[
'tags'];
1779 [ $this, $revision, $meta[
'baseRevId'],
$user, &$tags ] );
1785 $this->mTitle->getUserPermissionsErrors(
'autopatrol',
$user ) );
1790 $revision->isMinor(),
1794 $this->getTimestamp(),
1797 $oldContent ? $oldContent->getSize() : 0,
1806 $user->incEditCount();
1808 $dbw->endAtomic( __METHOD__ );
1809 $this->mTimestamp = $now;
1815 $revision = $meta[
'oldRevision'];
1820 $status->value[
'revision'] = $revision;
1822 $status->warning(
'edit-no-change' );
1825 $this->mTitle->invalidateCache( $now );
1834 $revision, &
$user, $content, $summary, &$flags,
1842 'changed' => $changed,
1843 'oldcountable' => $meta[
'oldCountable'],
1844 'oldrevision' => $meta[
'oldRevision']
1851 null,
null, &$flags, $revision, &
$status, $meta[
'baseRevId'],
1852 $meta[
'undidRevId'] ];
1882 $newsize = $content->
getSize();
1883 $prepStatus = $content->
prepareSave( $this, $flags, $meta[
'oldId'],
$user );
1884 $status->merge( $prepStatus );
1890 $dbw->startAtomic( __METHOD__ );
1894 if ( $newid ===
false ) {
1895 $dbw->endAtomic( __METHOD__ );
1896 $status->fatal(
'edit-already-exists' );
1909 'title' => $this->mTitle,
1910 'comment' => $summary,
1911 'minor_edit' => $meta[
'minor'],
1912 'text' => $meta[
'serialized'],
1914 'user' =>
$user->getId(),
1915 'user_text' =>
$user->getName(),
1916 'timestamp' => $now,
1917 'content_model' => $content->
getModel(),
1918 'content_format' => $meta[
'serialFormat'],
1922 $revisionId = $revision->insertOn( $dbw );
1925 throw new MWException(
"Failed to update page row to use new revision." );
1928 Hooks::run(
'NewRevisionFromEditComplete', [ $this, $revision,
false,
$user ] );
1934 !count( $this->mTitle->getUserPermissionsErrors(
'autopatrol',
$user ) );
1939 $revision->isMinor(),
1951 $user->incEditCount();
1953 $dbw->endAtomic( __METHOD__ );
1954 $this->mTimestamp = $now;
1957 $status->value[
'revision'] = $revision;
1965 $revision, &
$user, $content, $summary, &$flags, $meta, &
$status
1973 $flags &
EDIT_MINOR,
null,
null, &$flags, $revision ];
2003 if ( $this->
getTitle()->isConversionTable() ) {
2006 $options->disableContentConversion();
2031 $serialFormat =
null, $useCache =
true
2035 if ( is_object( $revision ) ) {
2036 $revid = $revision->getId();
2041 if ( $revid !==
null ) {
2042 wfDeprecated( __METHOD__ .
' with $revision = revision ID',
'1.25' );
2053 if ( $serialFormat ===
null ) {
2057 if ( $this->mPreparedEdit
2058 && isset( $this->mPreparedEdit->newContent )
2059 && $this->mPreparedEdit->newContent->equals( $content )
2060 && $this->mPreparedEdit->revid == $revid
2061 && $this->mPreparedEdit->format == $serialFormat
2074 Hooks::run(
'ArticlePrepareTextForEdit', [ $this, $popts ] );
2077 if ( $cachedEdit ) {
2078 $edit->timestamp = $cachedEdit->timestamp;
2083 $edit->revid = $revid;
2085 if ( $cachedEdit ) {
2086 $edit->pstContent = $cachedEdit->pstContent;
2088 $edit->pstContent = $content
2093 $edit->format = $serialFormat;
2095 if ( $cachedEdit ) {
2096 $edit->output = $cachedEdit->output;
2103 $oldCallback = $edit->popts->getCurrentRevisionCallback();
2104 $edit->popts->setCurrentRevisionCallback(
2106 if (
$title->equals( $revision->getTitle() ) ) {
2109 return call_user_func( $oldCallback, $title, $parser );
2115 $dbIndex = ( $this->mDataLoadedFrom & self::READ_LATEST ) === self::READ_LATEST
2119 $edit->popts->setSpeculativeRevIdCallback(
function ()
use ( $dbIndex ) {
2120 return 1 + (int)
wfGetDB( $dbIndex )->selectField(
2128 $edit->output = $edit->pstContent
2129 ? $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts )
2133 $edit->newContent = $content;
2136 if ( $edit->output ) {
2141 $this->mPreparedEdit = $edit;
2174 'restored' =>
false,
2175 'oldrevision' =>
null,
2176 'oldcountable' => null
2180 $logger = LoggerFactory::getInstance(
'SaveParse' );
2184 if ( !$this->mPreparedEdit ) {
2185 $logger->debug( __METHOD__ .
": No prepared edit...\n" );
2186 } elseif ( $this->mPreparedEdit->output->getFlag(
'vary-revision' ) ) {
2187 $logger->info( __METHOD__ .
": Prepared edit has vary-revision...\n" );
2188 } elseif ( $this->mPreparedEdit->output->getFlag(
'vary-revision-id' )
2189 && $this->mPreparedEdit->output->getSpeculativeRevIdUsed() !== $revision->
getId()
2191 $logger->info( __METHOD__ .
": Prepared edit has vary-revision-id with wrong ID...\n" );
2192 } elseif ( $this->mPreparedEdit->output->getFlag(
'vary-user' ) && !
$options[
'changed'] ) {
2193 $logger->info( __METHOD__ .
": Prepared edit has vary-user and is null...\n" );
2195 wfDebug( __METHOD__ .
": Using prepared edit...\n" );
2208 MediaWikiServices::getInstance()->getParserCache()->save(
2209 $editInfo->output, $this, $editInfo->popts,
2216 $updates = $content->getSecondaryDataUpdates(
2217 $this->
getTitle(),
null, $recursive, $editInfo->output
2219 foreach ( $updates
as $update ) {
2220 $update->setCause(
'edit-page',
$user->getName() );
2222 $update->setRevision( $revision );
2223 $update->setTriggeringUser(
$user );
2238 'pageId' => $this->
getId(),
2250 if (
Hooks::run(
'ArticleEditUpdatesDeleteFromRecentchanges', [ &$wikiPage ] ) ) {
2252 if ( mt_rand( 0, 9 ) == 0 ) {
2257 if ( !$this->
exists() ) {
2261 $id = $this->
getId();
2262 $title = $this->mTitle->getPrefixedDBkey();
2263 $shortTitle = $this->mTitle->getDBkey();
2265 if (
$options[
'oldcountable'] ===
'no-change' ||
2271 } elseif (
$options[
'oldcountable'] !==
null ) {
2276 $edits =
$options[
'changed'] ? 1 : 0;
2277 $pages =
$options[
'created'] ? 1 : 0;
2280 [
'edits' => $edits,
'articles' => $good,
'pages' => $pages ]
2289 && $shortTitle !=
$user->getTitleKey()
2290 && !( $revision->
isMinor() &&
$user->isAllowed(
'nominornewtalk' ) )
2293 if ( !$recipient ) {
2294 wfDebug( __METHOD__ .
": invalid username\n" );
2301 if (
Hooks::run(
'ArticleEditUpdateNewTalk', [ &$wikiPage, $recipient ] ) ) {
2304 $recipient->setNewtalk(
true, $revision );
2305 } elseif ( $recipient->isLoggedIn() ) {
2306 $recipient->setNewtalk(
true, $revision );
2308 wfDebug( __METHOD__ .
": don't need to notify a nonexistent user\n" );
2344 &$cascade, $reason,
User $user, $tags =
null
2353 $restrictionTypes = $this->mTitle->getRestrictionTypes();
2354 $id = $this->
getId();
2365 $isProtected =
false;
2371 foreach ( $restrictionTypes
as $action ) {
2372 if ( !isset( $expiry[$action] ) || $expiry[$action] === $dbw->getInfinity() ) {
2373 $expiry[$action] =
'infinity';
2375 if ( !isset( $limit[$action] ) ) {
2376 $limit[$action] =
'';
2377 } elseif ( $limit[$action] !=
'' ) {
2382 $current = implode(
'', $this->mTitle->getRestrictions( $action ) );
2383 if ( $current !=
'' ) {
2384 $isProtected =
true;
2387 if ( $limit[$action] != $current ) {
2389 } elseif ( $limit[$action] !=
'' ) {
2393 if ( $this->mTitle->getRestrictionExpiry( $action ) != $expiry[$action] ) {
2399 if ( !$changed && $protect && $this->mTitle->areRestrictionsCascading() != $cascade ) {
2409 $revCommentMsg =
'unprotectedarticle-comment';
2410 $logAction =
'unprotect';
2411 } elseif ( $isProtected ) {
2412 $revCommentMsg =
'modifiedarticleprotection-comment';
2413 $logAction =
'modify';
2415 $revCommentMsg =
'protectedarticle-comment';
2416 $logAction =
'protect';
2419 $logRelationsValues = [];
2420 $logRelationsField =
null;
2421 $logParamsDetails = [];
2424 $nullRevision =
null;
2430 if ( !
Hooks::run(
'ArticleProtect', [ &$wikiPage, &
$user, $limit, $reason ] ) ) {
2435 $editrestriction = isset( $limit[
'edit'] )
2436 ? [ $limit[
'edit'] ]
2437 : $this->mTitle->getRestrictions(
'edit' );
2438 foreach ( array_keys( $editrestriction,
'sysop' )
as $key ) {
2439 $editrestriction[$key] =
'editprotected';
2441 foreach ( array_keys( $editrestriction,
'autoconfirmed' )
as $key ) {
2442 $editrestriction[$key] =
'editsemiprotected';
2446 foreach ( array_keys( $cascadingRestrictionLevels,
'sysop' )
as $key ) {
2447 $cascadingRestrictionLevels[$key] =
'editprotected';
2449 foreach ( array_keys( $cascadingRestrictionLevels,
'autoconfirmed' )
as $key ) {
2450 $cascadingRestrictionLevels[$key] =
'editsemiprotected';
2454 if ( !array_intersect( $editrestriction, $cascadingRestrictionLevels ) ) {
2469 if ( $nullRevision ===
null ) {
2470 return Status::newFatal(
'no-null-revision', $this->mTitle->getPrefixedText() );
2473 $logRelationsField =
'pr_id';
2476 foreach ( $limit
as $action => $restrictions ) {
2478 'page_restrictions',
2481 'pr_type' => $action
2485 if ( $restrictions !=
'' ) {
2486 $cascadeValue = ( $cascade && $action ==
'edit' ) ? 1 : 0;
2488 'page_restrictions',
2491 'pr_type' => $action,
2492 'pr_level' => $restrictions,
2493 'pr_cascade' => $cascadeValue,
2494 'pr_expiry' => $dbw->encodeExpiry( $expiry[$action] )
2498 $logRelationsValues[] = $dbw->insertId();
2499 $logParamsDetails[] = [
2501 'level' => $restrictions,
2502 'expiry' => $expiry[$action],
2503 'cascade' => (bool)$cascadeValue,
2511 [
'page_restrictions' =>
'' ],
2512 [
'page_id' => $id ],
2520 [ $this, $nullRevision, $latest,
$user ] );
2521 Hooks::run(
'ArticleProtectComplete', [ &$wikiPage, &
$user, $limit, $reason ] );
2526 if ( $limit[
'create'] !=
'' ) {
2528 $dbw->replace(
'protected_titles',
2529 [ [
'pt_namespace',
'pt_title' ] ],
2531 'pt_namespace' => $this->mTitle->getNamespace(),
2532 'pt_title' => $this->mTitle->getDBkey(),
2533 'pt_create_perm' => $limit[
'create'],
2534 'pt_timestamp' => $dbw->timestamp(),
2535 'pt_expiry' => $dbw->encodeExpiry( $expiry[
'create'] ),
2536 'pt_user' =>
$user->getId(),
2537 ] + $commentFields, __METHOD__
2539 $logParamsDetails[] = [
2541 'level' => $limit[
'create'],
2542 'expiry' => $expiry[
'create'],
2545 $dbw->delete(
'protected_titles',
2547 'pt_namespace' => $this->mTitle->getNamespace(),
2548 'pt_title' => $this->mTitle->getDBkey()
2554 $this->mTitle->flushRestrictions();
2557 if ( $logAction ==
'unprotect' ) {
2562 '4::description' => $protectDescriptionLog,
2563 '5:bool:cascade' => $cascade,
2564 'details' => $logParamsDetails,
2570 $logEntry->setTarget( $this->mTitle );
2571 $logEntry->setComment( $reason );
2572 $logEntry->setPerformer(
$user );
2573 $logEntry->setParameters(
$params );
2574 if ( !is_null( $nullRevision ) ) {
2575 $logEntry->setAssociatedRevId( $nullRevision->getId() );
2577 $logEntry->setTags( $tags );
2578 if ( $logRelationsField !==
null && count( $logRelationsValues ) ) {
2579 $logEntry->setRelations( [ $logRelationsField => $logRelationsValues ] );
2581 $logId = $logEntry->insert();
2582 $logEntry->publish( $logId );
2599 array $expiry, $cascade, $reason,
$user =
null
2606 $this->mTitle->getPrefixedText(),
2608 )->inContentLanguage()->text();
2610 $editComment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() . $reason;
2613 if ( $protectDescription ) {
2614 $editComment .=
wfMessage(
'word-separator' )->inContentLanguage()->text();
2615 $editComment .=
wfMessage(
'parentheses' )->params( $protectDescription )
2616 ->inContentLanguage()->text();
2619 $editComment .=
wfMessage(
'word-separator' )->inContentLanguage()->text();
2620 $editComment .=
wfMessage(
'brackets' )->params(
2621 wfMessage(
'protect-summary-cascade' )->inContentLanguage()->
text()
2622 )->inContentLanguage()->text();
2627 $nullRev->insertOn( $dbw );
2630 $oldLatest = $nullRev->getParentId();
2644 if ( $expiry !=
'infinity' ) {
2647 $wgContLang->timeanddate( $expiry,
false,
false ),
2650 )->inContentLanguage()->text();
2652 return wfMessage(
'protect-expiry-indefinite' )
2653 ->inContentLanguage()->text();
2665 $protectDescription =
'';
2667 foreach ( array_filter( $limit )
as $action => $restrictions ) {
2668 # $action is one of $wgRestrictionTypes = [ 'create', 'edit', 'move', 'upload' ].
2669 # All possible message keys are listed here for easier grepping:
2670 # * restriction-create
2671 # * restriction-edit
2672 # * restriction-move
2673 # * restriction-upload
2674 $actionText =
wfMessage(
'restriction-' . $action )->inContentLanguage()->text();
2675 # $restrictions is one of $wgRestrictionLevels = [ '', 'autoconfirmed', 'sysop' ],
2676 # with '' filtered out. All possible message keys are listed below:
2677 # * protect-level-autoconfirmed
2678 # * protect-level-sysop
2679 $restrictionsText =
wfMessage(
'protect-level-' . $restrictions )
2680 ->inContentLanguage()->text();
2684 if ( $protectDescription !==
'' ) {
2685 $protectDescription .=
wfMessage(
'word-separator' )->inContentLanguage()->text();
2687 $protectDescription .=
wfMessage(
'protect-summary-desc' )
2688 ->params( $actionText, $restrictionsText, $expiryText )
2689 ->inContentLanguage()->text();
2692 return $protectDescription;
2709 $protectDescriptionLog =
'';
2711 foreach ( array_filter( $limit )
as $action => $restrictions ) {
2713 $protectDescriptionLog .=
$wgContLang->getDirMark() .
2714 "[$action=$restrictions] ($expiryText)";
2717 return trim( $protectDescriptionLog );
2730 if ( !is_array( $limit ) ) {
2731 throw new MWException( __METHOD__ .
' given non-array restriction set' );
2737 foreach ( array_filter( $limit )
as $action => $restrictions ) {
2738 $bits[] =
"$action=$restrictions";
2741 return implode(
':', $bits );
2761 $reason, $suppress =
false, $u1 =
null, $u2 =
null, &$error =
'',
User $user =
null
2787 $reason, $suppress =
false, $u1 =
null, $u2 =
null, &$error =
'',
User $deleter =
null,
2788 $tags = [], $logsubtype =
'delete'
2797 if ( $this->mTitle->getDBkey() ===
'' ) {
2798 $status->error(
'cannotdelete',
2806 $deleter = is_null( $deleter ) ?
$wgUser : $deleter;
2808 [ &$wikiPage, &$deleter, &$reason, &$error, &
$status, $suppress ]
2812 $status->fatal(
'delete-hook-aborted' );
2818 $dbw->startAtomic( __METHOD__ );
2821 $id = $this->
getId();
2827 if ( $id == 0 || $this->
getLatest() != $lockedLatest ) {
2828 $dbw->endAtomic( __METHOD__ );
2830 $status->error(
'cannotdelete',
2836 $namespace = $this->
getTitle()->getNamespace();
2837 $dbKey = $this->
getTitle()->getDBkey();
2848 }
catch ( Exception $ex ) {
2849 wfLogWarning( __METHOD__ .
': failed to load content during deletion! '
2850 . $ex->getMessage() );
2878 $res = $dbw->select(
2881 [
'revision',
'revision_comment_temp',
'revision_actor_temp' ]
2884 [
'rev_page' => $id ],
2889 foreach (
$res as $row ) {
2894 $res = $dbw->select(
2897 [
'rev_page' => $id ],
2910 foreach (
$res as $row ) {
2911 $comment = $commentStore->getComment(
'rev_comment', $row );
2914 'ar_namespace' => $namespace,
2915 'ar_title' => $dbKey,
2916 'ar_timestamp' => $row->rev_timestamp,
2917 'ar_minor_edit' => $row->rev_minor_edit,
2918 'ar_rev_id' => $row->rev_id,
2919 'ar_parent_id' => $row->rev_parent_id,
2920 'ar_text_id' => $row->rev_text_id,
2921 'ar_len' => $row->rev_len,
2922 'ar_page_id' => $id,
2923 'ar_deleted' => $suppress ? $bitfield : $row->rev_deleted,
2924 'ar_sha1' => $row->rev_sha1,
2925 ] + $commentStore->insert( $dbw,
'ar_comment', $comment )
2926 + $actorMigration->getInsertValues( $dbw,
'ar_user',
$user );
2928 $rowInsert[
'ar_content_model'] = $row->rev_content_model;
2929 $rowInsert[
'ar_content_format'] = $row->rev_content_format;
2931 $rowsInsert[] = $rowInsert;
2932 $revids[] = $row->rev_id;
2936 if ( (
int)$row->rev_user === 0 &&
IP::isValid( $row->rev_user_text ) ) {
2937 $ipRevIds[] = $row->rev_id;
2941 $dbw->insert(
'archive', $rowsInsert, __METHOD__ );
2943 $archivedRevisionCount = $dbw->affectedRows();
2948 $wikiPageBeforeDelete = clone $this;
2951 $dbw->delete(
'page', [
'page_id' => $id ], __METHOD__ );
2952 $dbw->delete(
'revision', [
'rev_page' => $id ], __METHOD__ );
2954 $dbw->delete(
'revision_comment_temp', [
'revcomment_rev' => $revids ], __METHOD__ );
2957 $dbw->delete(
'revision_actor_temp', [
'revactor_rev' => $revids ], __METHOD__ );
2961 if ( count( $ipRevIds ) > 0 ) {
2962 $dbw->delete(
'ip_changes', [
'ipc_rev_id' => $ipRevIds ], __METHOD__ );
2966 $logtype = $suppress ?
'suppress' :
'delete';
2969 $logEntry->setPerformer( $deleter );
2970 $logEntry->setTarget( $logTitle );
2971 $logEntry->setComment( $reason );
2972 $logEntry->setTags( $tags );
2973 $logid = $logEntry->insert();
2975 $dbw->onTransactionPreCommitOrIdle(
2976 function ()
use ( $dbw, $logEntry, $logid ) {
2978 $logEntry->publish( $logid );
2983 $dbw->endAtomic( __METHOD__ );
2988 &$wikiPageBeforeDelete,
2994 $archivedRevisionCount
2999 $cache = MediaWikiServices::getInstance()->getMainObjectStash();
3000 $key =
$cache->makeKey(
'page-recent-delete', md5( $logTitle->getPrefixedText() ) );
3001 $cache->set( $key, 1, $cache::TTL_DAY );
3017 'page_id' => $this->
getId(),
3020 'page_namespace' => $this->
getTitle()->getNamespace(),
3021 'page_title' => $this->
getTitle()->getDBkey()
3043 }
catch ( Exception $ex ) {
3051 [
'edits' => 1,
'articles' => -$countable,
'pages' => -1 ]
3056 foreach ( $updates
as $update ) {
3060 $causeAgent =
$user ?
$user->getName() :
'unknown';
3063 $this->mTitle,
'templatelinks',
'delete-page', $causeAgent );
3065 if ( $this->mTitle->getNamespace() ==
NS_FILE ) {
3067 $this->mTitle,
'imagelinks',
'delete-page', $causeAgent );
3073 $this->mTitle, $revision,
null,
wfWikiID()
3113 $fromP, $summary, $token, $bot, &$resultDetails,
User $user, $tags =
null
3115 $resultDetails =
null;
3118 $editErrors = $this->mTitle->getUserPermissionsErrors(
'edit',
$user );
3119 $rollbackErrors = $this->mTitle->getUserPermissionsErrors(
'rollback',
$user );
3120 $errors = array_merge( $editErrors,
wfArrayDiff2( $rollbackErrors, $editErrors ) );
3122 if ( !
$user->matchEditToken( $token,
'rollback' ) ) {
3123 $errors[] = [
'sessionfailure' ];
3126 if (
$user->pingLimiter(
'rollback' ) ||
$user->pingLimiter() ) {
3127 $errors[] = [
'actionthrottledtext' ];
3131 if ( !empty( $errors ) ) {
3159 &$resultDetails,
User $guser, $tags =
null
3166 return [ [
'readonlytext' ] ];
3171 if ( is_null( $current ) ) {
3173 return [ [
'notanarticle' ] ];
3176 $from = str_replace(
'_',
' ', $fromP );
3179 if ( $from != $current->getUserText() ) {
3180 $resultDetails = [
'current' => $current ];
3181 return [ [
'alreadyrolled',
3182 htmlspecialchars( $this->mTitle->getPrefixedText() ),
3183 htmlspecialchars( $fromP ),
3184 htmlspecialchars( $current->getUserText() )
3194 $user->setName( $userName );
3201 $s = $dbw->selectRow(
3202 [
'revision' ] + $actorWhere[
'tables'],
3203 [
'rev_id',
'rev_timestamp',
'rev_deleted' ],
3205 'rev_page' => $current->getPage(),
3206 'NOT(' . $actorWhere[
'conds'] .
')',
3210 'USE INDEX' => [
'revision' =>
'page_timestamp' ],
3211 'ORDER BY' =>
'rev_timestamp DESC'
3213 $actorWhere[
'joins']
3215 if (
$s ===
false ) {
3217 return [ [
'cantrollback' ] ];
3222 return [ [
'notvisiblerev' ] ];
3227 if ( empty( $summary ) ) {
3228 if ( $from ==
'' ) {
3229 $summary =
wfMessage(
'revertpage-nouser' );
3237 $target->getUserText(), $from,
$s->rev_id,
3239 $current->getId(),
$wgContLang->timeanddate( $current->getTimestamp() )
3241 if ( $summary instanceof
Message ) {
3242 $summary = $summary->params(
$args )->inContentLanguage()->text();
3248 $summary = trim( $summary );
3253 if ( $guser->
isAllowed(
'minoredit' ) ) {
3257 if ( $bot && ( $guser->
isAllowedAny(
'markbotedits',
'bot' ) ) ) {
3261 $targetContent = $target->getContent();
3262 $changingContentModel = $targetContent->getModel() !== $current->getContentModel();
3265 $tags[] =
'mw-rollback';
3282 if ( $bot && $guser->
isAllowed(
'markbotedits' ) ) {
3292 if ( count( $set ) ) {
3294 $dbw->update(
'recentchanges', $set,
3296 'rc_cur_id' => $current->getPage(),
3297 'rc_timestamp > ' . $dbw->addQuotes(
$s->rev_timestamp ),
3298 $actorWhere[
'conds'],
3305 return $status->getErrorsArray();
3309 $statusRev = isset(
$status->value[
'revision'] )
3312 if ( !( $statusRev instanceof
Revision ) ) {
3313 $resultDetails = [
'current' => $current ];
3314 return [ [
'alreadyrolled',
3315 htmlspecialchars( $this->mTitle->getPrefixedText() ),
3316 htmlspecialchars( $fromP ),
3317 htmlspecialchars( $current->getUserText() )
3321 if ( $changingContentModel ) {
3325 $log->setPerformer( $guser );
3326 $log->setTarget( $this->mTitle );
3327 $log->setComment( $summary );
3328 $log->setParameters( [
3329 '4::oldmodel' => $current->getContentModel(),
3330 '5::newmodel' => $targetContent->getModel(),
3333 $logId = $log->insert( $dbw );
3334 $log->publish( $logId );
3337 $revId = $statusRev->getId();
3339 Hooks::run(
'ArticleRollbackComplete', [ $this, $guser, $target, $current ] );
3342 'summary' => $summary,
3343 'current' => $current,
3344 'target' => $target,
3365 $other =
$title->getOtherPage();
3367 $other->purgeSquid();
3371 $title->deleteTitleProtection();
3373 MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle(
$title );
3398 $other =
$title->getOtherPage();
3400 $other->purgeSquid();
3405 MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle(
$title );
3427 $user->setNewtalk(
false );
3452 MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle(
$title );
3459 $revid = $revision ? $revision->getId() :
null;
3474 $id = $this->
getId();
3480 $res =
$dbr->select(
'categorylinks',
3481 [
'cl_to AS page_title, ' .
NS_CATEGORY .
' AS page_namespace' ],
3484 [
'cl_from' => $id ],
3498 $id = $this->
getId();
3505 $res =
$dbr->select( [
'categorylinks',
'page_props',
'page' ],
3507 [
'cl_from' => $id,
'pp_page=page_id',
'pp_propname' =>
'hiddencat',
3508 'page_namespace' =>
NS_CATEGORY,
'page_title=cl_to' ],
3511 if (
$res !==
false ) {
3512 foreach (
$res as $row ) {
3542 $id = $id ?: $this->
getId();
3543 $ns = $this->
getTitle()->getNamespace();
3545 $addFields = [
'cat_pages = cat_pages + 1' ];
3546 $removeFields = [
'cat_pages = cat_pages - 1' ];
3548 $addFields[] =
'cat_subcats = cat_subcats + 1';
3549 $removeFields[] =
'cat_subcats = cat_subcats - 1';
3551 $addFields[] =
'cat_files = cat_files + 1';
3552 $removeFields[] =
'cat_files = cat_files - 1';
3557 if ( count( $added ) ) {
3558 $existingAdded = $dbw->selectFieldValues(
3561 [
'cat_title' => $added ],
3568 if ( count( $existingAdded ) ) {
3572 [
'cat_title' => $existingAdded ],
3577 $missingAdded = array_diff( $added, $existingAdded );
3578 if ( count( $missingAdded ) ) {
3580 foreach ( $missingAdded
as $cat ) {
3582 'cat_title' => $cat,
3585 'cat_files' => ( $ns ==
NS_FILE ) ? 1 : 0,
3598 if ( count( $deleted ) ) {
3602 [
'cat_title' => $deleted ],
3607 foreach ( $added
as $catName ) {
3609 Hooks::run(
'CategoryAfterPageAdded', [ $cat, $this ] );
3612 foreach ( $deleted
as $catName ) {
3614 Hooks::run(
'CategoryAfterPageRemoved', [ $cat, $this, $id ] );
3620 if ( count( $deleted ) ) {
3621 $rows = $dbw->select(
3623 [
'cat_id',
'cat_title',
'cat_pages',
'cat_subcats',
'cat_files' ],
3624 [
'cat_title' => $deleted,
'cat_pages <= 0' ],
3631 $cat->refreshCounts();
3648 if ( !
Hooks::run(
'OpportunisticLinksUpdate',
3649 [ $this, $this->mTitle, $parserOutput ]
3657 'isOpportunistic' =>
true,
3661 if ( $this->mTitle->areRestrictionsCascading() ) {
3666 } elseif ( !$config->get(
'MiserMode' ) && $parserOutput->
hasDynamicContent() ) {
3677 $key =
$cache->makeKey(
'dynamic-linksupdate',
'last', $this->
getId() );
3679 if (
$cache->add( $key, time(), $ttl ) ) {
3703 }
catch ( Exception $ex ) {
3714 $updates = $content->getDeletionUpdates( $this );
3717 Hooks::run(
'WikiPageDeletionUpdates', [ $this, $content, &$updates ] );
3755 return $this->
getTitle()->getCanonicalURL();
3764 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
3766 return $linkCache->getMutableCacheKeys(
$cache, $this->
getTitle()->getTitleValue() );
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.
int $wgActorTableSchemaMigrationStage
Actor table schema migration stage.
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.
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 newMigration()
Static constructor.
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()
static get(Title $title)
Create a new BacklinkCache or reuse any existing one.
getCacheExpiry()
Returns the number of seconds after which this object should expire.
Job to add recent change entries mentioning category membership changes.
static newFromName( $name)
Factory function.
static newFromTitle( $title)
Factory function.
static newFromRow( $row, $title=null)
Factory function, for constructing a Category object from a result set.
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 getDBOptions( $bitfield)
Get an appropriate DB index, options, and fallback DB index for a query.
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
static addCallableUpdate( $callable, $stage=self::POSTSEND, $dbw=null)
Add a callable update.
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 run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static isValid( $ip)
Validate an IP address.
static invalidateCache(Title $title, $revid=null)
Clear the info cache for a given Title.
static singleton( $domain=false)
static singleton()
Get an instance of this class.
Class the manages updates of *_link tables as well as similar extension-managed tables.
static queueRecursiveJobsForTable(Title $title, $table, $action='unknown', $userName='unknown')
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:
static getMainWANInstance()
Get the main WAN cache object.
static getLocalClusterInstance()
Get the main cluster-local cache object.
Set options of the Parser.
getStubThreshold()
Thumb size preferred by the user.
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
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()
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...
getContentHandler()
Returns the content handler appropriate for this revision's content model.
static newKnownCurrent(IDatabase $db, $pageIdOrTitle, $revId=0)
Load a revision based on a known page ID and current revision ID from the DB.
static newFromPageId( $pageId, $revId=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given page ID.
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 getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Database independant search index updater.
static factory(array $deltas)
static newFatal( $message)
Factory function for fatal errors.
static newGood( $value=null)
Factory function for good results.
static newFromResult( $res)
Represents a title within MediaWiki.
getNamespace()
Get the namespace index, i.e.
getFragment()
Get the Title fragment (i.e.
static purgeExpiredRestrictions()
Purge expired restrictions from the page_restrictions table.
getDBkey()
Get the main part with underscores.
const GAID_FOR_UPDATE
Used to be GAID_FOR_UPDATE define.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
getInterwiki()
Get the interwiki prefix.
static newFromRow( $row)
Make a Title object from a DB row.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
isAllowed( $action='')
Internal mechanics of testing a permission.
static newFromAnyId( $userId, $userName, $actorId)
Static factory method for creation from an ID, name, and/or actor ID.
static newFromId( $id)
Static factory method for creation from a given user ID.
static isIP( $name)
Does the string match an anonymous IP address?
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.
doDeleteArticleReal( $reason, $suppress=false, $u1=null, $u2=null, &$error='', User $deleter=null, $tags=[], $logsubtype='delete')
Back-end article deletion Deletes the article with database consistency, writes logs,...
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.
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.
doDeleteUpdates( $id, Content $content=null, Revision $revision=null, User $user=null)
Do some database updates after deletion.
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)
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.
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new page object.
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.
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.
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.
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 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 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
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
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
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
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
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 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
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
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)
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method. MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances. The "Spi" in MediaWiki\Logger\Spi stands for "service provider interface". An SPI is an API intended to be implemented or extended by a third party. This software design pattern is intended to enable framework extension and replaceable components. It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki. The service provider interface allows the backend logging library to be implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime. This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance. Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory