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';
193 'page' => isset( $row->ar_page_id ) ? $row->ar_page_id :
null,
194 'id' => isset( $row->ar_rev_id ) ? $row->ar_rev_id :
null,
198 'user' => $row->ar_user,
199 'user_text' => $row->ar_user_text,
200 'timestamp' => $row->ar_timestamp,
201 'minor_edit' => $row->ar_minor_edit,
202 'text_id' => isset( $row->ar_text_id ) ? $row->ar_text_id :
null,
203 'deleted' => $row->ar_deleted,
204 'len' => $row->ar_len,
205 'sha1' => isset( $row->ar_sha1 ) ? $row->ar_sha1 :
null,
206 'content_model' => isset( $row->ar_content_model ) ? $row->ar_content_model :
null,
207 'content_format' => isset( $row->ar_content_format ) ? $row->ar_content_format :
null,
212 unset(
$attribs[
'content_format'] );
216 && isset( $row->ar_namespace )
217 && isset( $row->ar_title )
219 $attribs[
'title'] = Title::makeTitle( $row->ar_namespace, $row->ar_title );
222 if ( isset( $row->ar_text ) && !$row->ar_text_id ) {
226 throw new MWException(
'Unable to load text from archive row (possibly T24624)' );
239 return new self( $row );
265 $conds = [
'rev_page' => intval( $pageid ),
'page_id' => intval( $pageid ) ];
267 $conds[
'rev_id'] = intval( $id );
269 $conds[] =
'rev_id=page_latest';
286 $matchId = intval( $id );
288 $matchId =
'page_latest';
293 'page_namespace' =>
$title->getNamespace(),
294 'page_title' =>
$title->getDBkey()
312 'rev_timestamp' => $db->timestamp( $timestamp ),
313 'page_namespace' =>
$title->getNamespace(),
314 'page_title' =>
$title->getDBkey()
336 && !(
$flags & self::READ_LATEST )
337 &&
wfGetLB()->getServerCount() > 1
338 &&
wfGetLB()->hasOrMadeRecentMasterChanges()
340 $flags = self::READ_LATEST;
365 $rev->mWiki = $db->getDomainID();
386 'rev_id=page_latest',
387 'page_namespace' =>
$title->getNamespace(),
388 'page_title' =>
$title->getDBkey()
406 $fields = array_merge(
407 self::selectFields(),
408 self::selectPageFields(),
409 self::selectUserFields()
412 if ( (
$flags & self::READ_LOCKING ) == self::READ_LOCKING ) {
415 return $db->selectRow(
416 [
'revision',
'page',
'user' ],
421 [
'page' => self::pageJoinCond(),
'user' => self::userJoinCond() ]
432 return [
'LEFT JOIN', [
'rev_user != 0',
'user_id = rev_user' ] ];
442 return [
'INNER JOIN', [
'page_id = rev_page' ] ];
472 $fields[] =
'rev_content_format';
473 $fields[] =
'rev_content_model';
507 $fields[] =
'ar_content_format';
508 $fields[] =
'ar_content_model';
545 return [
'user_name' ];
559 $res = $db->select(
'revision',
560 [
'rev_id',
'rev_len' ],
561 [
'rev_id' => $revIds ],
563 foreach (
$res as $row ) {
564 $revLens[$row->rev_id] = $row->rev_len;
575 if ( is_object( $row ) ) {
576 $this->mId = intval( $row->rev_id );
577 $this->mPage = intval( $row->rev_page );
578 $this->mTextId = intval( $row->rev_text_id );
582 $this->mUser = intval( $row->rev_user );
583 $this->mMinorEdit = intval( $row->rev_minor_edit );
584 $this->mTimestamp = $row->rev_timestamp;
585 $this->mDeleted = intval( $row->rev_deleted );
587 if ( !isset( $row->rev_parent_id ) ) {
588 $this->mParentId =
null;
590 $this->mParentId = intval( $row->rev_parent_id );
593 if ( !isset( $row->rev_len ) ) {
596 $this->mSize = intval( $row->rev_len );
599 if ( !isset( $row->rev_sha1 ) ) {
602 $this->mSha1 = $row->rev_sha1;
605 if ( isset( $row->page_latest ) ) {
606 $this->mCurrent = ( $row->rev_id == $row->page_latest );
607 $this->mTitle = Title::newFromRow( $row );
609 $this->mCurrent =
false;
610 $this->mTitle =
null;
613 if ( !isset( $row->rev_content_model ) ) {
614 $this->mContentModel =
null; # determine
on demand
if needed
616 $this->mContentModel = strval( $row->rev_content_model );
619 if ( !isset( $row->rev_content_format ) ) {
620 $this->mContentFormat =
null; # determine
on demand
if needed
622 $this->mContentFormat = strval( $row->rev_content_format );
627 if ( isset( $row->old_text ) ) {
628 $this->mTextRow = $row;
631 $this->mTextRow =
null;
635 $this->mUserText =
null;
636 if ( $this->mUser == 0 ) {
637 $this->mUserText = $row->rev_user_text;
638 } elseif ( isset( $row->user_name ) ) {
639 $this->mUserText = $row->user_name;
641 $this->mOrigUserText = $row->rev_user_text;
642 } elseif ( is_array( $row ) ) {
646 # if we have a content object, use it to set the model and type
647 if ( !empty( $row[
'content'] ) ) {
649 if ( !empty( $row[
'text_id'] ) ) {
650 throw new MWException(
"Text already stored in external store (id {$row['text_id']}), " .
651 "can't serialize content object" );
654 $row[
'content_model'] = $row[
'content']->getModel();
655 # note: mContentFormat is initializes later accordingly
656 # note: content is serialized later in this method!
657 # also set text to null?
660 $this->mId = isset( $row[
'id'] ) ? intval( $row[
'id'] ) :
null;
661 $this->mPage = isset( $row[
'page'] ) ? intval( $row[
'page'] ) :
null;
662 $this->mTextId = isset( $row[
'text_id'] ) ? intval( $row[
'text_id'] ) :
null;
663 $this->mUserText = isset( $row[
'user_text'] )
664 ? strval( $row[
'user_text'] ) :
$wgUser->getName();
665 $this->mUser = isset( $row[
'user'] ) ? intval( $row[
'user'] ) :
$wgUser->getId();
666 $this->mMinorEdit = isset( $row[
'minor_edit'] ) ? intval( $row[
'minor_edit'] ) : 0;
667 $this->mTimestamp = isset( $row[
'timestamp'] )
669 $this->mDeleted = isset( $row[
'deleted'] ) ? intval( $row[
'deleted'] ) : 0;
670 $this->mSize = isset( $row[
'len'] ) ? intval( $row[
'len'] ) :
null;
671 $this->mParentId = isset( $row[
'parent_id'] ) ? intval( $row[
'parent_id'] ) :
null;
672 $this->mSha1 = isset( $row[
'sha1'] ) ? strval( $row[
'sha1'] ) :
null;
674 $this->mContentModel = isset( $row[
'content_model'] )
675 ? strval( $row[
'content_model'] ) :
null;
676 $this->mContentFormat = isset( $row[
'content_format'] )
677 ? strval( $row[
'content_format'] ) :
null;
680 $this->mComment = isset( $row[
'comment'] ) ? trim( strval( $row[
'comment'] ) ) :
null;
681 $this->mText = isset( $row[
'text'] ) ? rtrim( strval( $row[
'text'] ) ) :
null;
682 $this->mTextRow =
null;
684 $this->mTitle = isset( $row[
'title'] ) ? $row[
'title'] :
null;
687 if ( !empty( $row[
'content'] ) ) {
688 if ( !( $row[
'content'] instanceof
Content ) ) {
689 throw new MWException(
'`content` field must contain a Content object.' );
693 $this->mContent = $row[
'content'];
695 $this->mContentModel = $this->mContent->getModel();
696 $this->mContentHandler =
null;
699 } elseif ( $this->mText !==
null ) {
701 $this->mContent =
$handler->unserializeContent( $this->mText );
705 if ( $this->mTitle && $this->mTitle->exists() ) {
706 if ( $this->mPage ===
null ) {
708 $this->mPage = $this->mTitle->getArticleID();
709 } elseif ( $this->mTitle->getArticleID() !== $this->mPage ) {
712 wfDebug(
"Page ID " . $this->mPage .
" mismatches the ID " .
713 $this->mTitle->getArticleID() .
" provided by the Title object." );
717 $this->mCurrent =
false;
720 if ( !$this->mSize && $this->mContent !==
null ) {
721 $this->mSize = $this->mContent->getSize();
725 if ( $this->mSha1 ===
null ) {
726 $this->mSha1 = $this->mText ===
null ? null :
self::base36Sha1( $this->mText );
733 throw new MWException(
'Revision constructor passed invalid row format.' );
735 $this->mUnpatrolled =
null;
756 $this->mId = (int)$id;
769 $this->mUser = (int)$id;
770 $this->mUserText =
$name;
771 $this->mOrigUserText =
$name;
818 if ( $this->mTitle !==
null ) {
822 if ( $this->mId !==
null ) {
824 $row =
$dbr->selectRow(
825 [
'page',
'revision' ],
826 self::selectPageFields(),
827 [
'page_id=rev_page',
'rev_id' => $this->mId ],
832 $this->mTitle = Title::newFromRow( $row );
836 if ( $this->mWiki ===
false || $this->mWiki ===
wfWikiID() ) {
838 if ( !$this->mTitle && $this->mPage !==
null && $this->mPage > 0 ) {
839 $this->mTitle = Title::newFromID( $this->mPage );
877 public function getUser( $audience = self::FOR_PUBLIC,
User $user =
null ) {
878 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_USER ) ) {
880 } elseif ( $audience == self::FOR_THIS_USER && !$this->
userCan( self::DELETED_USER,
$user ) ) {
895 return $this->
getUser( self::RAW );
914 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_USER ) ) {
916 } elseif ( $audience == self::FOR_THIS_USER && !$this->
userCan( self::DELETED_USER,
$user ) ) {
919 if ( $this->mUserText ===
null ) {
920 $this->mUserText = User::whoIs( $this->mUser );
921 if ( $this->mUserText ===
false ) {
922 # This shouldn't happen, but it can if the wiki was recovered
923 # via importing revs and there is no user table entry yet.
956 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_COMMENT ) ) {
958 } elseif ( $audience == self::FOR_THIS_USER && !$this->
userCan( self::DELETED_COMMENT,
$user ) ) {
987 if ( $this->mUnpatrolled !==
null ) {
991 if ( $rc && $rc->getAttribute(
'rc_patrolled' ) == 0 ) {
992 $this->mUnpatrolled = $rc->getAttribute(
'rc_id' );
994 $this->mUnpatrolled = 0;
1015 'rc_user_text' => $this->
getUserText( self::RAW ),
1016 'rc_timestamp' =>
$dbr->timestamp( $this->getTimestamp() ),
1017 'rc_this_oldid' => $this->getId()
1030 if ( $this->
isCurrent() && $field === self::DELETED_TEXT ) {
1066 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( self::DELETED_TEXT ) ) {
1068 } elseif ( $audience == self::FOR_THIS_USER && !$this->
userCan( self::DELETED_TEXT,
$user ) ) {
1082 if ( $this->mText ===
null ) {
1100 if ( $this->mContent ===
null ) {
1103 if ( $text !==
null && $text !==
false ) {
1108 $this->mContent =
$handler->unserializeContent( $text, $format );
1113 return $this->mContent ? $this->mContent->copy() :
null;
1127 if ( !$this->mContentModel ) {
1135 assert( !empty( $this->mContentModel ) );
1151 if ( !$this->mContentFormat ) {
1153 $this->mContentFormat =
$handler->getDefaultFormat();
1155 assert( !empty( $this->mContentFormat ) );
1168 if ( !$this->mContentHandler ) {
1174 if ( !$this->mContentHandler->isSupportedFormat( $format ) ) {
1175 throw new MWException(
"Oops, the content format $format is not supported for "
1176 .
"this content model, $model" );
1204 $prev = $this->
getTitle()->getPreviousRevisionID( $this->
getId() );
1219 $next = $this->
getTitle()->getNextRevisionID( $this->
getId() );
1235 if ( $this->mPage ===
null ) {
1238 # Use page_latest if ID is not given
1239 if ( !$this->mId ) {
1240 $prevId = $db->selectField(
'page',
'page_latest',
1241 [
'page_id' => $this->mPage ],
1244 $prevId = $db->selectField(
'revision',
'rev_id',
1245 [
'rev_page' => $this->mPage,
'rev_id < ' . $this->mId ],
1247 [
'ORDER BY' =>
'rev_id DESC' ] );
1249 return intval( $prevId );
1267 $textField = $prefix .
'text';
1268 $flagsField = $prefix .
'flags';
1270 if ( isset( $row->$flagsField ) ) {
1271 $flags = explode(
',', $row->$flagsField );
1276 if ( isset( $row->$textField ) ) {
1277 $text = $row->$textField;
1283 if ( in_array(
'external',
$flags ) ) {
1285 $parts = explode(
'://', $url, 2 );
1286 if ( count( $parts ) == 1 || $parts[1] ==
'' ) {
1290 if ( isset( $row->old_id ) && $wiki ===
false ) {
1292 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
1294 return $cache->getWithSetCallback(
1295 $cache->makeKey(
'revisiontext',
'textid', $row->old_id ),
1296 self::getCacheTTL(
$cache ),
1327 # Revisions not marked this way will be converted
1328 # on load if $wgLegacyCharset is set in the future.
1332 if ( function_exists(
'gzdeflate' ) ) {
1333 $deflated = gzdeflate( $text );
1335 if ( $deflated ===
false ) {
1342 wfDebug( __METHOD__ .
" -- no zlib support, not compressing\n" );
1345 return implode(
',',
$flags );
1358 if ( $text ===
false ) {
1363 if ( in_array(
'gzip',
$flags ) ) {
1364 # Deal with optional compression of archived pages.
1365 # This can be done periodically via maintenance/compressOld.php, and
1366 # as pages are saved if $wgCompressRevisions is set.
1367 $text = gzinflate( $text );
1369 if ( $text ===
false ) {
1375 if ( in_array(
'object',
$flags ) ) {
1376 # Generic compressed storage
1378 if ( !is_object( $obj ) ) {
1382 $text = $obj->getText();
1386 && !in_array(
'utf-8',
$flags ) && !in_array(
'utf8',
$flags )
1388 # Old revisions kept around in a legacy encoding?
1389 # Upconvert on demand.
1390 # ("utf8" checked for compatibility with some broken
1391 # conversion scripts 2008-12-30)
1412 $this->mQueryFlags |= self::READ_LATEST;
1415 if ( !$this->mPage ) {
1418 $titleText =
' for page ' .
$title->getPrefixedText();
1422 throw new MWException(
"Cannot insert revision$titleText: page ID must be nonzero" );
1430 # Write to external storage if required
1435 throw new MWException(
"Unable to store text to external storage" );
1443 # Record the text (or external storage URL) to the text table
1444 if ( $this->mTextId ===
null ) {
1445 $dbw->insert(
'text',
1447 'old_text' => $data,
1451 $this->mTextId = $dbw->insertId();
1454 if ( $this->mComment ===
null ) {
1455 $this->mComment =
"";
1458 # Record the edit in revisions
1462 'rev_minor_edit' => $this->mMinorEdit ? 1 : 0,
1465 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ),
1468 'rev_parent_id' => $this->mParentId ===
null
1471 'rev_sha1' => $this->mSha1 ===
null
1475 if ( $this->mId !==
null ) {
1479 list( $commentFields, $commentCallback ) =
1481 $row += $commentFields;
1494 throw new MWException(
"Insufficient information to determine the title of the "
1495 .
"revision's page!" );
1501 $row[
'rev_content_model'] = ( $model === $defaultModel ) ?
null : $model;
1502 $row[
'rev_content_format'] = ( $format === $defaultFormat ) ?
null : $format;
1505 $dbw->insert(
'revision', $row, __METHOD__ );
1507 if ( $this->mId ===
null ) {
1509 $this->mId = $dbw->insertId();
1511 $commentCallback( $this->mId );
1514 if ( (
int)$this->mId === 0 ) {
1515 throw new UnexpectedValueException(
1516 'After insert, Revision mId is ' . var_export( $this->mId, 1 ) .
': ' .
1517 var_export( $row, 1 )
1522 if ( $this->mUser === 0 && IP::isValid( $this->mUserText ) ) {
1525 'ipc_rev_timestamp' => $row[
'rev_timestamp'],
1526 'ipc_hex' => IP::toHex( $row[
'rev_user_text'] ),
1528 $dbw->insert(
'ip_changes', $ipcRow, __METHOD__ );
1533 Hooks::run(
'RevisionInsertComplete', [ &$revision, $data,
$flags ] );
1548 if ( !
$handler->isSupportedFormat( $format ) ) {
1551 throw new MWException(
"Can't use format $format with content model $model on $t" );
1560 $defaultFormat = $defaultHandler->getDefaultFormat();
1565 throw new MWException(
"Can't save non-default content model with "
1566 .
"\$wgContentHandlerUseDB disabled: model is $model, "
1567 .
"default for $t is $defaultModel" );
1573 throw new MWException(
"Can't use non-default content format with "
1574 .
"\$wgContentHandlerUseDB disabled: format is $format, "
1575 .
"default for $t is $defaultFormat" );
1580 $prefixedDBkey =
$title->getPrefixedDBkey();
1585 "Content of revision $revId ($prefixedDBkey) could not be loaded for validation!"
1588 if ( !$content->isValid() ) {
1590 "Content of revision $revId ($prefixedDBkey) is not valid! Content model is $model"
1601 return Wikimedia\base_convert( sha1( $text ), 16, 36, 31 );
1613 if (
$cache->getQoS( $cache::ATTR_EMULATION ) <= $cache::QOS_EMULATION_SQL ) {
1615 $ttl = $cache::TTL_UNCACHEABLE;
1630 $cache = ObjectCache::getMainWANInstance();
1633 return $cache->getWithSetCallback(
1634 $cache->makeKey(
'revisiontext',
'textid', $this->getTextId() ),
1635 self::getCacheTTL(
$cache ),
1647 if ( $this->mTextRow !==
null ) {
1649 $this->mTextRow =
null;
1658 ? self::READ_LATEST_IMMUTABLE
1661 list( $index,
$options, $fallbackIndex, $fallbackOptions ) =
1666 $row =
wfGetDB( $index )->selectRow(
1668 [
'old_text',
'old_flags' ],
1669 [
'old_id' => $textId ],
1676 if ( !$row && $fallbackIndex !==
null ) {
1679 $row =
wfGetDB( $fallbackIndex )->selectRow(
1681 [
'old_text',
'old_flags' ],
1682 [
'old_id' => $textId ],
1689 wfDebugLog(
'Revision',
"No text row with ID '$textId' (revision {$this->getId()})." );
1693 if ( $row && $text ===
false ) {
1694 wfDebugLog(
'Revision',
"No blob for text row '$textId' (revision {$this->getId()})." );
1697 return is_string( $text ) ? $text :
false;
1718 $fields = [
'page_latest',
'page_namespace',
'page_title',
1719 'rev_text_id',
'rev_len',
'rev_sha1' ];
1722 $fields[] =
'rev_content_model';
1723 $fields[] =
'rev_content_format';
1726 $current = $dbw->selectRow(
1727 [
'page',
'revision' ],
1730 'page_id' => $pageId,
1731 'page_latest=rev_id',
1745 'user_text' =>
$user->getName(),
1746 'user' =>
$user->getId(),
1747 'comment' => $summary,
1748 'minor_edit' => $minor,
1749 'text_id' => $current->rev_text_id,
1750 'parent_id' => $current->page_latest,
1751 'len' => $current->rev_len,
1752 'sha1' => $current->rev_sha1
1756 $row[
'content_model'] = $current->rev_content_model;
1757 $row[
'content_format'] = $current->rev_content_format;
1760 $row[
'title'] = Title::makeTitle( $current->page_namespace, $current->page_title );
1801 if ( $bitfield & $field ) {
1802 if (
$user ===
null ) {
1806 if ( $bitfield & self::DELETED_RESTRICTED ) {
1807 $permissions = [
'suppressrevision',
'viewsuppressed' ];
1808 } elseif ( $field & self::DELETED_TEXT ) {
1809 $permissions = [
'deletedtext' ];
1811 $permissions = [
'deletedhistory' ];
1813 $permissionlist = implode(
', ', $permissions );
1815 wfDebug(
"Checking for $permissionlist due to $field match on $bitfield\n" );
1816 return call_user_func_array( [
$user,
'isAllowedAny' ], $permissions );
1818 $text =
$title->getPrefixedText();
1819 wfDebug(
"Checking for $permissionlist on $text due to $field match on $bitfield\n" );
1820 foreach ( $permissions
as $perm ) {
1841 $db = (
$flags & self::READ_LATEST )
1848 $conds = [
'rev_id' => $id ];
1849 $conds[
'rev_page'] =
$title->getArticleID();
1850 $timestamp = $db->selectField(
'revision',
'rev_timestamp', $conds, __METHOD__ );
1852 return ( $timestamp !==
false ) ?
wfTimestamp( TS_MW, $timestamp ) :
false;
1863 $row = $db->selectRow(
'revision', [
'revCount' =>
'COUNT(*)' ],
1864 [
'rev_page' => $id ], __METHOD__ );
1866 return $row->revCount;
1879 $id =
$title->getArticleID();
1907 if ( is_int( $db ) ) {
1911 $res = $db->select(
'revision',
1914 'rev_page' => $pageId,
1915 'rev_timestamp > ' . $db->addQuotes( $db->timestamp( $since ) )
1918 [
'ORDER BY' =>
'rev_timestamp ASC',
'LIMIT' => 50 ] );
1919 foreach (
$res as $row ) {
1920 if ( $row->rev_user != $userId ) {
1941 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
1942 return $cache->getWithSetCallback(
1946 function ( $curValue, &$ttl,
array &$setOpts )
use ( $db, $pageId, $revId ) {
1947 $setOpts += Database::getCacheSetOptions( $db );
1952 $rev->mTitle =
null;
1953 $rev->mRefreshMutableFields =
true;
1956 return $rev ?:
false;
1965 if ( !$this->mRefreshMutableFields ) {
1969 $this->mRefreshMutableFields =
false;
1971 $row =
$dbr->selectRow(
1972 [
'revision',
'user' ],
1973 [
'rev_deleted',
'user_name' ],
1974 [
'rev_id' => $this->mId,
'user_id = rev_user' ],
1978 $this->mDeleted = (int)$row->rev_deleted;
1979 $this->mUserText = $row->user_name;
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
unserialize( $serialized)
$wgLegacyEncoding
Set this to eg 'ISO-8859-1' to perform character set conversion when loading old revisions not marked...
$wgRevisionCacheExpiry
Revision text may be cached in $wgMemc to reduce load on external storage servers and object extracti...
array $wgDefaultExternalStore
The place to put new revisions, false to put them in the local text table.
$wgCompressRevisions
We can also compress text stored in the 'text' table.
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfGetLB( $wiki=false)
Get a load balancer object.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
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.
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title.
static getDBOptions( $bitfield)
Get an appropriate DB index, options, and fallback DB index for a query.
static hasFlags( $bitfield, $flags)
static fetchFromURL( $url, array $params=[])
Fetch data from given URL.
static insertToDefault( $data, array $params=[])
Like insert() above, but does more of the work for us.
static newFromConds( $conds, $fname=__METHOD__, $dbType=DB_REPLICA)
Find the first recent change matching some specific conditions.
static newKnownCurrent(IDatabase $db, $pageId, $revId)
Load a revision based on a known page ID and current revision ID from the DB.
getRecentChange( $flags=0)
Get the RC object belonging to the current revision, if there's one.
getUserText( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's username if it's available to the specified audience.
getTitle()
Returns the title of the page associated with this entry or null.
static selectArchiveFields()
Return the list of revision fields that should be selected to create a new revision from an archive r...
getPrevious()
Get previous revision for this title.
null ContentHandler $mContentHandler
getSize()
Returns the length of the text in this revision, or null if unknown.
loadMutableFields()
For cached revisions, make sure the user name and rev_deleted is up-to-date.
static getCacheTTL(WANObjectCache $cache)
Get the text cache TTL.
getContentInternal()
Gets the content object for the revision (or null on failure).
getSerializedData()
Get original serialized data (without checking view restrictions)
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
getRawUser()
Fetch revision's user id without regard for the current user's permissions.
static userJoinCond()
Return the value of a select() JOIN conds array for the user table.
static decompressRevisionText( $text, $flags)
Re-converts revision text according to it's flags.
bool $mRefreshMutableFields
Used for cached values to reload user text and rev_deleted.
setUserIdAndName( $id, $name)
Set the user ID/name.
getContentHandler()
Returns the content handler appropriate for this revision's content model.
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
getComment( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision comment if it's available to the specified audience.
static fetchFromConds( $db, $conditions, $flags=0)
Given a set of conditions, return a ResultWrapper which will return matching database rows with the f...
static loadFromTitle( $db, $title, $id=0)
Load either the current, or a specified, revision that's attached to a given page.
getNext()
Get next revision for this title.
getTextId()
Get text row ID.
static selectTextFields()
Return the list of text fields that should be selected to read the revision text.
static newFromPageId( $pageId, $revId=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given page ID.
static selectPageFields()
Return the list of page fields that should be selected from page table.
getContentFormat()
Returns the content format for this revision.
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
static loadFromTimestamp( $db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
static loadFromConds( $db, $conditions, $flags=0)
Given a set of conditions, fetch a revision from the given database connection.
getPage()
Get the page ID.
static newNullRevision( $dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
static loadFromId( $db, $id)
Load a page revision from a given revision ID number.
static getTimestampFromId( $title, $id, $flags=0)
Get rev_timestamp from rev_id, without loading the rest of the row.
static selectUserFields()
Return the list of user fields that should be selected from user table.
getContentModel()
Returns the content model for this revision.
static countByPageId( $db, $id)
Get count of revisions per page...not very efficient.
getUser( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's user id if it's available to the specified audience.
static newFromArchiveRow( $row, $overrides=[])
Make a fake revision object from an archive table row.
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
static countByTitle( $db, $title)
Get count of revisions per page...not very efficient.
static pageJoinCond()
Return the value of a select() page conds array for the page table.
static newFromConds( $conditions, $flags=0)
Given a set of conditions, fetch a revision.
static base36Sha1( $text)
Get the base 36 SHA-1 value for a string of text.
getSha1()
Returns the base36 sha1 of the text in this revision, or null if unknown.
static loadFromPageId( $db, $pageid, $id=0)
Load either the current, or a specified, revision that's attached to a given page.
getRawComment()
Fetch revision comment without regard for the current user's permissions.
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,...
getVisibility()
Get the deletion bitfield of the revision.
setTitle( $title)
Set the title of the revision.
insertOn( $dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
Content null bool $mContent
string $mWiki
Wiki ID; false means the current wiki.
static userWasLastToEdit( $db, $pageId, $userId, $since)
Check if no edits were made by other users since the time a user started editing the page.
getRawUserText()
Fetch revision's username without regard for view restrictions.
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
static fetchRevision(LinkTarget $title)
Return a wrapper for a series of database rows to fetch all of a given page's revisions in turn.
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision,...
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
getParentId()
Get parent revision ID (the original previous page revision)
getPreviousRevisionId( $db)
Get previous revision Id for this page_id This is used to populate rev_parent_id on save.
loadText()
Lazy-load the revision's text.
setId( $id)
Set the revision ID.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Multi-datacenter aware caching interface.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when needed(most notably, OutputPage::addWikiText()). The StandardSkin object is a complete implementation
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
when a variable name is used in a function
when a variable name is used in a it is silently declared as a new local masking the global
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
const CONTENT_MODEL_WIKITEXT
the array() calling protocol came about after MediaWiki 1.4rc1.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
namespace and then decline to actually register it file or subcat img or subcat $title
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Allows to change the fields on the form that will be generated $name
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
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Base interface for content objects.
Interface for database access objects.