Go to the documentation of this file.
137 'page_title' => $linkTarget->
getDBkey()
141 $conds[
'rev_id'] = $id;
145 $conds[] =
'rev_id=page_latest';
166 $conds = [
'page_id' => $pageId ];
168 $conds[
'rev_id'] =
$revId;
172 $conds[] =
'rev_id = page_latest';
190 global $wgContentHandlerUseDB;
193 'page' => isset( $row->ar_page_id ) ? $row->ar_page_id :
null,
194 'id' => isset( $row->ar_rev_id ) ? $row->ar_rev_id :
null,
195 'comment' => $row->ar_comment,
196 'user' => $row->ar_user,
197 'user_text' => $row->ar_user_text,
198 'timestamp' => $row->ar_timestamp,
199 'minor_edit' => $row->ar_minor_edit,
200 'text_id' => isset( $row->ar_text_id ) ? $row->ar_text_id :
null,
201 'deleted' => $row->ar_deleted,
202 'len' => $row->ar_len,
203 'sha1' => isset( $row->ar_sha1 ) ? $row->ar_sha1 :
null,
204 'content_model' => isset( $row->ar_content_model ) ? $row->ar_content_model :
null,
205 'content_format' => isset( $row->ar_content_format ) ? $row->ar_content_format :
null,
208 if ( !$wgContentHandlerUseDB ) {
210 unset(
$attribs[
'content_format'] );
214 && isset( $row->ar_namespace )
215 && isset( $row->ar_title )
220 if ( isset( $row->ar_text ) && !$row->ar_text_id ) {
224 throw new MWException(
'Unable to load text from archive row (possibly T24624)' );
237 return new self( $row );
263 $conds = [
'rev_page' => intval( $pageid ),
'page_id' => intval( $pageid ) ];
265 $conds[
'rev_id'] = intval( $id );
267 $conds[] =
'rev_id=page_latest';
284 $matchId = intval( $id );
286 $matchId =
'page_latest';
291 'page_namespace' =>
$title->getNamespace(),
292 'page_title' =>
$title->getDBkey()
310 'rev_timestamp' => $db->timestamp( $timestamp ),
311 'page_namespace' =>
$title->getNamespace(),
312 'page_title' =>
$title->getDBkey()
334 && !(
$flags & self::READ_LATEST )
335 &&
wfGetLB()->getServerCount() > 1
336 &&
wfGetLB()->hasOrMadeRecentMasterChanges()
338 $flags = self::READ_LATEST;
363 $rev->mWiki = $db->getWikiID();
384 'rev_id=page_latest',
385 'page_namespace' =>
$title->getNamespace(),
386 'page_title' =>
$title->getDBkey()
404 $fields = array_merge(
405 self::selectFields(),
406 self::selectPageFields(),
407 self::selectUserFields()
410 if ( (
$flags & self::READ_LOCKING ) == self::READ_LOCKING ) {
413 return $db->selectRow(
414 [
'revision',
'page',
'user' ],
419 [
'page' => self::pageJoinCond(),
'user' => self::userJoinCond() ]
430 return [
'LEFT JOIN', [
'rev_user != 0',
'user_id = rev_user' ] ];
440 return [
'INNER JOIN', [
'page_id = rev_page' ] ];
449 global $wgContentHandlerUseDB;
466 if ( $wgContentHandlerUseDB ) {
467 $fields[] =
'rev_content_format';
468 $fields[] =
'rev_content_model';
480 global $wgContentHandlerUseDB;
498 if ( $wgContentHandlerUseDB ) {
499 $fields[] =
'ar_content_format';
500 $fields[] =
'ar_content_model';
537 return [
'user_name' ];
551 $res = $db->select(
'revision',
552 [
'rev_id',
'rev_len' ],
553 [
'rev_id' => $revIds ],
555 foreach (
$res as $row ) {
556 $revLens[$row->rev_id] = $row->rev_len;
569 if ( is_object( $row ) ) {
570 $this->mId = intval( $row->rev_id );
571 $this->mPage = intval( $row->rev_page );
572 $this->mTextId = intval( $row->rev_text_id );
573 $this->mComment = $row->rev_comment;
574 $this->mUser = intval( $row->rev_user );
575 $this->mMinorEdit = intval( $row->rev_minor_edit );
576 $this->mTimestamp = $row->rev_timestamp;
577 $this->mDeleted = intval( $row->rev_deleted );
579 if ( !isset( $row->rev_parent_id ) ) {
580 $this->mParentId =
null;
582 $this->mParentId = intval( $row->rev_parent_id );
585 if ( !isset( $row->rev_len ) ) {
588 $this->mSize = intval( $row->rev_len );
591 if ( !isset( $row->rev_sha1 ) ) {
594 $this->mSha1 = $row->rev_sha1;
597 if ( isset( $row->page_latest ) ) {
598 $this->mCurrent = ( $row->rev_id == $row->page_latest );
601 $this->mCurrent =
false;
602 $this->mTitle =
null;
605 if ( !isset( $row->rev_content_model ) ) {
606 $this->mContentModel =
null; # determine
on demand
if needed
608 $this->mContentModel = strval( $row->rev_content_model );
611 if ( !isset( $row->rev_content_format ) ) {
612 $this->mContentFormat =
null; # determine
on demand
if needed
614 $this->mContentFormat = strval( $row->rev_content_format );
619 if ( isset( $row->old_text ) ) {
620 $this->mTextRow = $row;
623 $this->mTextRow =
null;
627 $this->mUserText =
null;
628 if ( $this->mUser == 0 ) {
629 $this->mUserText = $row->rev_user_text;
630 } elseif ( isset( $row->user_name ) ) {
631 $this->mUserText = $row->user_name;
633 $this->mOrigUserText = $row->rev_user_text;
634 } elseif ( is_array( $row ) ) {
638 # if we have a content object, use it to set the model and type
639 if ( !empty( $row[
'content'] ) ) {
641 if ( !empty( $row[
'text_id'] ) ) {
642 throw new MWException(
"Text already stored in external store (id {$row['text_id']}), " .
643 "can't serialize content object" );
646 $row[
'content_model'] = $row[
'content']->getModel();
647 # note: mContentFormat is initializes later accordingly
648 # note: content is serialized later in this method!
649 # also set text to null?
652 $this->mId = isset( $row[
'id'] ) ? intval( $row[
'id'] ) :
null;
653 $this->mPage = isset( $row[
'page'] ) ? intval( $row[
'page'] ) :
null;
654 $this->mTextId = isset( $row[
'text_id'] ) ? intval( $row[
'text_id'] ) :
null;
655 $this->mUserText = isset( $row[
'user_text'] )
656 ? strval( $row[
'user_text'] ) :
$wgUser->getName();
657 $this->mUser = isset( $row[
'user'] ) ? intval( $row[
'user'] ) :
$wgUser->getId();
658 $this->mMinorEdit = isset( $row[
'minor_edit'] ) ? intval( $row[
'minor_edit'] ) : 0;
659 $this->mTimestamp = isset( $row[
'timestamp'] )
661 $this->mDeleted = isset( $row[
'deleted'] ) ? intval( $row[
'deleted'] ) : 0;
662 $this->mSize = isset( $row[
'len'] ) ? intval( $row[
'len'] ) :
null;
663 $this->mParentId = isset( $row[
'parent_id'] ) ? intval( $row[
'parent_id'] ) :
null;
664 $this->mSha1 = isset( $row[
'sha1'] ) ? strval( $row[
'sha1'] ) :
null;
666 $this->mContentModel = isset( $row[
'content_model'] )
667 ? strval( $row[
'content_model'] ) :
null;
668 $this->mContentFormat = isset( $row[
'content_format'] )
669 ? strval( $row[
'content_format'] ) :
null;
672 $this->mComment = isset( $row[
'comment'] ) ? trim( strval( $row[
'comment'] ) ) :
null;
673 $this->mText = isset( $row[
'text'] ) ? rtrim( strval( $row[
'text'] ) ) :
null;
674 $this->mTextRow =
null;
676 $this->mTitle = isset( $row[
'title'] ) ? $row[
'title'] :
null;
679 if ( !empty( $row[
'content'] ) ) {
680 if ( !( $row[
'content'] instanceof
Content ) ) {
681 throw new MWException(
'`content` field must contain a Content object.' );
685 $this->mContent = $row[
'content'];
687 $this->mContentModel = $this->mContent->getModel();
688 $this->mContentHandler =
null;
691 } elseif ( $this->mText !==
null ) {
693 $this->mContent =
$handler->unserializeContent( $this->mText );
697 if ( $this->mTitle && $this->mTitle->exists() ) {
698 if ( $this->mPage ===
null ) {
700 $this->mPage = $this->mTitle->getArticleID();
701 } elseif ( $this->mTitle->getArticleID() !==
$this->mPage ) {
704 wfDebug(
"Page ID " . $this->mPage .
" mismatches the ID " .
705 $this->mTitle->getArticleID() .
" provided by the Title object." );
709 $this->mCurrent =
false;
712 if ( !$this->mSize && $this->mContent !==
null ) {
713 $this->mSize = $this->mContent->getSize();
717 if ( $this->mSha1 ===
null ) {
718 $this->mSha1 = $this->mText ===
null ? null :
self::base36Sha1( $this->mText );
725 throw new MWException(
'Revision constructor passed invalid row format.' );
727 $this->mUnpatrolled =
null;
748 $this->mId = (int)$id;
761 $this->mUser = (int)$id;
762 $this->mUserText =
$name;
763 $this->mOrigUserText =
$name;
810 if ( $this->mTitle !==
null ) {
814 if ( $this->mId !==
null ) {
816 $row =
$dbr->selectRow(
817 [
'page',
'revision' ],
818 self::selectPageFields(),
819 [
'page_id=rev_page',
'rev_id' => $this->mId ],
828 if ( $this->mWiki ===
false || $this->mWiki ===
wfWikiID() ) {
830 if ( !$this->mTitle && $this->mPage !==
null && $this->mPage > 0 ) {
870 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_USER ) ) {
872 } elseif ( $audience == self::FOR_THIS_USER && !$this->
userCan( self::DELETED_USER,
$user ) ) {
887 return $this->
getUser( self::RAW );
906 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_USER ) ) {
908 } elseif ( $audience == self::FOR_THIS_USER && !$this->
userCan( self::DELETED_USER,
$user ) ) {
911 if ( $this->mUserText ===
null ) {
913 if ( $this->mUserText ===
false ) {
914 # This shouldn't happen, but it can if the wiki was recovered
915 # via importing revs and there is no user table entry yet.
948 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_COMMENT ) ) {
950 } elseif ( $audience == self::FOR_THIS_USER && !$this->
userCan( self::DELETED_COMMENT,
$user ) ) {
979 if ( $this->mUnpatrolled !==
null ) {
983 if ( $rc && $rc->getAttribute(
'rc_patrolled' ) == 0 ) {
984 $this->mUnpatrolled = $rc->getAttribute(
'rc_id' );
986 $this->mUnpatrolled = 0;
1008 'rc_timestamp' =>
$dbr->timestamp( $this->getTimestamp() ),
1009 'rc_this_oldid' => $this->
getId()
1022 if ( $this->
isCurrent() && $field === self::DELETED_TEXT ) {
1058 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_TEXT ) ) {
1060 } elseif ( $audience == self::FOR_THIS_USER && !$this->
userCan( self::DELETED_TEXT,
$user ) ) {
1074 if ( $this->mText ===
null ) {
1092 if ( $this->mContent ===
null ) {
1095 if ( $text !==
null && $text !==
false ) {
1100 $this->mContent =
$handler->unserializeContent( $text, $format );
1105 return $this->mContent ? $this->mContent->copy() :
null;
1119 if ( !$this->mContentModel ) {
1127 assert( !empty( $this->mContentModel ) );
1143 if ( !$this->mContentFormat ) {
1145 $this->mContentFormat =
$handler->getDefaultFormat();
1147 assert( !empty( $this->mContentFormat ) );
1160 if ( !$this->mContentHandler ) {
1166 if ( !$this->mContentHandler->isSupportedFormat( $format ) ) {
1167 throw new MWException(
"Oops, the content format $format is not supported for "
1168 .
"this content model, $model" );
1196 $prev = $this->
getTitle()->getPreviousRevisionID( $this->
getId() );
1211 $next = $this->
getTitle()->getNextRevisionID( $this->
getId() );
1227 if ( $this->mPage ===
null ) {
1230 # Use page_latest if ID is not given
1231 if ( !$this->mId ) {
1232 $prevId = $db->selectField(
'page',
'page_latest',
1233 [
'page_id' => $this->mPage ],
1236 $prevId = $db->selectField(
'revision',
'rev_id',
1237 [
'rev_page' => $this->mPage,
'rev_id < ' . $this->mId ],
1239 [
'ORDER BY' =>
'rev_id DESC' ] );
1241 return intval( $prevId );
1259 $textField = $prefix .
'text';
1260 $flagsField = $prefix .
'flags';
1262 if ( isset( $row->$flagsField ) ) {
1263 $flags = explode(
',', $row->$flagsField );
1268 if ( isset( $row->$textField ) ) {
1269 $text = $row->$textField;
1275 if ( in_array(
'external',
$flags ) ) {
1277 $parts = explode(
'://', $url, 2 );
1278 if (
count( $parts ) == 1 || $parts[1] ==
'' ) {
1282 if ( isset( $row->old_id ) && $wiki ===
false ) {
1284 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
1286 return $cache->getWithSetCallback(
1287 $cache->makeKey(
'revisiontext',
'textid', $row->old_id ),
1289 function ()
use ( $url, $wiki,
$flags ) {
1319 # Revisions not marked this way will be converted
1320 # on load if $wgLegacyCharset is set in the future.
1324 if ( function_exists(
'gzdeflate' ) ) {
1325 $deflated = gzdeflate( $text );
1327 if ( $deflated ===
false ) {
1334 wfDebug( __METHOD__ .
" -- no zlib support, not compressing\n" );
1337 return implode(
',',
$flags );
1350 if ( $text ===
false ) {
1355 if ( in_array(
'gzip',
$flags ) ) {
1356 # Deal with optional compression of archived pages.
1357 # This can be done periodically via maintenance/compressOld.php, and
1358 # as pages are saved if $wgCompressRevisions is set.
1359 $text = gzinflate( $text );
1361 if ( $text ===
false ) {
1367 if ( in_array(
'object',
$flags ) ) {
1368 # Generic compressed storage
1370 if ( !is_object( $obj ) ) {
1374 $text = $obj->getText();
1378 && !in_array(
'utf-8',
$flags ) && !in_array(
'utf8',
$flags )
1380 # Old revisions kept around in a legacy encoding?
1381 # Upconvert on demand.
1382 # ("utf8" checked for compatibility with some broken
1383 # conversion scripts 2008-12-30)
1404 $this->mQueryFlags |= self::READ_LATEST;
1407 if ( !$this->mPage ) {
1410 $titleText =
' for page ' .
$title->getPrefixedText();
1414 throw new MWException(
"Cannot insert revision$titleText: page ID must be nonzero" );
1422 # Write to external storage if required
1427 throw new MWException(
"Unable to store text to external storage" );
1435 # Record the text (or external storage URL) to the text table
1436 if ( $this->mTextId ===
null ) {
1437 $old_id = $dbw->nextSequenceValue(
'text_old_id_seq' );
1438 $dbw->insert(
'text',
1440 'old_id' => $old_id,
1441 'old_text' => $data,
1445 $this->mTextId = $dbw->insertId();
1448 if ( $this->mComment ===
null ) {
1449 $this->mComment =
"";
1452 # Record the edit in revisions
1453 $rev_id = $this->mId !==
null
1455 : $dbw->nextSequenceValue(
'revision_rev_id_seq' );
1457 'rev_id' => $rev_id,
1461 'rev_minor_edit' => $this->mMinorEdit ? 1 : 0,
1464 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ),
1467 'rev_parent_id' => $this->mParentId ===
null
1470 'rev_sha1' => $this->mSha1 ===
null
1475 if ( $wgContentHandlerUseDB ) {
1486 throw new MWException(
"Insufficient information to determine the title of the "
1487 .
"revision's page!" );
1493 $row[
'rev_content_model'] = ( $model === $defaultModel ) ?
null : $model;
1494 $row[
'rev_content_format'] = ( $format === $defaultFormat ) ?
null : $format;
1497 $dbw->insert(
'revision', $row, __METHOD__ );
1499 $this->mId = $rev_id !==
null ? $rev_id : $dbw->insertId();
1502 if ( (
int)$this->mId === 0 ) {
1503 throw new UnexpectedValueException(
1504 'After insert, Revision mId is ' . var_export( $this->mId, 1 ) .
': ' .
1505 var_export( $row, 1 )
1517 global $wgContentHandlerUseDB;
1526 if ( !
$handler->isSupportedFormat( $format ) ) {
1529 throw new MWException(
"Can't use format $format with content model $model on $t" );
1532 if ( !$wgContentHandlerUseDB &&
$title ) {
1538 $defaultFormat = $defaultHandler->getDefaultFormat();
1543 throw new MWException(
"Can't save non-default content model with "
1544 .
"\$wgContentHandlerUseDB disabled: model is $model, "
1545 .
"default for $t is $defaultModel" );
1551 throw new MWException(
"Can't use non-default content format with "
1552 .
"\$wgContentHandlerUseDB disabled: format is $format, "
1553 .
"default for $t is $defaultFormat" );
1558 $prefixedDBkey =
$title->getPrefixedDBkey();
1563 "Content of revision $revId ($prefixedDBkey) could not be loaded for validation!"
1568 "Content of revision $revId ($prefixedDBkey) is not valid! Content model is $model"
1579 return Wikimedia\base_convert( sha1( $text ), 16, 36, 31 );
1591 if (
$cache->getQoS( $cache::ATTR_EMULATION ) <= $cache::QOS_EMULATION_SQL ) {
1593 $ttl = $cache::TTL_UNCACHEABLE;
1611 return $cache->getWithSetCallback(
1612 $cache->makeKey(
'revisiontext',
'textid', $this->getTextId() ),
1613 self::getCacheTTL(
$cache ),
1625 if ( $this->mTextRow !==
null ) {
1627 $this->mTextRow =
null;
1636 ? self::READ_LATEST_IMMUTABLE
1639 list( $index,
$options, $fallbackIndex, $fallbackOptions ) =
1644 $row =
wfGetDB( $index )->selectRow(
1646 [
'old_text',
'old_flags' ],
1647 [
'old_id' => $textId ],
1654 if ( !$row && $fallbackIndex !==
null ) {
1657 $row =
wfGetDB( $fallbackIndex )->selectRow(
1659 [
'old_text',
'old_flags' ],
1660 [
'old_id' => $textId ],
1667 wfDebugLog(
'Revision',
"No text row with ID '$textId' (revision {$this->getId()})." );
1671 if ( $row && $text ===
false ) {
1672 wfDebugLog(
'Revision',
"No blob for text row '$textId' (revision {$this->getId()})." );
1675 return is_string( $text ) ? $text :
false;
1696 $fields = [
'page_latest',
'page_namespace',
'page_title',
1697 'rev_text_id',
'rev_len',
'rev_sha1' ];
1699 if ( $wgContentHandlerUseDB ) {
1700 $fields[] =
'rev_content_model';
1701 $fields[] =
'rev_content_format';
1704 $current = $dbw->selectRow(
1705 [
'page',
'revision' ],
1708 'page_id' => $pageId,
1709 'page_latest=rev_id',
1722 $summary =
$wgContLang->truncate( $summary, 255 );
1726 'user_text' =>
$user->getName(),
1727 'user' =>
$user->getId(),
1728 'comment' => $summary,
1729 'minor_edit' => $minor,
1730 'text_id' => $current->rev_text_id,
1731 'parent_id' => $current->page_latest,
1732 'len' => $current->rev_len,
1733 'sha1' => $current->rev_sha1
1736 if ( $wgContentHandlerUseDB ) {
1737 $row[
'content_model'] = $current->rev_content_model;
1738 $row[
'content_format'] = $current->rev_content_format;
1741 $row[
'title'] =
Title::makeTitle( $current->page_namespace, $current->page_title );
1782 if ( $bitfield & $field ) {
1783 if (
$user ===
null ) {
1787 if ( $bitfield & self::DELETED_RESTRICTED ) {
1788 $permissions = [
'suppressrevision',
'viewsuppressed' ];
1789 } elseif ( $field & self::DELETED_TEXT ) {
1790 $permissions = [
'deletedtext' ];
1792 $permissions = [
'deletedhistory' ];
1794 $permissionlist = implode(
', ', $permissions );
1796 wfDebug(
"Checking for $permissionlist due to $field match on $bitfield\n" );
1797 return call_user_func_array( [
$user,
'isAllowedAny' ], $permissions );
1799 $text =
$title->getPrefixedText();
1800 wfDebug(
"Checking for $permissionlist on $text due to $field match on $bitfield\n" );
1801 foreach ( $permissions
as $perm ) {
1822 $db = (
$flags & self::READ_LATEST )
1829 $conds = [
'rev_id' => $id ];
1830 $conds[
'rev_page'] =
$title->getArticleID();
1831 $timestamp = $db->selectField(
'revision',
'rev_timestamp', $conds, __METHOD__ );
1833 return ( $timestamp !==
false ) ?
wfTimestamp( TS_MW, $timestamp ) :
false;
1844 $row = $db->selectRow(
'revision', [
'revCount' =>
'COUNT(*)' ],
1845 [
'rev_page' => $id ], __METHOD__ );
1847 return $row->revCount;
1860 $id =
$title->getArticleID();
1888 if ( is_int( $db ) ) {
1892 $res = $db->select(
'revision',
1895 'rev_page' => $pageId,
1896 'rev_timestamp > ' . $db->addQuotes( $db->timestamp( $since ) )
1899 [
'ORDER BY' =>
'rev_timestamp ASC',
'LIMIT' => 50 ] );
1900 foreach (
$res as $row ) {
1901 if ( $row->rev_user != $userId ) {
1922 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
1923 return $cache->getWithSetCallback(
1927 function ( $curValue, &$ttl,
array &$setOpts )
use ( $db, $pageId,
$revId ) {
1928 $setOpts += Database::getCacheSetOptions( $db );
1933 $rev->mTitle =
null;
1934 $rev->mRefreshMutableFields =
true;
1937 return $rev ?:
false;
1946 if ( !$this->mRefreshMutableFields ) {
1950 $this->mRefreshMutableFields =
false;
1952 $row =
$dbr->selectRow(
1953 [
'revision',
'user' ],
1954 [
'rev_deleted',
'user_name' ],
1955 [
'rev_id' => $this->mId,
'user_id = rev_user' ],
1959 $this->mDeleted = (int)$row->rev_deleted;
1960 $this->mUserText = $row->user_name;
static newFromArchiveRow( $row, $overrides=[])
Make a fake revision object from an archive table row.
static insertToDefault( $data, array $params=[])
Like insert() above, but does more of the work for us.
A content handler knows how do deal with a specific type of content on a wiki page.
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
getUserText( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's username if it's available to the specified audience.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
getPreviousRevisionId( $db)
Get previous revision Id for this page_id This is used to populate rev_parent_id on save.
getRawUser()
Fetch revision's user id without regard for the current user's permissions.
static pageJoinCond()
Return the value of a select() page conds array for the page table.
getUser( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's user id if it's available to the specified audience.
static userCanBitfield( $bitfield, $field, User $user=null, Title $title=null)
Determine if the current user is allowed to view a particular field of this revision,...
static newFromConds( $conds, $fname=__METHOD__, $dbType=DB_REPLICA)
Find the first recent change matching some specific conditions.
$wgLegacyEncoding
Set this to eg 'ISO-8859-1' to perform character set conversion when loading old revisions not marked...
loadText()
Lazy-load the revision's text.
null ContentHandler $mContentHandler
getSize()
Returns the length of the text in this revision, or null if unknown.
wfGetLB( $wiki=false)
Get a load balancer object.
setId( $id)
Set the revision ID.
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getPage()
Get the page ID.
static newKnownCurrent(IDatabase $db, $pageId, $revId)
Load a revision based on a known page ID and current revision ID from the DB.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
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
static fetchFromURL( $url, array $params=[])
Fetch data from given URL.
unserialize( $serialized)
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
getParentId()
Get parent revision ID (the original previous page revision)
setTitle( $title)
Set the title of the revision.
getContentHandler()
Returns the content handler appropriate for this revision's content model.
static fetchFromConds( $db, $conditions, $flags=0)
Given a set of conditions, return a ResultWrapper which will return matching database rows with the f...
getSerializedData()
Get original serialized data (without checking view restrictions)
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
getRecentChange( $flags=0)
Get the RC object belonging to the current revision, if there's one.
static getDBOptions( $bitfield)
Get an appropriate DB index, options, and fallback DB index for a query.
Allows to change the fields on the form that will be generated $name
const CONTENT_MODEL_WIKITEXT
static newFromPageId( $pageId, $revId=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given page ID.
bool $mRefreshMutableFields
Used for cached values to reload user text and rev_deleted.
getSha1()
Returns the base36 sha1 of the text in this revision, or null if unknown.
static loadFromId( $db, $id)
Load a page revision from a given revision ID number.
array $wgDefaultExternalStore
The place to put new revisions, false to put them in the local text table.
Interface for database access objects.
getContentModel()
Returns the content model for this revision.
insertOn( $dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
static base36Sha1( $text)
Get the base 36 SHA-1 value for a string of text.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
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 selectTextFields()
Return the list of text fields that should be selected to read the revision text.
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
static getCacheTTL(WANObjectCache $cache)
Get the text cache TTL.
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title.
getNext()
Get next revision for this title.
namespace and then decline to actually register it file or subcat img or subcat $title
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
setUserIdAndName( $id, $name)
Set the user ID/name.
static getTimestampFromId( $title, $id, $flags=0)
Get rev_timestamp from rev_id, without loading the rest of the row.
static newFromRow( $row)
Make a Title object from a DB row.
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 and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static loadFromPageId( $db, $pageid, $id=0)
Load either the current, or a specified, revision that's attached to a given page.
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 & $attribs
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
when a variable name is used in a it is silently declared as a new masking the global
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
$wgCompressRevisions
We can also compress text stored in the 'text' table.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
static countByTitle( $db, $title)
Get count of revisions per page...not very efficient.
getPrevious()
Get previous revision for this title.
static countByPageId( $db, $id)
Get count of revisions per page...not very efficient.
static newFromConds( $conditions, $flags=0)
Given a set of conditions, fetch a revision.
static selectPageFields()
Return the list of page fields that should be selected from page table.
getTitle()
Returns the title of the page associated with this entry or null.
static userWasLastToEdit( $db, $pageId, $userId, $since)
Check if no edits were made by other users since the time a user started editing the page.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
__construct( $row)
Constructor.
static selectArchiveFields()
Return the list of revision fields that should be selected to create a new revision from an archive r...
static whoIs( $id)
Get the username corresponding to a given user ID.
static hasFlags( $bitfield, $flags)
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going on
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
getVisibility()
Get the deletion bitfield of the revision.
getTextId()
Get text row ID.
$wgRevisionCacheExpiry
Revision text may be cached in $wgMemc to reduce load on external storage servers and object extracti...
Multi-datacenter aware caching interface.
Content null bool $mContent
getRawUserText()
Fetch revision's username without regard for view restrictions.
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
getContentFormat()
Returns the content format for this revision.
Base interface for content objects.
static fetchRevision(LinkTarget $title)
Return a wrapper for a series of database rows to fetch all of a given page's revisions in turn.
Represents a title within MediaWiki.
static getMainWANInstance()
Get the main WAN cache object.
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
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 needed(most notably, OutputPage::addWikiText()). The StandardSkin object is a complete implementation
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
static userJoinCond()
Return the value of a select() JOIN conds array for the user table.
static loadFromTimestamp( $db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
getContentInternal()
Gets the content object for the revision (or null on failure).
getRawComment()
Fetch revision comment without regard for the current user's permissions.
getComment( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision comment if it's available to the specified audience.
static loadFromConds( $db, $conditions, $flags=0)
Given a set of conditions, fetch a revision from the given database connection.
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 and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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
static newNullRevision( $dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
static selectUserFields()
Return the list of user fields that should be selected from user table.
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
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
static decompressRevisionText( $text, $flags)
Re-converts revision text according to it's flags.
static loadFromTitle( $db, $title, $id=0)
Load either the current, or a specified, revision that's attached to a given page.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
loadMutableFields()
For cached revisions, make sure the user name and rev_deleted is up-to-date.
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 and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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
it s the revision text itself In either if gzip is the revision text is gzipped $flags
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision,...
the array() calling protocol came about after MediaWiki 1.4rc1.
string $mWiki
Wiki ID; false means the current wiki.
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