MediaWiki  master
Revision.php
Go to the documentation of this file.
1 <?php
33 use Wikimedia\Assert\Assert;
35 
40 class Revision implements IDBAccessObject {
41 
43  private $mRecord;
44 
45  // Revision deletion constants
52 
53  // Audience options for accessors
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 
410  private function ensureTitle( $row, $queryFlags, $title = null ) {
411  if ( $title ) {
412  return $title;
413  }
414 
415  if ( is_array( $row ) ) {
416  if ( isset( $row['title'] ) ) {
417  if ( !( $row['title'] instanceof Title ) ) {
418  throw new MWException( 'title field must contain a Title object.' );
419  }
420 
421  return $row['title'];
422  }
423 
424  $pageId = $row['page'] ?? 0;
425  $revId = $row['id'] ?? 0;
426  } else {
427  $pageId = $row->rev_page ?? 0;
428  $revId = $row->rev_id ?? 0;
429  }
430 
431  return self::getRevisionStore()->getTitle( $pageId, $revId, $queryFlags );
432  }
433 
438  public function getRevisionRecord() {
439  wfDeprecated( __METHOD__, '1.31' );
440  return $this->mRecord;
441  }
442 
450  public function getId() {
451  wfDeprecated( __METHOD__, '1.31' );
452  return $this->mRecord->getId();
453  }
454 
468  public function setId( $id ) {
469  wfDeprecated( __METHOD__, '1.31' );
470  if ( $this->mRecord instanceof MutableRevisionRecord ) {
471  $this->mRecord->setId( intval( $id ) );
472  } else {
473  throw new MWException( __METHOD__ . ' is not supported on this instance' );
474  }
475  }
476 
489  public function setUserIdAndName( $id, $name ) {
490  wfDeprecated( __METHOD__, '1.31' );
491  if ( $this->mRecord instanceof MutableRevisionRecord ) {
492  $user = User::newFromAnyId( intval( $id ), $name, null );
493  $this->mRecord->setUser( $user );
494  } else {
495  throw new MWException( __METHOD__ . ' is not supported on this instance' );
496  }
497  }
498 
502  private function getMainSlotRaw() {
503  if ( !$this->mRecord->hasSlot( SlotRecord::MAIN ) ) {
504  return null;
505  }
506 
507  return $this->mRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW );
508  }
509 
523  public function getTextId() {
524  wfDeprecated( __METHOD__, '1.31' );
525  $slot = $this->getMainSlotRaw();
526  return $slot && $slot->hasAddress()
527  ? self::getBlobStore()->getTextIdFromAddress( $slot->getAddress() )
528  : null;
529  }
530 
539  public function getParentId() {
540  wfDeprecated( __METHOD__, '1.31' );
541  return $this->mRecord->getParentId();
542  }
543 
551  public function getSize() {
552  wfDeprecated( __METHOD__, '1.31' );
553  try {
554  return $this->mRecord->getSize();
555  } catch ( RevisionAccessException $ex ) {
556  return null;
557  }
558  }
559 
567  public function getSha1() {
568  wfDeprecated( __METHOD__, '1.31' );
569  try {
570  return $this->mRecord->getSha1();
571  } catch ( RevisionAccessException $ex ) {
572  return null;
573  }
574  }
575 
586  public function getTitle() {
587  wfDeprecated( __METHOD__, '1.31' );
588  return Title::castFromPageIdentity( $this->mRecord->getPage() );
589  }
590 
599  public function setTitle( $title ) {
600  wfDeprecated( __METHOD__, '1.31' );
601  if ( !$title->equals( $this->getTitle() ) ) {
602  throw new InvalidArgumentException(
603  $title->getPrefixedText()
604  . ' is not the same as '
605  . $this->mRecord->getPageAsLinkTarget()->__toString()
606  );
607  }
608  }
609 
617  public function getPage() {
618  wfDeprecated( __METHOD__, '1.31' );
619  return $this->mRecord->getPageId();
620  }
621 
637  public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
638  wfDeprecated( __METHOD__, '1.31' );
639  if ( $audience === self::FOR_THIS_USER && !$user ) {
640  global $wgUser;
641  $user = $wgUser;
642  }
643 
644  $user = $this->mRecord->getUser( $audience, $user );
645  return $user ? $user->getId() : 0;
646  }
647 
663  public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
664  wfDeprecated( __METHOD__, '1.31' );
665  if ( $audience === self::FOR_THIS_USER && !$user ) {
666  global $wgUser;
667  $user = $wgUser;
668  }
669 
670  $user = $this->mRecord->getUser( $audience, $user );
671  return $user ? $user->getName() : '';
672  }
673 
687  public function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
688  wfDeprecated( __METHOD__, '1.31' );
689  if ( $audience === self::FOR_THIS_USER && !$user ) {
690  global $wgUser;
691  $user = $wgUser;
692  }
693 
694  $comment = $this->mRecord->getComment( $audience, $user );
695  return $comment === null ? null : $comment->text;
696  }
697 
703  public function isMinor() {
704  wfDeprecated( __METHOD__, '1.31' );
705  return $this->mRecord->isMinor();
706  }
707 
712  public function isUnpatrolled() {
713  wfDeprecated( __METHOD__, '1.31' );
714  return self::getRevisionStore()->getRcIdIfUnpatrolled( $this->mRecord );
715  }
716 
728  public function getRecentChange( $flags = 0 ) {
729  wfDeprecated( __METHOD__, '1.31' );
730  return self::getRevisionStore()->getRecentChange( $this->mRecord, $flags );
731  }
732 
740  public function isDeleted( $field ) {
741  wfDeprecated( __METHOD__, '1.31' );
742  return $this->mRecord->isDeleted( $field );
743  }
744 
752  public function getVisibility() {
753  wfDeprecated( __METHOD__, '1.31' );
754  return $this->mRecord->getVisibility();
755  }
756 
773  public function getContent( $audience = self::FOR_PUBLIC, User $user = null ) {
774  wfDeprecated( __METHOD__, '1.31' );
775 
776  global $wgUser;
777 
778  if ( $audience === self::FOR_THIS_USER && !$user ) {
779  $user = $wgUser;
780  }
781 
782  try {
783  return $this->mRecord->getContent( SlotRecord::MAIN, $audience, $user );
784  }
785  catch ( RevisionAccessException $e ) {
786  return null;
787  }
788  }
789 
798  public function getSerializedData() {
799  wfDeprecated( __METHOD__, '1.31' );
800  $slot = $this->getMainSlotRaw();
801  return $slot ? $slot->getContent()->serialize() : '';
802  }
803 
816  public function getContentModel() {
817  wfDeprecated( __METHOD__, '1.31' );
818 
819  $slot = $this->getMainSlotRaw();
820 
821  if ( $slot ) {
822  return $slot->getModel();
823  } else {
824  $slotRoleRegistry = MediaWikiServices::getInstance()->getSlotRoleRegistry();
825  $slotRoleHandler = $slotRoleRegistry->getRoleHandler( SlotRecord::MAIN );
826  return $slotRoleHandler->getDefaultModel( $this->getTitle() );
827  }
828  }
829 
841  public function getContentFormat() {
842  wfDeprecated( __METHOD__, '1.31' );
843 
844  $slot = $this->getMainSlotRaw();
845  $format = $slot ? $this->getMainSlotRaw()->getFormat() : null;
846 
847  if ( $format === null ) {
848  // if no format was stored along with the blob, fall back to default format
849  $format = $this->getContentHandler()->getDefaultFormat();
850  }
851 
852  return $format;
853  }
854 
863  public function getContentHandler() {
864  wfDeprecated( __METHOD__, '1.31' );
865 
866  return MediaWikiServices::getInstance()
867  ->getContentHandlerFactory()
868  ->getContentHandler( $this->getContentModel() );
869  }
870 
876  public function getTimestamp() {
877  wfDeprecated( __METHOD__, '1.31' );
878  return $this->mRecord->getTimestamp();
879  }
880 
886  public function isCurrent() {
887  wfDeprecated( __METHOD__, '1.31' );
888  return $this->mRecord->isCurrent();
889  }
890 
898  public function getPrevious() {
899  wfDeprecated( __METHOD__, '1.31' );
900  $rec = self::getRevisionLookup()->getPreviousRevision( $this->mRecord );
901  return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
902  }
903 
911  public function getNext() {
912  wfDeprecated( __METHOD__, '1.31' );
913  $rec = self::getRevisionLookup()->getNextRevision( $this->mRecord );
914  return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
915  }
916 
938  public static function getRevisionText( $row, $prefix = 'old_', $wiki = false ) {
939  wfDeprecated( __METHOD__, '1.32' );
940 
941  if ( !$row ) {
942  return false;
943  }
944 
945  $textField = $prefix . 'text';
946 
947  if ( isset( $row->$textField ) ) {
948  throw new LogicException(
949  'Cannot use ' . __METHOD__ . ' with the ' . $textField . ' field since 1.35.'
950  );
951  }
952 
953  // Missing text field, we are probably looking at the MCR-enabled DB schema.
954  $store = self::getRevisionStore( $wiki );
955  $rev = $prefix === 'ar_'
956  ? $store->newRevisionFromArchiveRow( $row )
957  : $store->newRevisionFromRow( $row );
958 
959  $content = $rev->getContent( SlotRecord::MAIN );
960  return $content ? $content->serialize() : false;
961  }
962 
975  public static function compressRevisionText( &$text ) {
976  wfDeprecated( __METHOD__, '1.31' );
977  return self::getBlobStore()->compressData( $text );
978  }
979 
989  public static function decompressRevisionText( $text, $flags ) {
990  wfDeprecated( __METHOD__, '1.31' );
991  if ( $text === false ) {
992  // Text failed to be fetched; nothing to do
993  return false;
994  }
995 
996  return self::getBlobStore()->decompressData( $text, $flags );
997  }
998 
1009  public function insertOn( $dbw ) {
1010  wfDeprecated( __METHOD__, '1.31' );
1011 
1012  global $wgUser;
1013 
1014  // Note that $this->mRecord->getId() will typically return null here, but not always,
1015  // e.g. not when restoring a revision.
1016 
1017  if ( $this->mRecord->getUser( RevisionRecord::RAW ) === null ) {
1018  if ( $this->mRecord instanceof MutableRevisionRecord ) {
1019  $this->mRecord->setUser( $wgUser );
1020  } else {
1021  throw new MWException( 'Cannot insert revision with no associated user.' );
1022  }
1023  }
1024 
1025  $rec = self::getRevisionStore()->insertRevisionOn( $this->mRecord, $dbw );
1026 
1027  $this->mRecord = $rec;
1028  Assert::postcondition( $this->mRecord !== null, 'Failed to acquire a RevisionRecord' );
1029 
1030  return $rec->getId();
1031  }
1032 
1039  public static function base36Sha1( $text ) {
1040  wfDeprecated( __METHOD__, '1.31' );
1041  return SlotRecord::base36Sha1( $text );
1042  }
1043 
1061  public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
1062  wfDeprecated( __METHOD__, '1.35' );
1063 
1064  if ( !$user ) {
1065  global $wgUser;
1066  $user = $wgUser;
1067  }
1068 
1069  $comment = CommentStoreComment::newUnsavedComment( $summary, null );
1070 
1071  $title = Title::newFromID( $pageId, Title::READ_LATEST );
1072  if ( $title === null ) {
1073  return null;
1074  }
1075 
1076  $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
1077 
1078  return $rec ? new Revision( $rec ) : null;
1079  }
1080 
1093  public function userCan( $field, User $user = null ) {
1094  wfDeprecated( __METHOD__, '1.31' );
1095  if ( !$user ) {
1096  global $wgUser;
1097  $user = $wgUser;
1098  }
1099  return $this->mRecord->userCan( $field, $user );
1100  }
1101 
1116  public static function userCanBitfield( $bitfield, $field, User $user = null,
1117  Title $title = null
1118  ) {
1119  wfDeprecated( __METHOD__, '1.31' );
1120  if ( !$user ) {
1121  global $wgUser;
1122  $user = $wgUser;
1123  }
1124 
1125  return RevisionRecord::userCanBitfield( $bitfield, $field, $user, $title );
1126  }
1127 
1138  public static function getTimestampFromId( $title, $id, $flags = 0 ) {
1139  wfDeprecated( __METHOD__, '1.35' );
1140  return self::getRevisionStore()->getTimestampFromId( $id, $flags );
1141  }
1142 
1152  public static function countByPageId( $db, $id ) {
1153  wfDeprecated( __METHOD__, '1.31' );
1154  return self::getRevisionStore()->countRevisionsByPageId( $db, $id );
1155  }
1156 
1166  public static function countByTitle( $db, $title ) {
1167  wfDeprecated( __METHOD__, '1.31' );
1168  return self::getRevisionStore()->countRevisionsByTitle( $db, $title );
1169  }
1170 
1187  public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
1188  wfDeprecated( __METHOD__, '1.24' );
1189  if ( is_int( $db ) ) {
1190  $db = wfGetDB( $db );
1191  }
1192 
1193  return self::getRevisionStore()->userWasLastToEdit( $db, $pageId, $userId, $since );
1194  }
1195 
1210  public static function newKnownCurrent( IDatabase $db, $pageIdOrTitle, $revId = 0 ) {
1211  wfDeprecated( __METHOD__, '1.31' );
1212  $title = $pageIdOrTitle instanceof Title
1213  ? $pageIdOrTitle
1214  : Title::newFromID( $pageIdOrTitle );
1215 
1216  if ( !$title ) {
1217  return false;
1218  }
1219 
1220  $record = self::getRevisionLookup()->getKnownCurrentRevision( $title, $revId );
1221  return $record ? new Revision( $record ) : false;
1222  }
1223 }
Revision\FOR_PUBLIC
const FOR_PUBLIC
Definition: Revision.php:54
Revision\newFromArchiveRow
static newFromArchiveRow( $row, $overrides=[])
Make a fake revision object from an archive table row.
Definition: Revision.php:183
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:48
Revision\getTimestamp
getTimestamp()
Definition: Revision.php:876
CommentStoreComment\newUnsavedComment
static newUnsavedComment( $comment, array $data=null)
Create a new, unsaved CommentStoreComment.
Definition: CommentStoreComment.php:67
Revision\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: Revision.php:49
Revision\RevisionAccessException
Exception representing a failure to look up a revision.
Definition: RevisionAccessException.php:34
Revision\newKnownCurrent
static newKnownCurrent(IDatabase $db, $pageIdOrTitle, $revId=0)
Load a revision based on a known page ID and current revision ID from the DB.
Definition: Revision.php:1210
Revision\getUserText
getUserText( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's username if it's available to the specified audience.
Definition: Revision.php:663
Revision\RevisionRecord
Page revision base class.
Definition: RevisionRecord.php:47
Revision\SUPPRESSED_ALL
const SUPPRESSED_ALL
Definition: Revision.php:51
Revision\DELETED_COMMENT
const DELETED_COMMENT
Definition: Revision.php:47
Revision\newFromId
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition: Revision.php:121
Revision\getUser
getUser( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's user id if it's available to the specified audience.
Definition: Revision.php:637
Revision\userCanBitfield
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,...
Definition: Revision.php:1116
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:173
Revision\getSize
getSize()
Returns the length of the text in this revision, or null if unknown.
Definition: Revision.php:551
Revision\RevisionStore
Service for looking up page revisions.
Definition: RevisionStore.php:89
MediaWiki\Storage\SqlBlobStore
Service for storing and loading Content objects.
Definition: SqlBlobStore.php:51
Revision\setId
setId( $id)
Set the revision ID.
Definition: Revision.php:468
Revision\getContent
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
Definition: Revision.php:773
Revision\getPage
getPage()
Get the page ID.
Definition: Revision.php:617
Revision\getBlobStore
static getBlobStore( $wiki=false)
Definition: Revision.php:92
Revision\getRevisionText
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
Definition: Revision.php:938
Revision\getParentId
getParentId()
Get parent revision ID (the original previous page revision)
Definition: Revision.php:539
Revision\setTitle
setTitle( $title)
Set the title of the revision.
Definition: Revision.php:599
Revision\getContentHandler
getContentHandler()
Returns the content handler appropriate for this revision's content model.
Definition: Revision.php:863
Revision\RevisionFactory
Service for constructing revision objects.
Definition: RevisionFactory.php:38
Revision\getArchiveQueryInfo
static getArchiveQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new archived revision objec...
Definition: Revision.php:335
Revision\getSerializedData
getSerializedData()
Get original serialized data (without checking view restrictions)
Definition: Revision.php:798
Revision\getRecentChange
getRecentChange( $flags=0)
Get the RC object belonging to the current revision, if there's one.
Definition: Revision.php:728
Revision\TEXT_CACHE_GROUP
const TEXT_CACHE_GROUP
Definition: Revision.php:58
Revision\isCurrent
isCurrent()
Definition: Revision.php:886
Revision\newFromPageId
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
Revision\getSha1
getSha1()
Returns the base36 sha1 of the content in this revision, or null if unknown.
Definition: Revision.php:567
IDBAccessObject
Interface for database access objects.
Definition: IDBAccessObject.php:57
Revision\getId
getId()
Get revision ID.
Definition: Revision.php:450
Revision\getContentModel
getContentModel()
Returns the content model for the main slot of this revision.
Definition: Revision.php:816
Revision\insertOn
insertOn( $dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
Definition: Revision.php:1009
Revision\getRevisionFactory
static getRevisionFactory()
Definition: Revision.php:83
Revision\base36Sha1
static base36Sha1( $text)
Get the base 36 SHA-1 value for a string of text.
Definition: Revision.php:1039
Revision\RevisionLookup
Service for looking up page revisions.
Definition: RevisionLookup.php:38
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
Title\castFromPageIdentity
static castFromPageIdentity(?PageIdentity $pageIdentity)
Return a Title for a given PageIdentity.
Definition: Title.php:328
Revision\FOR_THIS_USER
const FOR_THIS_USER
Definition: Revision.php:55
Revision
Definition: Revision.php:40
Revision\newFromTitle
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
Revision\SUPPRESSED_USER
const SUPPRESSED_USER
Definition: Revision.php:50
Revision\getQueryInfo
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
Definition: Revision.php:319
MWException
MediaWiki exception.
Definition: MWException.php:29
Revision\getNext
getNext()
Get next revision for this title.
Definition: Revision.php:911
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Definition: GlobalFunctions.php:1034
Revision\setUserIdAndName
setUserIdAndName( $id, $name)
This should only be used for proposed revisions that turn out to be null edits.
Definition: Revision.php:489
Revision\getTimestampFromId
static getTimestampFromId( $title, $id, $flags=0)
Get rev_timestamp from rev_id, without loading the rest of the row.
Definition: Revision.php:1138
Revision\isUnpatrolled
isUnpatrolled()
Definition: Revision.php:712
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2467
Revision\loadFromPageId
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
Revision\compressRevisionText
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
Definition: Revision.php:975
Revision\RevisionRecord\RAW
const RAW
Definition: RevisionRecord.php:64
$title
$title
Definition: testCompression.php:38
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:626
User\newFromAnyId
static newFromAnyId( $userId, $userName, $actorId, $dbDomain=false)
Static factory method for creation from an ID, name, and/or actor ID.
Definition: User.php:692
Revision\SlotRecord\base36Sha1
static base36Sha1( $blob)
Get the base 36 SHA-1 value for a string of text.
Definition: SlotRecord.php:629
Revision\countByTitle
static countByTitle( $db, $title)
Get count of revisions per page...not very efficient.
Definition: Revision.php:1166
Revision\getPrevious
getPrevious()
Get previous revision for this title.
Definition: Revision.php:898
Revision\countByPageId
static countByPageId( $db, $id)
Get count of revisions per page...not very efficient.
Definition: Revision.php:1152
Revision\getRevisionStore
static getRevisionStore( $wiki=false)
Definition: Revision.php:64
Revision\ensureTitle
ensureTitle( $row, $queryFlags, $title=null)
Make sure we have some Title object for use by the constructor.
Definition: Revision.php:410
Revision\getTitle
getTitle()
Returns the title of the page associated with this entry.
Definition: Revision.php:586
Revision\userWasLastToEdit
static userWasLastToEdit( $db, $pageId, $userId, $since)
Check if no edits were made by other users since the time a user started editing the page.
Definition: Revision.php:1187
Revision\RevisionRecord\SUPPRESSED_USER
const SUPPRESSED_USER
Definition: RevisionRecord.php:57
$content
$content
Definition: router.php:76
Revision\RevisionRecord\DELETED_USER
const DELETED_USER
Definition: RevisionRecord.php:55
Revision\$mRecord
RevisionRecord $mRecord
Definition: Revision.php:43
Revision\MutableRevisionRecord
Definition: MutableRevisionRecord.php:45
Revision\getParentLengths
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
Definition: Revision.php:350
Revision\getVisibility
getVisibility()
Get the deletion bitfield of the revision.
Definition: Revision.php:752
Revision\getTextId
getTextId()
Get the ID of the row of the text table that contains the content of the revision's main slot,...
Definition: Revision.php:523
Revision\isDeleted
isDeleted( $field)
Definition: Revision.php:740
Revision\newFromRow
static newFromRow( $row)
Definition: Revision.php:237
Revision\RAW
const RAW
Definition: Revision.php:56
Revision\SlotRecord\MAIN
const MAIN
Definition: SlotRecord.php:43
Revision\getMainSlotRaw
getMainSlotRaw()
Definition: Revision.php:502
Revision\getContentFormat
getContentFormat()
Returns the content format for the main slot of this revision.
Definition: Revision.php:841
Revision\RevisionRecord\FOR_PUBLIC
const FOR_PUBLIC
Definition: RevisionRecord.php:62
Title
Represents a title within MediaWiki.
Definition: Title.php:46
Revision\RevisionRecord\DELETED_COMMENT
const DELETED_COMMENT
Definition: RevisionRecord.php:54
Revision\RevisionRecord\DELETED_TEXT
const DELETED_TEXT
Definition: RevisionRecord.php:53
Revision\loadFromTimestamp
static loadFromTimestamp( $db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
Definition: Revision.php:299
Revision\getComment
getComment( $audience=self::FOR_PUBLIC, User $user=null)
Definition: Revision.php:687
Revision\newNullRevision
static newNullRevision( $dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
Definition: Revision.php:1061
Revision\__construct
__construct( $row, $queryFlags=0, Title $title=null)
Definition: Revision.php:365
Revision\RevisionRecord\userCanBitfield
static userCanBitfield( $bitfield, $field, Authority $performer, PageIdentity $page=null)
Determine if the current user is allowed to view a particular field of this revision,...
Definition: RevisionRecord.php:545
Revision\isMinor
isMinor()
Definition: Revision.php:703
Revision\RevisionRecord\SUPPRESSED_ALL
const SUPPRESSED_ALL
Definition: RevisionRecord.php:58
Revision\RevisionRecord\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: RevisionRecord.php:56
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
Revision\getRevisionRecord
getRevisionRecord()
Definition: Revision.php:438
Revision\decompressRevisionText
static decompressRevisionText( $text, $flags)
Re-converts revision text according to it's flags.
Definition: Revision.php:989
Revision\loadFromTitle
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
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:66
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:507
Revision\RevisionRecord\FOR_THIS_USER
const FOR_THIS_USER
Definition: RevisionRecord.php:63
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:46
Revision\userCan
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision,...
Definition: Revision.php:1093
Revision\SlotRecord
Value object representing a content slot associated with a page revision.
Definition: SlotRecord.php:40
Revision\getRevisionLookup
static getRevisionLookup()
Definition: Revision.php:76