103 throw new MWException(
"NS_MEDIA is a virtual namespace; use NS_FILE." );
104 } elseif ( $ns < 0 ) {
105 throw new MWException(
"Invalid or virtual namespace $ns given." );
140 $row = $db->selectRow(
141 'page', self::selectFields(), [
'page_id' => $id ], __METHOD__ );
145 return self::newFromRow( $row,
$from );
174 return self::READ_NORMAL;
176 return self::READ_LATEST;
178 return self::READ_LOCKING;
197 return $content_handler->getActionOverrides();
226 $this->mDataLoaded =
false;
227 $this->mDataLoadedFrom = self::READ_NONE;
238 $this->mRedirectTarget = null;
239 $this->mLastRevision = null;
240 $this->mTouched =
'19700101000000';
241 $this->mLinksUpdated =
'19700101000000';
242 $this->mTimestamp =
'';
243 $this->mIsRedirect =
false;
244 $this->mLatest =
false;
257 $this->mPreparedEdit =
false;
267 global $wgContentHandlerUseDB, $wgPageLanguageUseDB;
278 'page_links_updated',
283 if ( $wgContentHandlerUseDB ) {
284 $fields[] =
'page_content_model';
287 if ( $wgPageLanguageUseDB ) {
288 $fields[] =
'page_lang';
302 $fields = self::selectFields();
304 Hooks::run(
'ArticlePageDataBefore', [ &$this, &$fields ] );
306 $row =
$dbr->selectRow(
'page', $fields, $conditions, __METHOD__,
$options );
308 Hooks::run(
'ArticlePageDataAfter', [ &$this, &$row ] );
324 'page_namespace' =>
$title->getNamespace(),
354 if ( is_int(
$from ) && $from <= $this->mDataLoadedFrom ) {
359 if ( is_int(
$from ) ) {
365 &&
wfGetLB()->getServerCount() > 1
366 &&
wfGetLB()->hasOrMadeRecentMasterChanges()
368 $from = self::READ_LATEST;
375 $from = self::READ_NORMAL;
394 $lc->clearLink( $this->mTitle );
397 $lc->addGoodLinkObjFromRow( $this->mTitle, $data );
399 $this->mTitle->loadFromRow( $data );
402 $this->mTitle->loadRestrictions( $data->page_restrictions );
404 $this->mId = intval( $data->page_id );
407 $this->mIsRedirect = intval( $data->page_is_redirect );
408 $this->mLatest = intval( $data->page_latest );
411 if ( $this->mLastRevision && $this->mLastRevision->getId() !=
$this->mLatest ) {
412 $this->mLastRevision = null;
413 $this->mTimestamp =
'';
416 $lc->addBadLinkObj( $this->mTitle );
418 $this->mTitle->loadFromRow(
false );
425 $this->mDataLoaded =
true;
426 $this->mDataLoadedFrom = self::convertSelectType(
$from );
433 if ( !$this->mDataLoaded ) {
443 if ( !$this->mDataLoaded ) {
446 return $this->mId > 0;
458 return $this->
exists() || $this->mTitle->isAlwaysKnown();
467 if ( !$this->mDataLoaded ) {
489 if (
$rev !== null ) {
490 return $rev->getContentModel();
492 $title = $this->mTitle->getPrefixedDBkey();
493 wfWarn(
"Page $title exists but has no (visible) revisions!" );
498 return $this->mTitle->getContentModel();
506 if ( !$this->mDataLoaded ) {
517 if ( !$this->mDataLoaded ) {
528 if ( !$this->mDataLoaded ) {
539 if ( !$this->mDataLoaded ) {
557 while ( $continue ) {
558 $row = $db->selectRow(
559 [
'page',
'revision' ],
562 'page_namespace' => $this->mTitle->getNamespace(),
563 'page_title' => $this->mTitle->getDBkey(),
568 'ORDER BY' =>
'rev_timestamp ASC'
588 if ( $this->mLastRevision !== null ) {
597 if ( $this->mDataLoadedFrom == self::READ_LOCKING ) {
606 } elseif ( $this->mDataLoadedFrom == self::READ_LATEST ) {
625 $this->mLastRevision = $revision;
635 if ( $this->mLastRevision ) {
656 if ( $this->mLastRevision ) {
657 return $this->mLastRevision->getContent( $audience,
$user );
678 if ( $this->mLastRevision ) {
679 return $this->mLastRevision->getText( $audience,
$user );
689 if ( !$this->mTimestamp ) {
716 if ( $this->mLastRevision ) {
717 return $this->mLastRevision->getUser( $audience,
$user );
736 $userName = $revision->getUserText( $audience,
$user );
754 if ( $this->mLastRevision ) {
755 return $this->mLastRevision->getUserText( $audience,
$user );
772 if ( $this->mLastRevision ) {
773 return $this->mLastRevision->getComment( $audience,
$user );
786 if ( $this->mLastRevision ) {
787 return $this->mLastRevision->isMinor();
802 global $wgArticleCountMethod;
804 if ( !$this->mTitle->isContentPage() ) {
820 if ( $wgArticleCountMethod ===
'link' ) {
828 $hasLinks = (bool)count( $editInfo->output->getLinks() );
831 [
'pl_from' => $this->
getId() ], __METHOD__ );
835 return $content->isCountable( $hasLinks );
846 if ( !$this->mTitle->isRedirect() ) {
850 if ( $this->mRedirectTarget !== null ) {
856 $row =
$dbr->selectRow(
'redirect',
857 [
'rd_namespace',
'rd_title',
'rd_fragment',
'rd_interwiki' ],
858 [
'rd_from' => $this->
getId() ],
863 if ( $row && !is_null( $row->rd_fragment ) && !is_null( $row->rd_interwiki ) ) {
865 $row->rd_namespace, $row->rd_title,
866 $row->rd_fragment, $row->rd_interwiki
895 $that->insertRedirectEntry(
$retval, $latest );
908 $dbw->startAtomic( __METHOD__ );
911 $dbw->replace(
'redirect',
914 '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() )
1059 ': using parser cache: ' . ( $useParserCache ?
'yes' :
'no' ) .
"\n" );
1064 if ( $useParserCache ) {
1071 if ( $oldid === null || $oldid === 0 ) {
1078 return $pool->getParserOutput();
1091 Hooks::run(
'PageViewUpdates', [ $this, $user ] );
1106 if ( !
Hooks::run(
'ArticlePurge', [ &$this ] ) ) {
1113 $title->invalidateCache();
1131 if ( $text === null ) {
1157 $pageIdForInsert = $pageId ?: $dbw->nextSequenceValue(
'page_page_id_seq' );
1161 'page_id' => $pageIdForInsert,
1162 'page_namespace' => $this->mTitle->getNamespace(),
1163 'page_title' => $this->mTitle->getDBkey(),
1164 'page_restrictions' =>
'',
1165 'page_is_redirect' => 0,
1168 'page_touched' => $dbw->timestamp(),
1176 if ( $dbw->affectedRows() > 0 ) {
1177 $newid = $pageId ?: $dbw->insertId();
1178 $this->mId = $newid;
1179 $this->mTitle->resetArticleID( $newid );
1201 $lastRevIsRedirect = null
1203 global $wgContentHandlerUseDB;
1206 if ( (
int)$revision->getId() === 0 ) {
1208 __METHOD__ .
': Revision has ID ' . var_export( $revision->getId(), 1 )
1212 $content = $revision->getContent();
1216 $conditions = [
'page_id' => $this->
getId() ];
1218 if ( !is_null( $lastRevision ) ) {
1220 $conditions[
'page_latest'] = $lastRevision;
1224 'page_latest' => $revision->getId(),
1225 'page_touched' => $dbw->timestamp( $revision->getTimestamp() ),
1226 'page_is_new' => ( $lastRevision === 0 ) ? 1 : 0,
1227 'page_is_redirect' => $rt !== null ? 1 : 0,
1231 if ( $wgContentHandlerUseDB ) {
1232 $row[
'page_content_model'] = $revision->getContentModel();
1235 $dbw->update(
'page',
1240 $result = $dbw->affectedRows() > 0;
1244 $this->mLatest = $revision->getId();
1245 $this->mIsRedirect = (bool)$rt;
1253 $revision->getContentModel()
1275 $isRedirect = !is_null( $redirectTitle );
1277 if ( !$isRedirect && $lastRevIsRedirect ===
false ) {
1281 if ( $isRedirect ) {
1285 $where = [
'rd_from' => $this->
getId() ];
1286 $dbw->delete(
'redirect', $where, __METHOD__ );
1293 return ( $dbw->affectedRows() != 0 );
1308 $row = $dbw->selectRow(
1309 [
'revision',
'page' ],
1310 [
'rev_id',
'rev_timestamp',
'page_is_redirect' ],
1312 'page_id' => $this->
getId(),
1313 'page_latest=rev_id' ],
1317 if (
wfTimestamp(
TS_MW, $row->rev_timestamp ) >= $revision->getTimestamp() ) {
1320 $prev = $row->rev_id;
1321 $lastRevIsRedirect = (bool)$row->page_is_redirect;
1325 $lastRevIsRedirect = null;
1381 if ( $edittime && $sectionId !==
'new' ) {
1388 &&
wfGetLB()->getServerCount() > 1
1389 &&
wfGetLB()->hasOrMadeRecentMasterChanges()
1395 $baseRevId =
$rev->getId();
1399 return $this->
replaceSectionAtRev( $sectionId, $sectionContent, $sectionTitle, $baseRevId );
1416 $sectionTitle =
'', $baseRevId = null
1419 if ( strval( $sectionId ) ===
'' ) {
1424 throw new MWException(
"sections not supported for content model " .
1429 if ( is_null( $baseRevId ) || $sectionId ===
'new' ) {
1434 wfDebug( __METHOD__ .
" asked for bogus section (page: " .
1435 $this->
getId() .
"; section: $sectionId)\n" );
1439 $oldContent =
$rev->getContent();
1442 if ( !$oldContent ) {
1443 wfDebug( __METHOD__ .
": no page text\n" );
1447 $newContent = $oldContent->replaceSection( $sectionId, $sectionContent, $sectionTitle );
1587 User $user = null, $serialFormat = null, $tags = null
1592 if ( $this->mTitle->getText() ===
'' ) {
1593 throw new MWException(
'Something is trying to edit an article with an empty title' );
1599 $this->mTitle->getPrefixedText()
1616 if ( !
Hooks::run(
'PageContentSave', $hook_args )
1619 if ( $hookStatus->isOK() ) {
1621 $hookStatus->fatal(
'edit-hook-aborted' );
1631 if ( $wgUseAutomaticEditSummaries && ( $flags &
EDIT_AUTOSUMMARY ) && $summary ==
'' ) {
1632 $handler = $content->getContentHandler();
1633 $summary =
$handler->getAutosummary( $old_content, $content, $flags );
1638 $pstContent = $editInfo->pstContent;
1641 'minor' => ( $flags & EDIT_MINOR ) && $user->isAllowed(
'minoredit' ),
1642 'serialized' => $editInfo->pst,
1643 'serialFormat' => $serialFormat,
1644 'baseRevId' => $baseRevId,
1645 'oldRevision' => $old_revision,
1646 'oldContent' => $old_content,
1650 'tags' => ( $tags !== null ) ? (
array)$tags : []
1655 $status = $this->
doModify( $pstContent, $flags, $user, $summary, $meta );
1657 $status = $this->
doCreate( $pstContent, $flags, $user, $summary, $meta );
1662 $user->addAutopromoteOnceGroups(
'onEdit' );
1663 $user->addAutopromoteOnceGroups(
'onView' );
1691 $oldid = $meta[
'oldId'];
1693 $oldContent = $meta[
'oldContent'];
1694 $newsize = $content->
getSize();
1698 $status->fatal(
'edit-gone-missing' );
1701 } elseif ( !$oldContent ) {
1703 throw new MWException(
"Could not find text for current revision {$oldid}." );
1708 'page' => $this->
getId(),
1709 'title' => $this->mTitle,
1711 'minor_edit' => $meta[
'minor'],
1712 'text' => $meta[
'serialized'],
1714 'parent_id' => $oldid,
1715 'user' => $user->
getId(),
1716 'user_text' => $user->
getName(),
1717 'timestamp' => $now,
1718 'content_model' => $content->
getModel(),
1719 'content_format' => $meta[
'serialFormat'],
1722 $changed = !$content->
equals( $oldContent );
1728 $status->merge( $prepStatus );
1733 $dbw->startAtomic( __METHOD__ );
1738 if ( $latestNow != $oldid ) {
1739 $dbw->endAtomic( __METHOD__ );
1741 $status->fatal(
'edit-conflict' );
1752 $revisionId = $revision->insertOn( $dbw );
1754 if ( !$this->
updateRevisionOn( $dbw, $revision, null, $meta[
'oldIsRedirect'] ) ) {
1755 $dbw->rollback( __METHOD__ );
1756 throw new MWException(
"Failed to update page row to use new revision." );
1760 [ $this, $revision, $meta[
'baseRevId'], $user ] );
1765 $patrolled = $wgUseRCPatrol && !count(
1766 $this->mTitle->getUserPermissionsErrors(
'autopatrol', $user ) );
1771 $revision->isMinor(),
1778 $oldContent ? $oldContent->getSize() : 0,
1788 $dbw->endAtomic( __METHOD__ );
1789 $this->mTimestamp = $now;
1798 $status->value[
'revision'] = $revision;
1800 $status->warning(
'edit-no-change' );
1803 $this->mTitle->invalidateCache( $now );
1808 $dbw->onTransactionIdle(
1816 $that->doEditUpdates(
1820 'changed' => $changed,
1821 'oldcountable' => $meta[
'oldCountable'],
1822 'oldrevision' => $meta[
'oldRevision']
1827 null, null, &
$flags, $revision, &
$status, $meta[
'baseRevId'] ];
1851 global $wgUseRCPatrol, $wgUseNPPatrol;
1856 $newsize = $content->
getSize();
1858 $status->merge( $prepStatus );
1864 $dbw->startAtomic( __METHOD__ );
1868 if ( $newid ===
false ) {
1869 $dbw->endAtomic( __METHOD__ );
1870 $status->fatal(
'edit-already-exists' );
1883 'title' => $this->mTitle,
1885 'minor_edit' => $meta[
'minor'],
1886 'text' => $meta[
'serialized'],
1888 'user' => $user->
getId(),
1889 'user_text' => $user->
getName(),
1890 'timestamp' => $now,
1891 'content_model' => $content->
getModel(),
1892 'content_format' => $meta[
'serialFormat'],
1896 $revisionId = $revision->
insertOn( $dbw );
1899 $dbw->rollback( __METHOD__ );
1900 throw new MWException(
"Failed to update page row to use new revision." );
1903 Hooks::run(
'NewRevisionFromEditComplete', [ $this, $revision,
false, $user ] );
1908 $patrolled = ( $wgUseRCPatrol || $wgUseNPPatrol ) &&
1909 !count( $this->mTitle->getUserPermissionsErrors(
'autopatrol', $user ) );
1914 $revision->isMinor(),
1928 $dbw->endAtomic( __METHOD__ );
1929 $this->mTimestamp = $now;
1932 $status->value[
'revision'] = $revision;
1936 $dbw->onTransactionIdle(
1943 $that->doEditUpdates( $revision, $user, [
'created' =>
true ] );
1977 if ( $this->
getTitle()->isConversionTable() ) {
1980 $options->disableContentConversion();
2019 $serialFormat = null, $useCache =
true
2023 if ( is_object( $revision ) ) {
2024 $revid = $revision->getId();
2029 if ( $revid !== null ) {
2040 if ( $serialFormat === null ) {
2044 if ( $this->mPreparedEdit
2045 && $this->mPreparedEdit->newContent
2046 && $this->mPreparedEdit->newContent->equals( $content )
2047 && $this->mPreparedEdit->revid == $revid
2048 && $this->mPreparedEdit->format == $serialFormat
2056 $cachedEdit = $useCache && $wgAjaxEditStash
2061 Hooks::run(
'ArticlePrepareTextForEdit', [ $this, $popts ] );
2064 if ( $cachedEdit ) {
2065 $edit->timestamp = $cachedEdit->timestamp;
2070 $edit->revid = $revid;
2072 if ( $cachedEdit ) {
2073 $edit->pstContent = $cachedEdit->pstContent;
2075 $edit->pstContent = $content
2080 $edit->format = $serialFormat;
2082 if ( $cachedEdit ) {
2083 $edit->output = $cachedEdit->output;
2090 $oldCallback = $edit->popts->getCurrentRevisionCallback();
2091 $edit->popts->setCurrentRevisionCallback(
2093 if ( $title->
equals( $revision->getTitle() ) ) {
2096 return call_user_func( $oldCallback, $title,
$parser );
2101 $edit->output = $edit->pstContent
2102 ? $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts )
2110 $edit->newText = $edit->newContent
2113 $edit->oldText = $edit->oldContent
2116 $edit->pst = $edit->pstContent ? $edit->pstContent->serialize( $serialFormat ) :
'';
2118 if ( $edit->output ) {
2123 $this->mPreparedEdit = $edit;
2156 'restored' =>
false,
2157 'oldrevision' => null,
2158 'oldcountable' => null
2165 if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag(
'vary-revision' ) ) {
2166 wfDebug( __METHOD__ .
": No prepared edit or vary-revision is set...\n" );
2169 wfDebug( __METHOD__ .
": No vary-revision, using prepared edit...\n" );
2176 $editInfo->output, $this, $editInfo->popts,
2183 $updates =
$content->getSecondaryDataUpdates(
2184 $this->
getTitle(), null, $recursive, $editInfo->output
2186 foreach ( $updates
as $update ) {
2188 $update->setRevision( $revision );
2189 $update->setTriggeringUser( $user );
2193 if ( $wgRCWatchCategoryMembership
2204 'pageId' => $this->
getId(),
2213 if (
Hooks::run(
'ArticleEditUpdatesDeleteFromRecentchanges', [ &$this ] ) ) {
2215 if ( mt_rand( 0, 9 ) == 0 ) {
2220 if ( !$this->
exists() ) {
2224 $id = $this->
getId();
2225 $title = $this->mTitle->getPrefixedDBkey();
2226 $shortTitle = $this->mTitle->getDBkey();
2228 if (
$options[
'oldcountable'] ===
'no-change' ||
2234 } elseif (
$options[
'oldcountable'] !== null ) {
2239 $edits =
$options[
'changed'] ? 1 : 0;
2240 $total =
$options[
'created'] ? 1 : 0;
2254 if ( !$recipient ) {
2255 wfDebug( __METHOD__ .
": invalid username\n" );
2259 if (
Hooks::run(
'ArticleEditUpdateNewTalk', [ &$this, $recipient ] ) ) {
2262 $recipient->setNewtalk(
true, $revision );
2263 } elseif ( $recipient->isLoggedIn() ) {
2264 $recipient->setNewtalk(
true, $revision );
2266 wfDebug( __METHOD__ .
": don't need to notify a nonexistent user\n" );
2275 if ( $msgtext ===
false || $msgtext === null ) {
2281 if ( $wgContLang->hasVariants() ) {
2282 $wgContLang->updateConversionTable( $this->mTitle );
2287 self::onArticleCreate( $this->mTitle );
2289 self::onArticleEdit( $this->mTitle, $revision );
2313 'page' => $this->
getId(),
2314 'user_text' => $user->
getName(),
2315 'user' => $user->
getId(),
2317 'length' => $content->
getSize(),
2319 'minor_edit' => $minor ? 1 : 0,
2324 Hooks::run(
'NewRevisionFromEditComplete', [ $this, $revision,
false, $user ] );
2343 &$cascade, $reason,
User $user, $tags = null
2352 $restrictionTypes = $this->mTitle->getRestrictionTypes();
2353 $id = $this->
getId();
2364 $isProtected =
false;
2370 foreach ( $restrictionTypes
as $action ) {
2371 if ( !isset( $expiry[$action] ) || $expiry[$action] === $dbw->getInfinity() ) {
2372 $expiry[$action] =
'infinity';
2374 if ( !isset( $limit[$action] ) ) {
2375 $limit[$action] =
'';
2376 } elseif ( $limit[$action] !=
'' ) {
2381 $current = implode(
'', $this->mTitle->getRestrictions( $action ) );
2382 if ( $current !=
'' ) {
2383 $isProtected =
true;
2386 if ( $limit[$action] != $current ) {
2388 } elseif ( $limit[$action] !=
'' ) {
2392 if ( $this->mTitle->getRestrictionExpiry( $action ) != $expiry[$action] ) {
2398 if ( !$changed && $protect && $this->mTitle->areRestrictionsCascading() != $cascade ) {
2408 $revCommentMsg =
'unprotectedarticle';
2409 $logAction =
'unprotect';
2410 } elseif ( $isProtected ) {
2411 $revCommentMsg =
'modifiedarticleprotection';
2412 $logAction =
'modify';
2414 $revCommentMsg =
'protectedarticle';
2415 $logAction =
'protect';
2419 $reason = $wgContLang->truncate( $reason, 255 );
2421 $logRelationsValues = [];
2422 $logRelationsField = null;
2423 $logParamsDetails = [];
2426 $nullRevision = null;
2429 if ( !
Hooks::run(
'ArticleProtect', [ &$this, &$user, $limit, $reason ] ) ) {
2434 $editrestriction = isset( $limit[
'edit'] )
2435 ? [ $limit[
'edit'] ]
2436 : $this->mTitle->getRestrictions(
'edit' );
2437 foreach ( array_keys( $editrestriction,
'sysop' )
as $key ) {
2438 $editrestriction[
$key] =
'editprotected';
2440 foreach ( array_keys( $editrestriction,
'autoconfirmed' )
as $key ) {
2441 $editrestriction[
$key] =
'editsemiprotected';
2444 $cascadingRestrictionLevels = $wgCascadingRestrictionLevels;
2445 foreach ( array_keys( $cascadingRestrictionLevels,
'sysop' )
as $key ) {
2446 $cascadingRestrictionLevels[
$key] =
'editprotected';
2448 foreach ( array_keys( $cascadingRestrictionLevels,
'autoconfirmed' )
as $key ) {
2449 $cascadingRestrictionLevels[
$key] =
'editsemiprotected';
2453 if ( !array_intersect( $editrestriction, $cascadingRestrictionLevels ) ) {
2468 if ( $nullRevision === null ) {
2469 return Status::newFatal(
'no-null-revision', $this->mTitle->getPrefixedText() );
2472 $logRelationsField =
'pr_id';
2475 foreach ( $limit
as $action => $restrictions ) {
2477 'page_restrictions',
2480 'pr_type' => $action
2484 if ( $restrictions !=
'' ) {
2485 $cascadeValue = ( $cascade && $action ==
'edit' ) ? 1 : 0;
2487 'page_restrictions',
2489 'pr_id' => $dbw->nextSequenceValue(
'page_restrictions_pr_id_seq' ),
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 ],
2517 [ $this, $nullRevision, $latest, $user ] );
2518 Hooks::run(
'ArticleProtectComplete', [ &$this, &$user, $limit, $reason ] );
2523 if ( $limit[
'create'] !=
'' ) {
2524 $dbw->replace(
'protected_titles',
2525 [ [
'pt_namespace',
'pt_title' ] ],
2527 'pt_namespace' => $this->mTitle->getNamespace(),
2528 'pt_title' => $this->mTitle->getDBkey(),
2529 'pt_create_perm' => $limit[
'create'],
2530 'pt_timestamp' => $dbw->timestamp(),
2531 'pt_expiry' => $dbw->encodeExpiry( $expiry[
'create'] ),
2532 'pt_user' => $user->
getId(),
2533 'pt_reason' => $reason,
2536 $logParamsDetails[] = [
2538 'level' => $limit[
'create'],
2539 'expiry' => $expiry[
'create'],
2542 $dbw->delete(
'protected_titles',
2544 'pt_namespace' => $this->mTitle->getNamespace(),
2545 'pt_title' => $this->mTitle->getDBkey()
2551 $this->mTitle->flushRestrictions();
2554 if ( $logAction ==
'unprotect' ) {
2559 '4::description' => $protectDescriptionLog,
2560 '5:bool:cascade' => $cascade,
2561 'details' => $logParamsDetails,
2567 $logEntry->setTarget( $this->mTitle );
2568 $logEntry->setComment( $reason );
2569 $logEntry->setPerformer( $user );
2570 $logEntry->setParameters(
$params );
2571 if ( !is_null( $nullRevision ) ) {
2572 $logEntry->setAssociatedRevId( $nullRevision->getId() );
2574 $logEntry->setTags( $tags );
2575 if ( $logRelationsField !== null && count( $logRelationsValues ) ) {
2576 $logEntry->setRelations( [ $logRelationsField => $logRelationsValues ] );
2578 $logId = $logEntry->insert();
2579 $logEntry->publish( $logId );
2596 array $expiry, $cascade, $reason,
$user = null
2602 $editComment = $wgContLang->ucfirst(
2605 $this->mTitle->getPrefixedText()
2606 )->inContentLanguage()->text()
2609 $editComment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() . $reason;
2612 if ( $protectDescription ) {
2613 $editComment .=
wfMessage(
'word-separator' )->inContentLanguage()->text();
2614 $editComment .=
wfMessage(
'parentheses' )->params( $protectDescription )
2615 ->inContentLanguage()->text();
2618 $editComment .=
wfMessage(
'word-separator' )->inContentLanguage()->text();
2619 $editComment .=
wfMessage(
'brackets' )->params(
2620 wfMessage(
'protect-summary-cascade' )->inContentLanguage()->
text()
2621 )->inContentLanguage()->text();
2626 $nullRev->insertOn( $dbw );
2629 $oldLatest = $nullRev->getParentId();
2643 if ( $expiry !=
'infinity' ) {
2646 $wgContLang->timeanddate( $expiry,
false,
false ),
2647 $wgContLang->date( $expiry,
false,
false ),
2648 $wgContLang->time( $expiry,
false,
false )
2649 )->inContentLanguage()->text();
2651 return wfMessage(
'protect-expiry-indefinite' )
2652 ->inContentLanguage()->text();
2664 $protectDescription =
'';
2666 foreach ( array_filter( $limit )
as $action => $restrictions ) {
2667 # $action is one of $wgRestrictionTypes = array( 'create', 'edit', 'move', 'upload' ).
2668 # All possible message keys are listed here for easier grepping:
2669 # * restriction-create
2670 # * restriction-edit
2671 # * restriction-move
2672 # * restriction-upload
2673 $actionText =
wfMessage(
'restriction-' . $action )->inContentLanguage()->text();
2674 # $restrictions is one of $wgRestrictionLevels = array( '', 'autoconfirmed', 'sysop' ),
2675 # with '' filtered out. All possible message keys are listed below:
2676 # * protect-level-autoconfirmed
2677 # * protect-level-sysop
2678 $restrictionsText =
wfMessage(
'protect-level-' . $restrictions )
2679 ->inContentLanguage()->text();
2683 if ( $protectDescription !==
'' ) {
2684 $protectDescription .=
wfMessage(
'word-separator' )->inContentLanguage()->text();
2686 $protectDescription .=
wfMessage(
'protect-summary-desc' )
2687 ->params( $actionText, $restrictionsText, $expiryText )
2688 ->inContentLanguage()->text();
2691 return $protectDescription;
2708 $protectDescriptionLog =
'';
2710 foreach ( array_filter( $limit )
as $action => $restrictions ) {
2712 $protectDescriptionLog .= $wgContLang->getDirMark() .
2713 "[$action=$restrictions] ($expiryText)";
2716 return trim( $protectDescriptionLog );
2729 if ( !is_array(
$limit ) ) {
2730 throw new MWException( __METHOD__ .
' given non-array restriction set' );
2736 foreach ( array_filter(
$limit )
as $action => $restrictions ) {
2737 $bits[] =
"$action=$restrictions";
2740 return implode(
':', $bits );
2760 $reason, $suppress =
false, $u1 = null, $u2 = null, &$error =
'',
User $user = null
2784 $reason, $suppress =
false, $u1 = null, $u2 = null, &$error =
'',
User $user = null
2792 if ( $this->mTitle->getDBkey() ===
'' ) {
2793 $status->error(
'cannotdelete',
2800 [ &$this, &
$user, &$reason, &$error, &
$status, $suppress ]
2804 $status->fatal(
'delete-hook-aborted' );
2810 $dbw->startAtomic( __METHOD__ );
2813 $id = $this->
getId();
2819 if ( $id == 0 || $this->
getLatest() != $lockedLatest ) {
2820 $dbw->endAtomic( __METHOD__ );
2822 $status->error(
'cannotdelete',
2844 $bitfield =
'rev_deleted';
2861 'ar_namespace' =>
'page_namespace',
2862 'ar_title' =>
'page_title',
2863 'ar_comment' =>
'rev_comment',
2864 'ar_user' =>
'rev_user',
2865 'ar_user_text' =>
'rev_user_text',
2866 'ar_timestamp' =>
'rev_timestamp',
2867 'ar_minor_edit' =>
'rev_minor_edit',
2868 'ar_rev_id' =>
'rev_id',
2869 'ar_parent_id' =>
'rev_parent_id',
2870 'ar_text_id' =>
'rev_text_id',
2871 'ar_text' =>
'\'\
'',
2872 'ar_flags' =>
'\'\
'',
2873 'ar_len' =>
'rev_len',
2874 'ar_page_id' =>
'page_id',
2875 'ar_deleted' => $bitfield,
2876 'ar_sha1' =>
'rev_sha1',
2879 if ( $wgContentHandlerUseDB ) {
2880 $row[
'ar_content_model'] =
'rev_content_model';
2881 $row[
'ar_content_format'] =
'rev_content_format';
2887 [
'page',
'revision' ],
2891 'page_id = rev_page'
2897 $dbw->delete(
'page', [
'page_id' => $id ], __METHOD__ );
2899 if ( !$dbw->cascadingDeletes() ) {
2900 $dbw->delete(
'revision', [
'rev_page' => $id ], __METHOD__ );
2907 $logtype = $suppress ?
'suppress' :
'delete';
2910 $logEntry->setPerformer(
$user );
2911 $logEntry->setTarget( $logTitle );
2912 $logEntry->setComment( $reason );
2913 $logid = $logEntry->insert();
2915 $dbw->onTransactionPreCommitOrIdle(
function ()
use ( $dbw, $logEntry, $logid ) {
2917 $logEntry->publish( $logid );
2920 $dbw->endAtomic( __METHOD__ );
2930 $key =
wfMemcKey(
'page-recent-delete', md5( $logTitle->getPrefixedText() ) );
2947 'page_id' => $this->
getId(),
2950 'page_namespace' => $this->
getTitle()->getNamespace(),
2951 'page_title' => $this->
getTitle()->getDBkey()
2972 foreach ( $updates
as $update ) {
2980 if ( $this->mTitle->getNamespace() ==
NS_FILE ) {
3025 $resultDetails = null;
3028 $editErrors = $this->mTitle->getUserPermissionsErrors(
'edit', $user );
3029 $rollbackErrors = $this->mTitle->getUserPermissionsErrors(
'rollback', $user );
3030 $errors = array_merge( $editErrors,
wfArrayDiff2( $rollbackErrors, $editErrors ) );
3032 if ( !$user->
matchEditToken( $token, [ $this->mTitle->getPrefixedText(), $fromP ] ) ) {
3033 $errors[] = [
'sessionfailure' ];
3037 $errors[] = [
'actionthrottledtext' ];
3041 if ( !empty( $errors ) ) {
3069 &$resultDetails,
User $guser, $tags = null
3076 return [ [
'readonlytext' ] ];
3081 if ( is_null( $current ) ) {
3083 return [ [
'notanarticle' ] ];
3086 $from = str_replace(
'_',
' ', $fromP );
3089 if (
$from != $current->getUserText() ) {
3090 $resultDetails = [
'current' => $current ];
3091 return [ [
'alreadyrolled',
3092 htmlspecialchars( $this->mTitle->getPrefixedText() ),
3093 htmlspecialchars( $fromP ),
3094 htmlspecialchars( $current->getUserText() )
3101 $user_text = $dbw->addQuotes( $current->getUserText(
Revision::RAW ) );
3102 $s = $dbw->selectRow(
'revision',
3103 [
'rev_id',
'rev_timestamp',
'rev_deleted' ],
3104 [
'rev_page' => $current->getPage(),
3105 "rev_user != {$user} OR rev_user_text != {$user_text}"
3107 [
'USE INDEX' =>
'page_timestamp',
3108 'ORDER BY' =>
'rev_timestamp DESC' ]
3110 if (
$s ===
false ) {
3112 return [ [
'cantrollback' ] ];
3117 return [ [
'notvisiblerev' ] ];
3123 if (
$from ==
'' ) {
3132 $target->getUserText(),
$from,
$s->rev_id,
3134 $current->getId(), $wgContLang->timeanddate( $current->getTimestamp() )
3151 if ( $guser->
isAllowed(
'minoredit' ) ) {
3155 if ( $bot && ( $guser->
isAllowedAny(
'markbotedits',
'bot' ) ) ) {
3161 $target->getContent(),
3173 if ( $bot && $guser->
isAllowed(
'markbotedits' ) ) {
3178 if ( $wgUseRCPatrol ) {
3180 $set[
'rc_patrolled'] = 1;
3183 if ( count( $set ) ) {
3184 $dbw->update(
'recentchanges', $set,
3186 'rc_cur_id' => $current->getPage(),
3187 'rc_user_text' => $current->getUserText(),
3188 'rc_timestamp > ' . $dbw->addQuotes(
$s->rev_timestamp ),
3195 return $status->getErrorsArray();
3199 $statusRev = isset(
$status->value[
'revision'] )
3202 if ( !( $statusRev instanceof
Revision ) ) {
3203 $resultDetails = [
'current' => $current ];
3204 return [ [
'alreadyrolled',
3205 htmlspecialchars( $this->mTitle->getPrefixedText() ),
3206 htmlspecialchars( $fromP ),
3207 htmlspecialchars( $current->getUserText() )
3211 $revId = $statusRev->getId();
3213 Hooks::run(
'ArticleRollbackComplete', [ $this, $guser, $target, $current ] );
3217 'current' => $current,
3218 'target' => $target,
3240 $other->purgeSquid();
3258 $other->purgeSquid();
3271 if ( $wgContLang->hasVariants() ) {
3272 $wgContLang->updateConversionTable( $title );
3285 $user->setNewtalk(
false );
3311 $revid = $revision ? $revision->getId() : null;
3326 $id = $this->
getId();
3332 $res =
$dbr->select(
'categorylinks',
3333 [
'cl_to AS page_title, ' .
NS_CATEGORY .
' AS page_namespace' ],
3336 [
'cl_from' => $id ],
3350 $id = $this->
getId();
3357 $res =
$dbr->select( [
'categorylinks',
'page_props',
'page' ],
3359 [
'cl_from' => $id,
'pp_page=page_id',
'pp_propname' =>
'hiddencat',
3360 'page_namespace' =>
NS_CATEGORY,
'page_title=cl_to' ],
3363 if (
$res !==
false ) {
3364 foreach (
$res as $row ) {
3388 $oldContent = is_null( $oldtext ) ? null :
$handler->unserializeContent( $oldtext );
3389 $newContent = is_null( $newtext ) ? null :
$handler->unserializeContent( $newtext );
3391 return $handler->getAutosummary( $oldContent, $newContent,
$flags );
3414 $method = __METHOD__;
3418 $dbw->onTransactionPreCommitOrIdle(
3419 function ()
use ( $dbw, $that, $method, $added, $deleted ) {
3420 $ns = $that->getTitle()->getNamespace();
3422 $addFields = [
'cat_pages = cat_pages + 1' ];
3423 $removeFields = [
'cat_pages = cat_pages - 1' ];
3425 $addFields[] =
'cat_subcats = cat_subcats + 1';
3426 $removeFields[] =
'cat_subcats = cat_subcats - 1';
3428 $addFields[] =
'cat_files = cat_files + 1';
3429 $removeFields[] =
'cat_files = cat_files - 1';
3432 if ( count( $added ) ) {
3433 $existingAdded = $dbw->selectFieldValues(
3436 [
'cat_title' => $added ],
3443 if ( count( $existingAdded ) ) {
3447 [
'cat_title' => $existingAdded ],
3452 $missingAdded = array_diff( $added, $existingAdded );
3453 if ( count( $missingAdded ) ) {
3455 foreach ( $missingAdded
as $cat ) {
3457 'cat_title' => $cat,
3460 'cat_files' => ( $ns ==
NS_FILE ) ? 1 : 0,
3473 if ( count( $deleted ) ) {
3477 [
'cat_title' => $deleted ],
3482 foreach ( $added
as $catName ) {
3484 Hooks::run(
'CategoryAfterPageAdded', [ $cat, $that ] );
3487 foreach ( $deleted
as $catName ) {
3489 Hooks::run(
'CategoryAfterPageRemoved', [ $cat, $that ] );
3506 if ( !
Hooks::run(
'OpportunisticLinksUpdate',
3507 [ $this, $this->mTitle, $parserOutput ]
3515 'isOpportunistic' =>
true,
3519 if ( $this->mTitle->areRestrictionsCascading() ) {
3524 } elseif ( !$config->get(
'MiserMode' ) && $parserOutput->
hasDynamicContent() ) {
3535 $key =
$cache->makeKey(
'dynamic-linksupdate',
'last', $this->
getId() );
3565 $updates =
$content->getDeletionUpdates( $this );
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
getLinksTimestamp()
Get the page_links_updated field.
isCountable($editInfo=false)
Determine whether a page would be suitable for being counted as an article in the site_stats table ba...
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
static newFromRow($row)
Make a Title object from a DB row.
static purgeExpiredRestrictions()
Purge expired restrictions from the page_restrictions table.
setLastEdit(Revision $revision)
Set the latest revision.
makeParserOptions($context)
Get parser options suitable for rendering the primary article wikitext.
static onArticleCreate(Title $title)
The onArticle*() functions are supposed to be a kind of hooks which should be called whenever any of ...
getUndoContent(Revision $undo, Revision $undoafter=null)
Get the content that needs to be saved in order to undo all revisions between $undo and $undoafter...
touchLinks()
Update page_touched timestamps and send CDN purge messages for pages linking to this title...
getFragment()
Get the Title fragment (i.e.
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
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
Database error base class.
static newFromName($name)
Factory function.
the array() calling protocol came about after MediaWiki 1.4rc1.
replaceSectionContent($sectionId, Content $sectionContent, $sectionTitle= '', $edittime=null)
const CONTENT_MODEL_WIKITEXT
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
getLatest()
Get the page_latest field.
stdClass $mPreparedEdit
Map of cache fields (text, parser output, ect) for a proposed/new edit.
getContentHandler()
Convenience method that returns the ContentHandler singleton for handling the content model that this...
serialize($format=null)
Convenience method for serializing this Content object.
getUser($audience=Revision::FOR_PUBLIC, User $user=null)
getParserOutput(ParserOptions $parserOptions, $oldid=null)
Get a ParserOutput for the given ParserOptions and revision ID.
getText()
Get the text form (spaces not underscores) of the main part.
clearNotification(&$title, $oldid=0)
Clear the user's notification timestamp for the given title.
doEditContent(Content $content, $summary, $flags=0, $baseRevId=false, User $user=null, $serialFormat=null, $tags=null)
Change an existing article or create a new article.
static checkCache(Title $title, Content $content, User $user)
Check that a prepared edit is in cache and still up-to-date.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
int $mDataLoadedFrom
One of the READ_* constants.
isAllowedAny()
Check if user is allowed to access a feature / make an action.
static getForModelID($modelId)
Returns the ContentHandler singleton for the given model ID.
protectDescription(array $limit, array $expiry)
Builds the description to serve as comment for the edit.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
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
Set options of the Parser.
insertRedirect()
Insert an entry for this page into the redirect table if the content is a redirect.
pingLimiter($action= 'edit', $incrBy=1)
Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.
updateCategoryCounts(array $added, array $deleted)
Update all the appropriate counts in the category table, given that we've added the categories $added...
processing should stop and the error should be shown to the user * false
updateRevisionOn($dbw, $revision, $lastRevision=null, $lastRevIsRedirect=null)
Update the page record to point to a newly saved revision.
Handles purging appropriate CDN URLs given a title (or titles)
triggerOpportunisticLinksUpdate(ParserOutput $parserOutput)
Opportunistically enqueue link update jobs given fresh parser output if useful.
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
getMinorEdit()
Returns true if last revision was marked as "minor edit".
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context $revId
getOtherPage()
Get the other title for this page, if this is a subject page get the talk page, if it is a subject pa...
static getLocalClusterInstance()
Get the main cluster-local cache object.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
getContributors()
Get a list of users who have edited this article, not including the user who made the most recent rev...
checkFlags($flags)
Check flags and add EDIT_NEW or EDIT_UPDATE to them as needed.
static getMainStashInstance()
Get the cache object for the main stash.
doQuickEditContent(Content $content, User $user, $comment= '', $minor=false, $serialFormat=null)
Edit an article without doing all that other stuff The article must already exist; link tables etc ar...
insertProtectNullRevision($revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user=null)
Insert a new null revision for this page.
Represents a title within MediaWiki.
static newFromPageId($pageId, $revId=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given page ID...
when a variable name is used in a it is silently declared as a new local masking the global
getTouched()
Get the page_touched field.
static newFatal($message)
Factory function for fatal errors.
matchEditToken($val, $salt= '', $request=null, $maxage=null)
Check given value against the token value stored in the session.
getDeletionUpdates(Content $content=null)
Returns a list of updates to be performed when this page is deleted.
string $mTimestamp
Timestamp of the current revision or empty string if not loaded.
clearCacheFields()
Clear the object cache fields.
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
loadLastEdit()
Loads everything except the text This isn't necessary for all uses, so it's only done if needed...
getName()
Get the user name, or the IP of an anonymous user.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
pageDataFromTitle($dbr, $title, $options=[])
Fetch a page record matching the Title object's namespace and title using a sanitized title string...
getActionOverrides()
Returns overrides for action handlers.
isRedirect()
Tests if the article content represents a redirect.
static queueRecursiveJobsForTable(Title $title, $table)
Queue a RefreshLinks job for any table.
wfArrayDiff2($a, $b)
Like array_diff( $a, $b ) except that it works with two-dimensional arrays.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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:Associative array mapping language codes to prefixed links of the form"language:title".&$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':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
getTitleKey()
Get the user's name escaped by underscores.
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.
doEdit($text, $summary, $flags=0, $baseRevId=false, $user=null)
Change an existing article or create a new article.
getContentModel()
Returns the page's content model id (see the CONTENT_MODEL_XXX constants).
static addCallableUpdate($callable, $type=self::POSTSEND)
Add a callable update.
checkTouched()
Loads page_touched and returns a value indicating if it should be used.
Database independant search index updater.
getSize()
Returns the content's nominal size in "bogo-bytes".
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfMsgReplaceArgs($message, $args)
Replace message parameter keys on the given formatted output.
loadFromRow($data, $from)
Load the object from a database row.
static getLocalizedName($name, Language $lang=null)
Returns the localized name for a given content model.
getRevision()
Get the latest revision.
getContent($audience=Revision::FOR_PUBLIC, User $user=null)
Get the content of the current revision.
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
static invalidateCache(Title $title, $revid=null)
Clear the info cache for a given Title.
getCacheExpiry()
Returns the number of seconds after which this object should expire.
wfGetLB($wiki=false)
Get a load balancer object.
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
wfReadOnly()
Check whether the wiki is in read-only mode.
deleteTitleProtection()
Remove any title protection due to page existing.
static getMain()
Static methods.
static singleton()
Get an instance of this class.
static clearFileCache(Title $title)
Clear the file caches for a page for all actions.
commitRollback($fromP, $summary, $bot, &$resultDetails, User $guser, $tags=null)
Backend implementation of doRollback(), please refer there for parameter and return value documentati...
static deprecated($func, $version, $component=false)
Logs a deprecation warning, visible if $wgDevelopmentWarnings, but only if self::$enableDeprecationWa...
isAllowed($action= '')
Internal mechanics of testing a permission.
Class to invalidate the HTML cache of all the pages linking to a given title.
getDBkey()
Get the main part with underscores.
wfWarn($msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
getComment($audience=Revision::FOR_PUBLIC, User $user=null)
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context $parserOutput
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
static runLegacyHooks($event, $args=[], $warn=null)
Call a legacy hook that uses text instead of Content objects.
followRedirect()
Get the Title object or URL this page redirects to.
static loadFromTimestamp($db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
static singleton()
Get a RepoGroup instance.
static getContentText(Content $content=null)
Convenience function for getting flat text from a Content object.
getContentHandler()
Returns the content handler appropriate for this revision's content model.
doDeleteArticle($reason, $suppress=false, $u1=null, $u2=null, &$error= '', User $user=null)
Same as doDeleteArticleReal(), but returns a simple boolean.
static newNullRevision($dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
static newFromRow($row, $from= 'fromdb')
Constructor from a database row.
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...
Class for handling updates to the site_stats table.
incEditCount()
Deferred version of incEditCountImmediate()
doCreate(Content $content, $flags, User $user, $summary, array $meta)
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
doModify(Content $content, $flags, User $user, $summary, array $meta)
Base interface for content objects.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing 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 unsetoffset-wrap String Wrap the message in html(usually something like"<
getOldestRevision()
Get the Revision object of the oldest revision.
getHiddenCategories()
Returns a list of hidden categories this page is a member of.
doViewUpdates(User $user, $oldid=0)
Do standard deferred updates after page view (existing or missing page)
getTitle()
Get the title object of the article.
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
static isIP($name)
Does the string match an anonymous IPv4 address?
wfIncrStats($key, $count=1)
Increment a statistics counter.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty & $sectionContent
namespace and then decline to actually register it file or subcat img or subcat $title
hasViewableContent()
Check if this page is something we're going to be showing some sort of sensible content for...
static addUpdate(DeferrableUpdate $update, $type=self::POSTSEND)
Add an update to the deferred list.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
getNamespace()
Get the namespace index, i.e.
static getDBOptions($bitfield)
Get an appropriate DB index and options for a query.
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
equals(Title $title)
Compare with another title.
static newFromResult($res)
static makeContent($text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
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
getInterwiki()
Get the interwiki prefix.
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
Special handling for file pages.
getRedirectURL($rt)
Get the Title object or URL to use for a redirect.
getContentHandler()
Returns the ContentHandler instance to be used to deal with the content of this WikiPage.
doPurge()
Perform the actions of a page purging.
equals(Content $that=null)
Returns true if this Content objects is conceptually equivalent to the given Content object...
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
getAutoDeleteReason(&$hasHistory)
Auto-generates a deletion reason.
static onArticleEdit(Title $title, Revision $revision=null)
Purge caches on page update etc.
doDeleteUpdates($id, Content $content=null)
Do some database updates after deletion.
static singleton($wiki=false)
static singleton()
Get an instance of this object.
prepareSave(WikiPage $page, $flags, $parentRevId, User $user)
Prepare Content for saving.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
getUserText($audience=Revision::FOR_PUBLIC, User $user=null)
Class representing a MediaWiki article and history.
static newFromId($id, $flags=0)
Load a page revision from a given revision ID number.
replaceSectionAtRev($sectionId, Content $sectionContent, $sectionTitle= '', $baseRevId=null)
prepareContentForEdit(Content $content, $revision=null, User $user=null, $serialFormat=null, $useCache=true)
Prepare content which is about to be saved.
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
static newDynamic(Title $title, array $params)
wfRandom()
Get a random decimal value between 0 and 1, in a way not likely to give duplicate values for any real...
Job to add recent change entries mentioning category membership changes.
Class for creating log entries manually, to inject them into the database.
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
hasDynamicContent()
Check whether the cache TTL was lowered due to dynamic content.
doEditUpdates(Revision $revision, User $user, array $options=[])
Do standard deferred updates after page edit.
getId()
Get the user's ID.
insertOn($dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
insertOn($dbw, $pageId=null)
Insert a new empty page record for this article.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
static onArticleDelete(Title $title)
Clears caches when article is deleted.
static convertSelectType($type)
Convert 'fromdb', 'fromdbmaster' and 'forupdate' to READ_* constants.
supportsSections()
Returns true if this page's content model supports sections.
static newPrioritized(Title $title, array $params)
preSaveTransform(Title $title, User $user, ParserOptions $parserOptions)
Returns a Content object with pre-save transformations applied (or this object if no transformations ...
getContent($audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
updateRedirectOn($dbw, $redirectTitle, $lastRevIsRedirect=null)
Add row to the redirect table if this is a redirect, remove otherwise.
shouldCheckParserCache(ParserOptions $parserOptions, $oldId)
Should the parser cache be used?
getRedirectTarget()
If this page is a redirect, get its target.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired 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 inclusive $limit
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
Interface for database access objects.
updateIfNewerOn($dbw, $revision)
If the given revision is newer than the currently set page_latest, update the page record...
static newFromID($id, $from= 'fromdb')
Constructor from a page id.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
loadPageData($from= 'fromdb')
Load the object from a given source by title.
insertRedirectEntry(Title $rt, $oldLatest=null)
Insert or update the redirect table entry for this page to indicate it redirects to $rt...
wfMemcKey()
Make a cache key for the local wiki.
setTimestamp($ts)
Set the page timestamp (use only to avoid DB queries)
doDeleteArticleReal($reason, $suppress=false, $u1=null, $u2=null, &$error= '', User $user=null)
Back-end article deletion Deletes the article with database consistency, writes logs, purges caches.
lockAndGetLatest()
Lock the page row for this title+id and return page_latest (or 0)
foreach($res as $row) $serialized
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...
pageData($dbr, $conditions, $options=[])
Fetch a page record with the given conditions.
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
getModel()
Returns the ID of the content model used by this Content object.
static logException($e)
Log an exception to the exception log (if enabled).
prepareTextForEdit($text, $revid=null, User $user=null)
Prepare text which is about to be saved.
wfTimestampOrNull($outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
static selectFields()
Return the list of revision fields that should be selected to create a new page.
static getAutosummary($oldtext, $newtext, $flags)
Return an applicable autosummary if one exists for the given edit.
clearPreparedEdit()
Clear the mPreparedEdit cache field, as may be needed by mutable content types.
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
__construct(Title $title)
Constructor and clear the article.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
getText($audience=Revision::FOR_PUBLIC, User $user=null)
Get the text of the current revision.
pageDataFromId($dbr, $id, $options=[])
Fetch a page record matching the requested ID.
Special handling for category pages.
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
static singleton()
Get the signleton instance of this class.
purgeSquid()
Purge all applicable CDN URLs.
static newGood($value=null)
Factory function for good results.
doUpdateRestrictions(array $limit, array $expiry, &$cascade, $reason, User $user, $tags=null)
Update the article's restriction field, and leave a log entry.
static flattenRestrictions($limit)
Take an array of page restrictions and flatten it to a string suitable for insertion into the page_re...
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
getCreator($audience=Revision::FOR_PUBLIC, User $user=null)
Get the User object of the user who created the page.
protectDescriptionLog(array $limit, array $expiry)
Builds the description to serve as comment for the log entry.