MediaWiki REL1_35
Revision.php
Go to the documentation of this file.
1<?php
33use Wikimedia\Assert\Assert;
35
40class Revision implements IDBAccessObject {
41
43 private $mRecord;
44
45 // Revision deletion constants
46 public const DELETED_TEXT = RevisionRecord::DELETED_TEXT;
47 public const DELETED_COMMENT = RevisionRecord::DELETED_COMMENT;
48 public const DELETED_USER = RevisionRecord::DELETED_USER;
49 public const DELETED_RESTRICTED = RevisionRecord::DELETED_RESTRICTED;
50 public const SUPPRESSED_USER = RevisionRecord::SUPPRESSED_USER;
51 public const SUPPRESSED_ALL = RevisionRecord::SUPPRESSED_ALL;
52
53 // Audience options for accessors
54 public const FOR_PUBLIC = RevisionRecord::FOR_PUBLIC;
55 public const FOR_THIS_USER = RevisionRecord::FOR_THIS_USER;
56 public const RAW = RevisionRecord::RAW;
57
58 public const TEXT_CACHE_GROUP = SqlBlobStore::TEXT_CACHE_GROUP;
59
64 private static function getRevisionStore( $wiki = false ) {
65 if ( $wiki ) {
66 return MediaWikiServices::getInstance()->getRevisionStoreFactory()
67 ->getRevisionStore( $wiki );
68 } else {
69 return MediaWikiServices::getInstance()->getRevisionStore();
70 }
71 }
72
76 private static function getRevisionLookup() {
77 return MediaWikiServices::getInstance()->getRevisionLookup();
78 }
79
83 private static function getRevisionFactory() {
84 return MediaWikiServices::getInstance()->getRevisionFactory();
85 }
86
92 private static function getBlobStore( $wiki = false ) {
93 $store = MediaWikiServices::getInstance()
94 ->getBlobStoreFactory()
95 ->newSqlBlobStore( $wiki );
96
97 if ( !$store instanceof SqlBlobStore ) {
98 throw new RuntimeException(
99 'The backwards compatibility code in Revision currently requires the BlobStore '
100 . 'service to be an SqlBlobStore instance, but it is a ' . get_class( $store )
101 );
102 }
103
104 return $store;
105 }
106
121 public static function newFromId( $id, $flags = 0 ) {
122 wfDeprecated( __METHOD__, '1.31' );
123 $rec = self::getRevisionLookup()->getRevisionById( $id, $flags );
124 return $rec ? new Revision( $rec, $flags ) : null;
125 }
126
143 public static function newFromTitle( LinkTarget $linkTarget, $id = 0, $flags = 0 ) {
144 wfDeprecated( __METHOD__, '1.31' );
145 $rec = self::getRevisionLookup()->getRevisionByTitle( $linkTarget, $id, $flags );
146 return $rec ? new Revision( $rec, $flags ) : null;
147 }
148
165 public static function newFromPageId( $pageId, $revId = 0, $flags = 0 ) {
166 wfDeprecated( __METHOD__, '1.31' );
167 $rec = self::getRevisionLookup()->getRevisionByPageId( $pageId, $revId, $flags );
168 return $rec ? new Revision( $rec, $flags ) : null;
169 }
170
183 public static function newFromArchiveRow( $row, $overrides = [] ) {
184 wfDeprecated( __METHOD__, '1.31' );
185
192 if ( array_key_exists( 'page', $overrides ) ) {
193 $overrides['page_id'] = $overrides['page'];
194 unset( $overrides['page'] );
195 }
196
202 $title = null;
203 if ( isset( $overrides['title'] ) ) {
204 if ( !( $overrides['title'] instanceof Title ) ) {
205 throw new MWException( 'title field override must contain a Title object.' );
206 }
207
208 $title = $overrides['title'];
209 }
210 if ( $title !== null ) {
211 if ( isset( $row->ar_namespace ) && isset( $row->ar_title ) ) {
212 $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
213 } else {
214 throw new InvalidArgumentException(
215 'A Title or ar_namespace and ar_title must be given'
216 );
217 }
218 }
219
220 $rec = self::getRevisionFactory()->newRevisionFromArchiveRow( $row, 0, $title, $overrides );
221 return new Revision( $rec, self::READ_NORMAL, $title );
222 }
223
237 public static function newFromRow( $row ) {
238 wfDeprecated( __METHOD__, '1.31' );
239 if ( is_array( $row ) ) {
240 $rec = self::getRevisionFactory()->newMutableRevisionFromArray( $row );
241 } else {
242 $rec = self::getRevisionFactory()->newRevisionFromRow( $row );
243 }
244
245 return new Revision( $rec );
246 }
247
261 public static function loadFromPageId( $db, $pageid, $id = 0 ) {
262 wfDeprecated( __METHOD__, '1.31' );
263 $rec = self::getRevisionStore()->loadRevisionFromPageId( $db, $pageid, $id );
264 return $rec ? new Revision( $rec ) : null;
265 }
266
280 public static function loadFromTitle( $db, $title, $id = 0 ) {
281 wfDeprecated( __METHOD__, '1.31' );
282 $rec = self::getRevisionStore()->loadRevisionFromTitle( $db, $title, $id );
283 return $rec ? new Revision( $rec ) : null;
284 }
285
299 public static function loadFromTimestamp( $db, $title, $timestamp ) {
300 wfDeprecated( __METHOD__, '1.31' );
301 $rec = self::getRevisionStore()->loadRevisionFromTimestamp( $db, $title, $timestamp );
302 return $rec ? new Revision( $rec ) : null;
303 }
304
319 public static function getQueryInfo( $options = [] ) {
320 wfDeprecated( __METHOD__, '1.31' );
321 return self::getRevisionStore()->getQueryInfo( $options );
322 }
323
335 public static function getArchiveQueryInfo() {
336 wfDeprecated( __METHOD__, '1.31' );
337 return self::getRevisionStore()->getArchiveQueryInfo();
338 }
339
350 public static function getParentLengths( $db, array $revIds ) {
351 wfDeprecated( __METHOD__, '1.31' );
352 return self::getRevisionStore()->getRevisionSizes( $revIds );
353 }
354
365 public function __construct( $row, $queryFlags = 0, Title $title = null ) {
366 wfDeprecated( __METHOD__, '1.31' );
367
368 global $wgUser;
369
370 if ( $row instanceof RevisionRecord ) {
371 $this->mRecord = $row;
372 } elseif ( is_array( $row ) ) {
373 // If no user is specified, fall back to using the global user object, to stay
374 // compatible with pre-1.31 behavior.
375 if ( !isset( $row['user'] ) && !isset( $row['user_text'] ) ) {
376 $row['user'] = $wgUser;
377 }
378
379 $this->mRecord = self::getRevisionFactory()->newMutableRevisionFromArray(
380 $row,
381 $queryFlags,
382 $this->ensureTitle( $row, $queryFlags, $title )
383 );
384 } elseif ( is_object( $row ) ) {
385 $this->mRecord = self::getRevisionFactory()->newRevisionFromRow(
386 $row,
387 $queryFlags,
388 $this->ensureTitle( $row, $queryFlags, $title )
389 );
390 } else {
391 throw new InvalidArgumentException(
392 '$row must be a row object, an associative array, or a RevisionRecord'
393 );
394 }
395
396 Assert::postcondition( $this->mRecord !== null, 'Failed to construct a RevisionRecord' );
397 }
398
409 private function ensureTitle( $row, $queryFlags, $title = null ) {
410 if ( $title ) {
411 return $title;
412 }
413
414 if ( is_array( $row ) ) {
415 if ( isset( $row['title'] ) ) {
416 if ( !( $row['title'] instanceof Title ) ) {
417 throw new MWException( 'title field must contain a Title object.' );
418 }
419
420 return $row['title'];
421 }
422
423 $pageId = $row['page'] ?? 0;
424 $revId = $row['id'] ?? 0;
425 } else {
426 $pageId = $row->rev_page ?? 0;
427 $revId = $row->rev_id ?? 0;
428 }
429
430 try {
431 $title = self::getRevisionStore()->getTitle( $pageId, $revId, $queryFlags );
432 } catch ( RevisionAccessException $ex ) {
433 // construct a dummy title!
434 wfLogWarning( __METHOD__ . ': ' . $ex->getMessage() );
435
436 // NOTE: this Title will only be used inside RevisionRecord
437 $title = Title::makeTitleSafe( NS_SPECIAL, "Badtitle/ID=$pageId" );
438 $title->resetArticleID( $pageId );
439 }
440
441 return $title;
442 }
443
448 public function getRevisionRecord() {
449 wfDeprecated( __METHOD__, '1.31' );
450 return $this->mRecord;
451 }
452
460 public function getId() {
461 wfDeprecated( __METHOD__, '1.31' );
462 return $this->mRecord->getId();
463 }
464
478 public function setId( $id ) {
479 wfDeprecated( __METHOD__, '1.31' );
480 if ( $this->mRecord instanceof MutableRevisionRecord ) {
481 $this->mRecord->setId( intval( $id ) );
482 } else {
483 throw new MWException( __METHOD__ . ' is not supported on this instance' );
484 }
485 }
486
501 public function setUserIdAndName( $id, $name ) {
502 wfDeprecated( __METHOD__, '1.31' );
503 if ( $this->mRecord instanceof MutableRevisionRecord ) {
504 $user = User::newFromAnyId( intval( $id ), $name, null );
505 $this->mRecord->setUser( $user );
506 } else {
507 throw new MWException( __METHOD__ . ' is not supported on this instance' );
508 }
509 }
510
514 private function getMainSlotRaw() {
515 if ( !$this->mRecord->hasSlot( SlotRecord::MAIN ) ) {
516 return null;
517 }
518
519 return $this->mRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW );
520 }
521
535 public function getTextId() {
536 wfDeprecated( __METHOD__, '1.31' );
537 $slot = $this->getMainSlotRaw();
538 return $slot && $slot->hasAddress()
539 ? self::getBlobStore()->getTextIdFromAddress( $slot->getAddress() )
540 : null;
541 }
542
551 public function getParentId() {
552 wfDeprecated( __METHOD__, '1.31' );
553 return $this->mRecord->getParentId();
554 }
555
563 public function getSize() {
564 wfDeprecated( __METHOD__, '1.31' );
565 try {
566 return $this->mRecord->getSize();
567 } catch ( RevisionAccessException $ex ) {
568 return null;
569 }
570 }
571
579 public function getSha1() {
580 wfDeprecated( __METHOD__, '1.31' );
581 try {
582 return $this->mRecord->getSha1();
583 } catch ( RevisionAccessException $ex ) {
584 return null;
585 }
586 }
587
598 public function getTitle() {
599 wfDeprecated( __METHOD__, '1.31' );
600 $linkTarget = $this->mRecord->getPageAsLinkTarget();
601 return Title::newFromLinkTarget( $linkTarget );
602 }
603
612 public function setTitle( $title ) {
613 wfDeprecated( __METHOD__, '1.31' );
614 if ( !$title->equals( $this->getTitle() ) ) {
615 throw new InvalidArgumentException(
616 $title->getPrefixedText()
617 . ' is not the same as '
618 . $this->mRecord->getPageAsLinkTarget()->__toString()
619 );
620 }
621 }
622
630 public function getPage() {
631 wfDeprecated( __METHOD__, '1.31' );
632 return $this->mRecord->getPageId();
633 }
634
650 public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
651 wfDeprecated( __METHOD__, '1.31' );
652 if ( $audience === self::FOR_THIS_USER && !$user ) {
653 global $wgUser;
654 $user = $wgUser;
655 }
656
657 $user = $this->mRecord->getUser( $audience, $user );
658 return $user ? $user->getId() : 0;
659 }
660
676 public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
677 wfDeprecated( __METHOD__, '1.31' );
678 if ( $audience === self::FOR_THIS_USER && !$user ) {
679 global $wgUser;
680 $user = $wgUser;
681 }
682
683 $user = $this->mRecord->getUser( $audience, $user );
684 return $user ? $user->getName() : '';
685 }
686
700 public function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
701 wfDeprecated( __METHOD__, '1.31' );
702 if ( $audience === self::FOR_THIS_USER && !$user ) {
703 global $wgUser;
704 $user = $wgUser;
705 }
706
707 $comment = $this->mRecord->getComment( $audience, $user );
708 return $comment === null ? null : $comment->text;
709 }
710
716 public function isMinor() {
717 wfDeprecated( __METHOD__, '1.31' );
718 return $this->mRecord->isMinor();
719 }
720
725 public function isUnpatrolled() {
726 wfDeprecated( __METHOD__, '1.31' );
727 return self::getRevisionStore()->getRcIdIfUnpatrolled( $this->mRecord );
728 }
729
741 public function getRecentChange( $flags = 0 ) {
742 wfDeprecated( __METHOD__, '1.31' );
743 return self::getRevisionStore()->getRecentChange( $this->mRecord, $flags );
744 }
745
753 public function isDeleted( $field ) {
754 wfDeprecated( __METHOD__, '1.31' );
755 return $this->mRecord->isDeleted( $field );
756 }
757
765 public function getVisibility() {
766 wfDeprecated( __METHOD__, '1.31' );
767 return $this->mRecord->getVisibility();
768 }
769
786 public function getContent( $audience = self::FOR_PUBLIC, User $user = null ) {
787 wfDeprecated( __METHOD__, '1.31' );
788
789 global $wgUser;
790
791 if ( $audience === self::FOR_THIS_USER && !$user ) {
792 $user = $wgUser;
793 }
794
795 try {
796 return $this->mRecord->getContent( SlotRecord::MAIN, $audience, $user );
797 }
798 catch ( RevisionAccessException $e ) {
799 return null;
800 }
801 }
802
811 public function getSerializedData() {
812 wfDeprecated( __METHOD__, '1.31' );
813 $slot = $this->getMainSlotRaw();
814 return $slot ? $slot->getContent()->serialize() : '';
815 }
816
829 public function getContentModel() {
830 wfDeprecated( __METHOD__, '1.31' );
831
832 $slot = $this->getMainSlotRaw();
833
834 if ( $slot ) {
835 return $slot->getModel();
836 } else {
837 $slotRoleRegistry = MediaWikiServices::getInstance()->getSlotRoleRegistry();
838 $slotRoleHandler = $slotRoleRegistry->getRoleHandler( SlotRecord::MAIN );
839 return $slotRoleHandler->getDefaultModel( $this->getTitle() );
840 }
841 }
842
854 public function getContentFormat() {
855 wfDeprecated( __METHOD__, '1.31' );
856
857 $slot = $this->getMainSlotRaw();
858 $format = $slot ? $this->getMainSlotRaw()->getFormat() : null;
859
860 if ( $format === null ) {
861 // if no format was stored along with the blob, fall back to default format
862 $format = $this->getContentHandler()->getDefaultFormat();
863 }
864
865 return $format;
866 }
867
876 public function getContentHandler() {
877 wfDeprecated( __METHOD__, '1.31' );
878
879 return MediaWikiServices::getInstance()
880 ->getContentHandlerFactory()
881 ->getContentHandler( $this->getContentModel() );
882 }
883
889 public function getTimestamp() {
890 wfDeprecated( __METHOD__, '1.31' );
891 return $this->mRecord->getTimestamp();
892 }
893
899 public function isCurrent() {
900 wfDeprecated( __METHOD__, '1.31' );
901 return $this->mRecord->isCurrent();
902 }
903
911 public function getPrevious() {
912 wfDeprecated( __METHOD__, '1.31' );
913 $rec = self::getRevisionLookup()->getPreviousRevision( $this->mRecord );
914 return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
915 }
916
924 public function getNext() {
925 wfDeprecated( __METHOD__, '1.31' );
926 $rec = self::getRevisionLookup()->getNextRevision( $this->mRecord );
927 return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
928 }
929
951 public static function getRevisionText( $row, $prefix = 'old_', $wiki = false ) {
952 wfDeprecated( __METHOD__, '1.32' );
953
954 if ( !$row ) {
955 return false;
956 }
957
958 $textField = $prefix . 'text';
959
960 if ( isset( $row->$textField ) ) {
961 throw new LogicException(
962 'Cannot use ' . __METHOD__ . ' with the ' . $textField . ' field since 1.35.'
963 );
964 }
965
966 // Missing text field, we are probably looking at the MCR-enabled DB schema.
967 $store = self::getRevisionStore( $wiki );
968 $rev = $prefix === 'ar_'
969 ? $store->newRevisionFromArchiveRow( $row )
970 : $store->newRevisionFromRow( $row );
971
972 $content = $rev->getContent( SlotRecord::MAIN );
973 return $content ? $content->serialize() : false;
974 }
975
988 public static function compressRevisionText( &$text ) {
989 wfDeprecated( __METHOD__, '1.31' );
990 return self::getBlobStore()->compressData( $text );
991 }
992
1002 public static function decompressRevisionText( $text, $flags ) {
1003 wfDeprecated( __METHOD__, '1.31' );
1004 if ( $text === false ) {
1005 // Text failed to be fetched; nothing to do
1006 return false;
1007 }
1008
1009 return self::getBlobStore()->decompressData( $text, $flags );
1010 }
1011
1022 public function insertOn( $dbw ) {
1023 wfDeprecated( __METHOD__, '1.31' );
1024
1025 global $wgUser;
1026
1027 // Note that $this->mRecord->getId() will typically return null here, but not always,
1028 // e.g. not when restoring a revision.
1029
1030 if ( $this->mRecord->getUser( RevisionRecord::RAW ) === null ) {
1031 if ( $this->mRecord instanceof MutableRevisionRecord ) {
1032 $this->mRecord->setUser( $wgUser );
1033 } else {
1034 throw new MWException( 'Cannot insert revision with no associated user.' );
1035 }
1036 }
1037
1038 $rec = self::getRevisionStore()->insertRevisionOn( $this->mRecord, $dbw );
1039
1040 $this->mRecord = $rec;
1041 Assert::postcondition( $this->mRecord !== null, 'Failed to acquire a RevisionRecord' );
1042
1043 return $rec->getId();
1044 }
1045
1052 public static function base36Sha1( $text ) {
1053 wfDeprecated( __METHOD__, '1.31' );
1054 return SlotRecord::base36Sha1( $text );
1055 }
1056
1074 public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
1075 wfDeprecated( __METHOD__, '1.35' );
1076
1077 if ( !$user ) {
1078 global $wgUser;
1079 $user = $wgUser;
1080 }
1081
1082 $comment = CommentStoreComment::newUnsavedComment( $summary, null );
1083
1084 $title = Title::newFromID( $pageId, Title::READ_LATEST );
1085 if ( $title === null ) {
1086 return null;
1087 }
1088
1089 $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
1090
1091 return $rec ? new Revision( $rec ) : null;
1092 }
1093
1106 public function userCan( $field, User $user = null ) {
1107 wfDeprecated( __METHOD__, '1.31' );
1108 if ( !$user ) {
1109 global $wgUser;
1110 $user = $wgUser;
1111 }
1112 return RevisionRecord::userCanBitfield( $this->mRecord->getVisibility(), $field, $user );
1113 }
1114
1129 public static function userCanBitfield( $bitfield, $field, User $user = null,
1130 Title $title = null
1131 ) {
1132 wfDeprecated( __METHOD__, '1.31' );
1133 if ( !$user ) {
1134 global $wgUser;
1135 $user = $wgUser;
1136 }
1137
1138 return RevisionRecord::userCanBitfield( $bitfield, $field, $user, $title );
1139 }
1140
1151 public static function getTimestampFromId( $title, $id, $flags = 0 ) {
1152 wfDeprecated( __METHOD__, '1.35' );
1153 return self::getRevisionStore()->getTimestampFromId( $id, $flags );
1154 }
1155
1165 public static function countByPageId( $db, $id ) {
1166 wfDeprecated( __METHOD__, '1.31' );
1167 return self::getRevisionStore()->countRevisionsByPageId( $db, $id );
1168 }
1169
1179 public static function countByTitle( $db, $title ) {
1180 wfDeprecated( __METHOD__, '1.31' );
1181 return self::getRevisionStore()->countRevisionsByTitle( $db, $title );
1182 }
1183
1200 public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
1201 wfDeprecated( __METHOD__, '1.24' );
1202 if ( is_int( $db ) ) {
1203 $db = wfGetDB( $db );
1204 }
1205
1206 return self::getRevisionStore()->userWasLastToEdit( $db, $pageId, $userId, $since );
1207 }
1208
1223 public static function newKnownCurrent( IDatabase $db, $pageIdOrTitle, $revId = 0 ) {
1224 wfDeprecated( __METHOD__, '1.31' );
1225 $title = $pageIdOrTitle instanceof Title
1226 ? $pageIdOrTitle
1227 : Title::newFromID( $pageIdOrTitle );
1228
1229 if ( !$title ) {
1230 return false;
1231 }
1232
1233 $record = self::getRevisionLookup()->getKnownCurrentRevision( $title, $revId );
1234 return $record ? new Revision( $record ) : false;
1235 }
1236}
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.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
MediaWiki exception.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Exception representing a failure to look up a revision.
Page revision base class.
Service for looking up page revisions.
Value object representing a content slot associated with a page revision.
Service for storing and loading Content objects.
getRecentChange( $flags=0)
Get the RC object belonging to the current revision, if there's one.
Definition Revision.php:741
getUserText( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's username if it's available to the specified audience.
Definition Revision.php:676
getTitle()
Returns the title of the page associated with this entry.
Definition Revision.php:598
getPrevious()
Get previous revision for this title.
Definition Revision.php:911
ensureTitle( $row, $queryFlags, $title=null)
Make sure we have some Title object for use by the constructor.
Definition Revision.php:409
getSize()
Returns the length of the text in this revision, or null if unknown.
Definition Revision.php:563
getSerializedData()
Get original serialized data (without checking view restrictions)
Definition Revision.php:811
getId()
Get revision ID.
Definition Revision.php:460
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
Definition Revision.php:988
static decompressRevisionText( $text, $flags)
Re-converts revision text according to it's flags.
setUserIdAndName( $id, $name)
Set the user ID/name.
Definition Revision.php:501
getContentHandler()
Returns the content handler appropriate for this revision's content model.
Definition Revision.php:876
static newKnownCurrent(IDatabase $db, $pageIdOrTitle, $revId=0)
Load a revision based on a known page ID and current revision ID from the DB.
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
Definition Revision.php:951
getComment( $audience=self::FOR_PUBLIC, User $user=null)
Definition Revision.php:700
static loadFromTitle( $db, $title, $id=0)
Load either the current, or a specified, revision that's attached to a given page.
Definition Revision.php:280
getNext()
Get next revision for this title.
Definition Revision.php:924
getTextId()
Get the ID of the row of the text table that contains the content of the revision's main slot,...
Definition Revision.php:535
static getRevisionStore( $wiki=false)
Definition Revision.php:64
static newFromPageId( $pageId, $revId=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given page ID.
Definition Revision.php:165
getMainSlotRaw()
Definition Revision.php:514
getContentFormat()
Returns the content format for the main slot of this revision.
Definition Revision.php:854
static loadFromTimestamp( $db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
Definition Revision.php:299
static getRevisionFactory()
Definition Revision.php:83
getPage()
Get the page ID.
Definition Revision.php:630
static getArchiveQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new archived revision objec...
Definition Revision.php:335
static newFromRow( $row)
Definition Revision.php:237
static newNullRevision( $dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
static getTimestampFromId( $title, $id, $flags=0)
Get rev_timestamp from rev_id, without loading the rest of the row.
RevisionRecord $mRecord
Definition Revision.php:43
getContentModel()
Returns the content model for the main slot of this revision.
Definition Revision.php:829
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.
Definition Revision.php:650
static newFromArchiveRow( $row, $overrides=[])
Make a fake revision object from an archive table row.
Definition Revision.php:183
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
Definition Revision.php:786
static countByTitle( $db, $title)
Get count of revisions per page...not very efficient.
const DELETED_USER
Definition Revision.php:48
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
Definition Revision.php:319
const TEXT_CACHE_GROUP
Definition Revision.php:58
const DELETED_TEXT
Definition Revision.php:46
static base36Sha1( $text)
Get the base 36 SHA-1 value for a string of text.
getSha1()
Returns the base36 sha1 of the content in this revision, or null if unknown.
Definition Revision.php:579
const DELETED_RESTRICTED
Definition Revision.php:49
static loadFromPageId( $db, $pageid, $id=0)
Load either the current, or a specified, revision that's attached to a given page.
Definition Revision.php:261
getTimestamp()
Definition Revision.php:889
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.
Definition Revision.php:765
setTitle( $title)
Set the title of the revision.
Definition Revision.php:612
insertOn( $dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
__construct( $row, $queryFlags=0, Title $title=null)
Definition Revision.php:365
static userWasLastToEdit( $db, $pageId, $userId, $since)
Check if no edits were made by other users since the time a user started editing the page.
getRevisionRecord()
Definition Revision.php:448
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
Definition Revision.php:350
static getRevisionLookup()
Definition Revision.php:76
isUnpatrolled()
Definition Revision.php:725
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision,...
const FOR_PUBLIC
Definition Revision.php:54
static getBlobStore( $wiki=false)
Definition Revision.php:92
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
Definition Revision.php:143
getParentId()
Get parent revision ID (the original previous page revision)
Definition Revision.php:551
const SUPPRESSED_ALL
Definition Revision.php:51
setId( $id)
Set the revision ID.
Definition Revision.php:478
const RAW
Definition Revision.php:56
isDeleted( $field)
Definition Revision.php:753
const DELETED_COMMENT
Definition Revision.php:47
const FOR_THIS_USER
Definition Revision.php:55
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition Revision.php:121
const SUPPRESSED_USER
Definition Revision.php:50
Represents a title within MediaWiki.
Definition Title.php:42
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:60
static newFromAnyId( $userId, $userName, $actorId, $dbDomain=false)
Static factory method for creation from an ID, name, and/or actor ID.
Definition User.php:616
const NS_SPECIAL
Definition Defines.php:59
Interface for database access objects.
Service for constructing revision objects.
Service for looking up page revisions.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
$content
Definition router.php:76