111 return self::newFromConds( [
'rev_id' => intval( $id ) ],
$flags );
131 'page_title' => $linkTarget->
getDBkey()
135 $conds[
'rev_id'] = $id;
136 return self::newFromConds( $conds,
$flags );
139 $conds[] =
'rev_id=page_latest';
141 return self::loadFromConds( $db, $conds,
$flags );
160 $conds = [
'page_id' => $pageId ];
162 $conds[
'rev_id'] =
$revId;
163 return self::newFromConds( $conds,
$flags );
166 $conds[] =
'rev_id = page_latest';
168 return self::loadFromConds( $db, $conds,
$flags );
184 global $wgContentHandlerUseDB;
187 'page' => isset( $row->ar_page_id ) ? $row->ar_page_id : null,
188 'id' => isset( $row->ar_rev_id ) ? $row->ar_rev_id : null,
189 'comment' => $row->ar_comment,
190 'user' => $row->ar_user,
191 'user_text' => $row->ar_user_text,
192 'timestamp' => $row->ar_timestamp,
193 'minor_edit' => $row->ar_minor_edit,
194 'text_id' => isset( $row->ar_text_id ) ? $row->ar_text_id : null,
195 'deleted' => $row->ar_deleted,
196 'len' => $row->ar_len,
197 'sha1' => isset( $row->ar_sha1 ) ? $row->ar_sha1 : null,
198 'content_model' => isset( $row->ar_content_model ) ? $row->ar_content_model : null,
199 'content_format' => isset( $row->ar_content_format ) ? $row->ar_content_format : null,
202 if ( !$wgContentHandlerUseDB ) {
204 unset(
$attribs[
'content_format'] );
208 && isset( $row->ar_namespace )
209 && isset( $row->ar_title )
214 if ( isset( $row->ar_text ) && !$row->ar_text_id ) {
216 $attribs[
'text'] = self::getRevisionText( $row,
'ar_' );
218 throw new MWException(
'Unable to load text from archive row (possibly bug 22624)' );
231 return new self( $row );
243 return self::loadFromConds( $db, [
'rev_id' => intval( $id ) ] );
257 $conds = [
'rev_page' => intval( $pageid ),
'page_id' => intval( $pageid ) ];
259 $conds[
'rev_id'] = intval( $id );
261 $conds[] =
'rev_id=page_latest';
263 return self::loadFromConds( $db, $conds );
278 $matchId = intval( $id );
280 $matchId =
'page_latest';
282 return self::loadFromConds( $db,
285 'page_namespace' =>
$title->getNamespace(),
286 'page_title' =>
$title->getDBkey()
302 return self::loadFromConds( $db,
304 'rev_timestamp' => $db->timestamp(
$timestamp ),
305 'page_namespace' =>
$title->getNamespace(),
306 'page_title' =>
$title->getDBkey()
324 $rev = self::loadFromConds( $db, $conditions,
$flags );
328 && !(
$flags & self::READ_LATEST )
329 &&
wfGetLB()->getServerCount() > 1
330 &&
wfGetLB()->hasOrMadeRecentMasterChanges()
332 $flags = self::READ_LATEST;
334 $rev = self::loadFromConds( $db, $conditions,
$flags );
354 $row = self::fetchFromConds( $db, $conditions,
$flags );
357 $rev->mWiki = $db->getWikiID();
375 $row = self::fetchFromConds(
378 'rev_id=page_latest',
398 $fields = array_merge(
399 self::selectFields(),
400 self::selectPageFields(),
401 self::selectUserFields()
404 if ( (
$flags & self::READ_LOCKING ) == self::READ_LOCKING ) {
407 return $db->selectRow(
408 [
'revision',
'page',
'user' ],
413 [
'page' => self::pageJoinCond(),
'user' => self::userJoinCond() ]
424 return [
'LEFT JOIN', [
'rev_user != 0',
'user_id = rev_user' ] ];
434 return [
'INNER JOIN', [
'page_id = rev_page' ] ];
443 global $wgContentHandlerUseDB;
460 if ( $wgContentHandlerUseDB ) {
461 $fields[] =
'rev_content_format';
462 $fields[] =
'rev_content_model';
474 global $wgContentHandlerUseDB;
492 if ( $wgContentHandlerUseDB ) {
493 $fields[] =
'ar_content_format';
494 $fields[] =
'ar_content_model';
531 return [
'user_name' ];
545 $res = $db->select(
'revision',
546 [
'rev_id',
'rev_len' ],
547 [
'rev_id' => $revIds ],
549 foreach (
$res as $row ) {
550 $revLens[$row->rev_id] = $row->rev_len;
563 if ( is_object( $row ) ) {
564 $this->mId = intval( $row->rev_id );
565 $this->mPage = intval( $row->rev_page );
566 $this->mTextId = intval( $row->rev_text_id );
567 $this->mComment = $row->rev_comment;
568 $this->mUser = intval( $row->rev_user );
569 $this->mMinorEdit = intval( $row->rev_minor_edit );
570 $this->mTimestamp = $row->rev_timestamp;
571 $this->mDeleted = intval( $row->rev_deleted );
573 if ( !isset( $row->rev_parent_id ) ) {
574 $this->mParentId = null;
576 $this->mParentId = intval( $row->rev_parent_id );
579 if ( !isset( $row->rev_len ) ) {
582 $this->mSize = intval( $row->rev_len );
585 if ( !isset( $row->rev_sha1 ) ) {
588 $this->mSha1 = $row->rev_sha1;
591 if ( isset( $row->page_latest ) ) {
592 $this->mCurrent = ( $row->rev_id == $row->page_latest );
595 $this->mCurrent =
false;
596 $this->mTitle = null;
599 if ( !isset( $row->rev_content_model ) ) {
600 $this->mContentModel = null; # determine
on demand
if needed
602 $this->mContentModel = strval( $row->rev_content_model );
605 if ( !isset( $row->rev_content_format ) ) {
606 $this->mContentFormat = null; # determine
on demand
if needed
608 $this->mContentFormat = strval( $row->rev_content_format );
613 if ( isset( $row->old_text ) ) {
614 $this->mTextRow = $row;
617 $this->mTextRow = null;
621 $this->mUserText = null;
622 if ( $this->mUser == 0 ) {
623 $this->mUserText = $row->rev_user_text;
624 } elseif ( isset( $row->user_name ) ) {
625 $this->mUserText = $row->user_name;
627 $this->mOrigUserText = $row->rev_user_text;
628 } elseif ( is_array( $row ) ) {
632 # if we have a content object, use it to set the model and type
633 if ( !empty( $row[
'content'] ) ) {
635 if ( !empty( $row[
'text_id'] ) ) {
636 throw new MWException(
"Text already stored in external store (id {$row['text_id']}), " .
637 "can't serialize content object" );
640 $row[
'content_model'] = $row[
'content']->getModel();
641 # note: mContentFormat is initializes later accordingly
642 # note: content is serialized later in this method!
643 # also set text to null?
646 $this->mId = isset( $row[
'id'] ) ? intval( $row[
'id'] ) : null;
647 $this->mPage = isset( $row[
'page'] ) ? intval( $row[
'page'] ) : null;
648 $this->mTextId = isset( $row[
'text_id'] ) ? intval( $row[
'text_id'] ) : null;
649 $this->mUserText = isset( $row[
'user_text'] )
650 ? strval( $row[
'user_text'] ) : $wgUser->getName();
651 $this->mUser = isset( $row[
'user'] ) ? intval( $row[
'user'] ) : $wgUser->getId();
652 $this->mMinorEdit = isset( $row[
'minor_edit'] ) ? intval( $row[
'minor_edit'] ) : 0;
653 $this->mTimestamp = isset( $row[
'timestamp'] )
655 $this->mDeleted = isset( $row[
'deleted'] ) ? intval( $row[
'deleted'] ) : 0;
656 $this->mSize = isset( $row[
'len'] ) ? intval( $row[
'len'] ) : null;
657 $this->mParentId = isset( $row[
'parent_id'] ) ? intval( $row[
'parent_id'] ) : null;
658 $this->mSha1 = isset( $row[
'sha1'] ) ? strval( $row[
'sha1'] ) : null;
660 $this->mContentModel = isset( $row[
'content_model'] )
661 ? strval( $row[
'content_model'] ) : null;
662 $this->mContentFormat = isset( $row[
'content_format'] )
663 ? strval( $row[
'content_format'] ) : null;
666 $this->mComment = isset( $row[
'comment'] ) ? trim( strval( $row[
'comment'] ) ) : null;
667 $this->mText = isset( $row[
'text'] ) ? rtrim( strval( $row[
'text'] ) ) : null;
668 $this->mTextRow = null;
670 $this->mTitle = isset( $row[
'title'] ) ? $row[
'title'] : null;
673 if ( !empty( $row[
'content'] ) ) {
674 if ( !( $row[
'content'] instanceof
Content ) ) {
675 throw new MWException(
'`content` field must contain a Content object.' );
679 $this->mContent = $row[
'content'];
681 $this->mContentModel = $this->mContent->getModel();
682 $this->mContentHandler = null;
685 } elseif ( $this->mText !== null ) {
687 $this->mContent =
$handler->unserializeContent( $this->mText );
691 if ( $this->mTitle && $this->mTitle->exists() ) {
692 if ( $this->mPage === null ) {
694 $this->mPage = $this->mTitle->getArticleID();
695 } elseif ( $this->mTitle->getArticleID() !==
$this->mPage ) {
698 wfDebug(
"Page ID " . $this->mPage .
" mismatches the ID " .
699 $this->mTitle->getArticleID() .
" provided by the Title object." );
703 $this->mCurrent =
false;
706 if ( !$this->mSize && $this->mContent !== null ) {
707 $this->mSize = $this->mContent->getSize();
711 if ( $this->mSha1 === null ) {
712 $this->mSha1 = $this->mText === null ? null : self::base36Sha1( $this->mText );
719 throw new MWException(
'Revision constructor passed invalid row format.' );
721 $this->mUnpatrolled = null;
742 $this->mId = (int)$id;
755 $this->mUser = (int)$id;
756 $this->mUserText =
$name;
757 $this->mOrigUserText =
$name;
804 if ( $this->mTitle !== null ) {
808 if ( $this->mId !== null ) {
810 $row =
$dbr->selectRow(
811 [
'page',
'revision' ],
812 self::selectPageFields(),
813 [
'page_id=rev_page',
'rev_id' => $this->mId ],
822 if ( $this->mWiki ===
false || $this->mWiki ===
wfWikiID() ) {
824 if ( !$this->mTitle && $this->mPage !== null && $this->mPage > 0 ) {
864 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_USER ) ) {
866 } elseif ( $audience == self::FOR_THIS_USER && !$this->
userCan( self::DELETED_USER,
$user ) ) {
881 return $this->
getUser( self::RAW );
900 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_USER ) ) {
902 } elseif ( $audience == self::FOR_THIS_USER && !$this->
userCan( self::DELETED_USER,
$user ) ) {
905 if ( $this->mUserText === null ) {
907 if ( $this->mUserText ===
false ) {
908 # This shouldn't happen, but it can if the wiki was recovered
909 # via importing revs and there is no user table entry yet.
942 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_COMMENT ) ) {
944 } elseif ( $audience == self::FOR_THIS_USER && !$this->
userCan( self::DELETED_COMMENT,
$user ) ) {
973 if ( $this->mUnpatrolled !== null ) {
977 if ( $rc && $rc->getAttribute(
'rc_patrolled' ) == 0 ) {
978 $this->mUnpatrolled = $rc->getAttribute(
'rc_id' );
980 $this->mUnpatrolled = 0;
1002 'rc_timestamp' =>
$dbr->timestamp( $this->getTimestamp() ),
1003 'rc_this_oldid' => $this->
getId()
1016 if ( $this->
isCurrent() && $field === self::DELETED_TEXT ) {
1074 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_TEXT ) ) {
1076 } elseif ( $audience == self::FOR_THIS_USER && !$this->
userCan( self::DELETED_TEXT,
$user ) ) {
1090 if ( $this->mText === null ) {
1108 if ( $this->mContent === null ) {
1111 if ( $text !== null && $text !==
false ) {
1116 $this->mContent =
$handler->unserializeContent( $text, $format );
1121 return $this->mContent ? $this->mContent->copy() : null;
1135 if ( !$this->mContentModel ) {
1143 assert( !empty( $this->mContentModel ) );
1159 if ( !$this->mContentFormat ) {
1161 $this->mContentFormat =
$handler->getDefaultFormat();
1163 assert( !empty( $this->mContentFormat ) );
1176 if ( !$this->mContentHandler ) {
1182 if ( !$this->mContentHandler->isSupportedFormat( $format ) ) {
1183 throw new MWException(
"Oops, the content format $format is not supported for "
1184 .
"this content model, $model" );
1212 $prev = $this->
getTitle()->getPreviousRevisionID( $this->
getId() );
1214 return self::newFromTitle( $this->
getTitle(), $prev );
1227 $next = $this->
getTitle()->getNextRevisionID( $this->
getId() );
1229 return self::newFromTitle( $this->
getTitle(), $next );
1243 if ( $this->mPage === null ) {
1246 # Use page_latest if ID is not given
1247 if ( !$this->mId ) {
1248 $prevId = $db->selectField(
'page',
'page_latest',
1249 [
'page_id' => $this->mPage ],
1252 $prevId = $db->selectField(
'revision',
'rev_id',
1253 [
'rev_page' => $this->mPage,
'rev_id < ' . $this->mId ],
1255 [
'ORDER BY' =>
'rev_id DESC' ] );
1257 return intval( $prevId );
1276 $textField = $prefix .
'text';
1277 $flagsField = $prefix .
'flags';
1279 if ( isset( $row->$flagsField ) ) {
1280 $flags = explode(
',', $row->$flagsField );
1285 if ( isset( $row->$textField ) ) {
1286 $text = $row->$textField;
1291 # Use external methods for external objects, text in table is URL-only then
1292 if ( in_array(
'external',
$flags ) ) {
1294 $parts = explode(
'://', $url, 2 );
1295 if ( count( $parts ) == 1 || $parts[1] ==
'' ) {
1302 if ( $text !==
false ) {
1303 $text = self::decompressRevisionText( $text,
$flags );
1322 # Revisions not marked this way will be converted
1323 # on load if $wgLegacyCharset is set in the future.
1326 if ( $wgCompressRevisions ) {
1327 if ( function_exists(
'gzdeflate' ) ) {
1328 $deflated = gzdeflate( $text );
1330 if ( $deflated ===
false ) {
1337 wfDebug( __METHOD__ .
" -- no zlib support, not compressing\n" );
1340 return implode(
',',
$flags );
1351 if ( in_array(
'gzip',
$flags ) ) {
1352 # Deal with optional compression of archived pages.
1353 # This can be done periodically via maintenance/compressOld.php, and
1354 # as pages are saved if $wgCompressRevisions is set.
1355 $text = gzinflate( $text );
1357 if ( $text ===
false ) {
1363 if ( in_array(
'object',
$flags ) ) {
1364 # Generic compressed storage
1366 if ( !is_object( $obj ) ) {
1370 $text = $obj->getText();
1374 if ( $text !==
false && $wgLegacyEncoding
1375 && !in_array(
'utf-8',
$flags ) && !in_array(
'utf8',
$flags )
1377 # Old revisions kept around in a legacy encoding?
1378 # Upconvert on demand.
1379 # ("utf8" checked for compatibility with some broken
1380 # conversion scripts 2008-12-30)
1382 $text = $wgContLang->iconv( $wgLegacyEncoding,
'UTF-8', $text );
1402 $this->mQueryFlags |= self::READ_LATEST;
1405 if ( !$this->mPage ) {
1408 $titleText =
' for page ' .
$title->getPrefixedText();
1412 throw new MWException(
"Cannot insert revision$titleText: page ID must be nonzero" );
1418 $flags = self::compressRevisionText( $data );
1420 # Write to external storage if required
1421 if ( $wgDefaultExternalStore ) {
1425 throw new MWException(
"Unable to store text to external storage" );
1433 # Record the text (or external storage URL) to the text table
1434 if ( $this->mTextId === null ) {
1435 $old_id = $dbw->nextSequenceValue(
'text_old_id_seq' );
1436 $dbw->insert(
'text',
1438 'old_id' => $old_id,
1439 'old_text' => $data,
1443 $this->mTextId = $dbw->insertId();
1446 if ( $this->mComment === null ) {
1447 $this->mComment =
"";
1450 # Record the edit in revisions
1451 $rev_id = $this->mId !== null
1453 : $dbw->nextSequenceValue(
'revision_rev_id_seq' );
1455 'rev_id' => $rev_id,
1459 'rev_minor_edit' => $this->mMinorEdit ? 1 : 0,
1462 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ),
1465 'rev_parent_id' => $this->mParentId === null
1468 'rev_sha1' => $this->mSha1 === null
1473 if ( $wgContentHandlerUseDB ) {
1484 throw new MWException(
"Insufficient information to determine the title of the "
1485 .
"revision's page!" );
1491 $row[
'rev_content_model'] = ( $model === $defaultModel ) ? null : $model;
1492 $row[
'rev_content_format'] = ( $format === $defaultFormat ) ? null : $format;
1495 $dbw->insert(
'revision', $row, __METHOD__ );
1497 $this->mId = $rev_id !== null ? $rev_id : $dbw->insertId();
1500 if ( (
int)$this->mId === 0 ) {
1502 'After insert, Revision mId is ' . var_export( $this->mId, 1 ) .
': ' .
1503 var_export( $row, 1 )
1513 global $wgContentHandlerUseDB;
1522 if ( !
$handler->isSupportedFormat( $format ) ) {
1525 throw new MWException(
"Can't use format $format with content model $model on $t" );
1528 if ( !$wgContentHandlerUseDB &&
$title ) {
1534 $defaultFormat = $defaultHandler->getDefaultFormat();
1539 throw new MWException(
"Can't save non-default content model with "
1540 .
"\$wgContentHandlerUseDB disabled: model is $model, "
1541 .
"default for $t is $defaultModel" );
1547 throw new MWException(
"Can't use non-default content format with "
1548 .
"\$wgContentHandlerUseDB disabled: format is $format, "
1549 .
"default for $t is $defaultFormat" );
1554 $prefixedDBkey =
$title->getPrefixedDBkey();
1559 "Content of revision $revId ($prefixedDBkey) could not be loaded for validation!"
1564 "Content of revision $revId ($prefixedDBkey) is not valid! Content model is $model"
1575 return Wikimedia\base_convert( sha1( $text ), 16, 36, 31 );
1588 if (
$cache->getQoS( $cache::ATTR_EMULATION ) <= $cache::QOS_EMULATION_SQL ) {
1590 $ttl = $cache::TTL_UNCACHEABLE;
1592 $ttl = $wgRevisionCacheExpiry ?: $cache::TTL_UNCACHEABLE;
1596 return $cache->getWithSetCallback(
1597 $cache->makeKey(
'revisiontext',
'textid', $this->getTextId() ),
1602 [
'pcGroup' => self::TEXT_CACHE_GROUP,
'pcTTL' => $cache::TTL_PROC_LONG ]
1610 if ( $this->mTextRow !== null ) {
1612 $this->mTextRow = null;
1621 ? self::READ_LATEST_IMMUTABLE
1624 list( $index,
$options, $fallbackIndex, $fallbackOptions ) =
1629 $row =
wfGetDB( $index )->selectRow(
1631 [
'old_text',
'old_flags' ],
1632 [
'old_id' => $textId ],
1639 if ( !$row && $fallbackIndex !== null ) {
1642 $row =
wfGetDB( $fallbackIndex )->selectRow(
1644 [
'old_text',
'old_flags' ],
1645 [
'old_id' => $textId ],
1652 wfDebugLog(
'Revision',
"No text row with ID '$textId' (revision {$this->getId()})." );
1655 $text = self::getRevisionText( $row );
1656 if ( $row && $text ===
false ) {
1657 wfDebugLog(
'Revision',
"No blob for text row '$textId' (revision {$this->getId()})." );
1660 return is_string( $text ) ? $text :
false;
1681 $fields = [
'page_latest',
'page_namespace',
'page_title',
1682 'rev_text_id',
'rev_len',
'rev_sha1' ];
1684 if ( $wgContentHandlerUseDB ) {
1685 $fields[] =
'rev_content_model';
1686 $fields[] =
'rev_content_format';
1689 $current = $dbw->selectRow(
1690 [
'page',
'revision' ],
1693 'page_id' => $pageId,
1694 'page_latest=rev_id',
1711 'user_text' =>
$user->getName(),
1712 'user' =>
$user->getId(),
1714 'minor_edit' => $minor,
1715 'text_id' => $current->rev_text_id,
1716 'parent_id' => $current->page_latest,
1717 'len' => $current->rev_len,
1718 'sha1' => $current->rev_sha1
1721 if ( $wgContentHandlerUseDB ) {
1722 $row[
'content_model'] = $current->rev_content_model;
1723 $row[
'content_format'] = $current->rev_content_format;
1726 $row[
'title'] =
Title::makeTitle( $current->page_namespace, $current->page_title );
1767 if ( $bitfield & $field ) {
1768 if (
$user === null ) {
1772 if ( $bitfield & self::DELETED_RESTRICTED ) {
1773 $permissions = [
'suppressrevision',
'viewsuppressed' ];
1774 } elseif ( $field & self::DELETED_TEXT ) {
1775 $permissions = [
'deletedtext' ];
1777 $permissions = [
'deletedhistory' ];
1779 $permissionlist = implode(
', ', $permissions );
1781 wfDebug(
"Checking for $permissionlist due to $field match on $bitfield\n" );
1782 return call_user_func_array( [
$user,
'isAllowedAny' ], $permissions );
1784 $text =
$title->getPrefixedText();
1785 wfDebug(
"Checking for $permissionlist on $text due to $field match on $bitfield\n" );
1786 foreach ( $permissions
as $perm ) {
1806 $db = (
$flags & self::READ_LATEST )
1813 $conds = [
'rev_id' => $id ];
1814 $conds[
'rev_page'] =
$title->getArticleID();
1815 $timestamp = $db->selectField(
'revision',
'rev_timestamp', $conds, __METHOD__ );
1828 $row = $db->selectRow(
'revision', [
'revCount' =>
'COUNT(*)' ],
1829 [
'rev_page' => $id ], __METHOD__ );
1831 return $row->revCount;
1844 $id =
$title->getArticleID();
1846 return self::countByPageId( $db, $id );
1872 if ( is_int( $db ) ) {
1876 $res = $db->select(
'revision',
1879 'rev_page' => $pageId,
1880 'rev_timestamp > ' . $db->addQuotes( $db->timestamp( $since ) )
1883 [
'ORDER BY' =>
'rev_timestamp ASC',
'LIMIT' => 50 ] );
1884 foreach (
$res as $row ) {
1885 if ( $row->rev_user != $userId ) {
1906 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
1907 return $cache->getWithSetCallback(
1911 function ( $curValue, &$ttl,
array &$setOpts )
use ( $db, $pageId,
$revId ) {
1917 $rev->mTitle = null;
1918 $rev->mRefreshMutableFields =
true;
1921 return $rev ?:
false;
1930 if ( !$this->mRefreshMutableFields ) {
1934 $this->mRefreshMutableFields =
false;
1936 $row =
$dbr->selectRow(
1937 [
'revision',
'user' ],
1938 [
'rev_deleted',
'user_name' ],
1939 [
'rev_id' => $this->mId,
'user_id = rev_user' ],
1943 $this->mDeleted = (int)$row->rev_deleted;
1944 $this->mUserText = $row->user_name;
static newFromRow($row)
Make a Title object from a DB row.
#define the
table suitable for use with IDatabase::select()
static newFromID($id, $flags=0)
Create a new Title from an article ID.
static whoIs($id)
Get the username corresponding to a given user ID.
static getMainWANInstance()
Get the main WAN cache object.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
the array() calling protocol came about after MediaWiki 1.4rc1.
static getRevisionText($row, $prefix= 'old_', $wiki=false)
Get revision text associated with an old or archive row $row is usually an object from wfFetchRow()...
const CONTENT_MODEL_WIKITEXT
array $wgDefaultExternalStore
The place to put new revisions, false to put them in the local text table.
static fetchRevision(LinkTarget $title)
Return a wrapper for a series of database rows to fetch all of a given page's revisions in turn...
setTitle($title)
Set the title of the revision.
getPage()
Get the page ID.
per default it will return the text for text based content
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static getForModelID($modelId)
Returns the ContentHandler singleton for the given model ID.
static insertToDefault($data, array $params=[])
Like insert() above, but does more of the work for us.
static getCacheSetOptions(IDatabase $db1)
Merge the result of getSessionLagStatus() for several DBs using the most pessimistic values to estima...
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 newFromConds($conds, $fname=__METHOD__, $dbType=DB_REPLICA)
Find the first recent change matching some specific conditions.
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title...
loadText()
Lazy-load the revision's text.
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
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
it s the revision text itself In either if gzip is the revision text is gzipped $flags
static selectArchiveFields()
Return the list of revision fields that should be selected to create a new revision from an archive r...
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
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 fetchFromConds($db, $conditions, $flags=0)
Given a set of conditions, return a ResultWrapper which will return matching database rows with the f...
$wgCompressRevisions
We can also compress text stored in the 'text' table.
loadMutableFields()
For cached revisions, make sure the user name and rev_deleted is up-to-date.
getSerializedData()
Get original serialized data (without checking view restrictions)
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
getRawComment()
Fetch revision comment without regard for the current user's permissions.
bool $mRefreshMutableFields
Used for cached values to reload user text and rev_deleted.
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static loadFromConds($db, $conditions, $flags=0)
Given a set of conditions, fetch a revision from the given database connection.
wfDebugLog($logGroup, $text, $dest= 'all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not...
$wgRevisionCacheExpiry
Revision text may be cached in $wgMemc to reduce load on external storage servers and object extracti...
null ContentHandler $mContentHandler
wfGetLB($wiki=false)
Get a load balancer object.
getTitle()
Returns the title of the page associated with this entry or null.
$wgLegacyEncoding
Set this to eg 'ISO-8859-1' to perform character set conversion when loading old revisions not marked...
getParentId()
Get parent revision ID (the original previous page revision)
getUserText($audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's username if it's available to the specified audience.
getRawUserText()
Fetch revision's username without regard for view restrictions.
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 loadFromTimestamp($db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
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.
__construct($row)
Constructor.
static newNullRevision($dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Base interface for content objects.
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
static selectTextFields()
Return the list of text fields that should be selected to read the revision text. ...
wfDeprecated($function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
userCan($field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision, if it's marked as deleted.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
getComment($audience=self::FOR_PUBLIC, User $user=null)
Fetch revision comment if it's available to the specified audience.
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
getContentInternal()
Gets the content object for the revision (or null on failure).
namespace and then decline to actually register it file or subcat img or subcat $title
static newKnownCurrent(IDatabase $db, $pageId, $revId)
Load a revision based on a known page ID and current revision ID from the DB.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static getDBOptions($bitfield)
Get an appropriate DB index, options, and fallback DB index 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
static loadFromTitle($db, $title, $id=0)
Load either the current, or a specified, revision that's attached to a given page.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
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
getPrevious()
Get previous revision for this title.
setId($id)
Set the revision ID.
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
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
getRecentChange($flags=0)
Get the RC object belonging to the current revision, if there's one.
getContentModel()
Returns the content model for this revision.
static countByPageId($db, $id)
Get count of revisions per page...not very efficient.
static newFromId($id, $flags=0)
Load a page revision from a given revision ID number.
static pageJoinCond()
Return the value of a select() page conds array for the page table.
getVisibility()
Get the deletion bitfield of the revision.
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
getWikiID()
Alias for getDomainID()
static hasFlags($bitfield, $flags)
getTextId()
Get text row 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...
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 fetchFromURL($url, array $params=[])
Fetch data from given URL.
getText($audience=self::FOR_PUBLIC, User $user=null)
Fetch revision text if it's available to the specified audience.
static countByTitle($db, $title)
Get count of revisions per page...not very efficient.
getContent($audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
getPreviousRevisionId($db)
Get previous revision Id for this page_id This is used to populate rev_parent_id on save...
static loadFromPageId($db, $pageid, $id=0)
Load either the current, or a specified, revision that's attached to a given page.
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.
getNext()
Get next revision for this title.
static getParentLengths($db, array $revIds)
Do a batched query to get the parent revision lengths.
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
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 base36Sha1($text)
Get the base 36 SHA-1 value for a string of text.
getUser($audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's user id if it's available to the specified audience.
static selectPageFields()
Return the list of page fields that should be selected from page table.
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, if it's marked as deleted.
wfLogWarning($msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
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
static userWasLastToEdit($db, $pageId, $userId, $since)
Check if no edits were made by other users since the time a user started editing the page...
static userJoinCond()
Return the value of a select() JOIN conds array for the user table.
getContentFormat()
Returns the content format for this revision.
static loadFromId($db, $id)
Load a page revision from a given revision ID number.
Content null bool $mContent
static newFromArchiveRow($row, $overrides=[])
Make a fake revision object from an archive table row.
getRawUser()
Fetch revision's user id without regard for the current user's permissions.
getSize()
Returns the length of the text in this revision, or null if unknown.
string $mWiki
Wiki ID; false means the current wiki.
static decompressRevisionText($text, $flags)
Re-converts revision text according to it's flags.
static selectUserFields()
Return the list of user fields that should be selected from user table.
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
static newFromConds($conditions, $flags=0)
Given a set of conditions, fetch a revision.
getSha1()
Returns the base36 sha1 of the text in this revision, or null if unknown.
Basic database interface for live and lazy-loaded relation database handles.
Allows to change the fields on the form that will be generated $name