MediaWiki  master
Revision.php
Go to the documentation of this file.
1 <?php
36 
40 class Revision implements IDBAccessObject {
41 
43  protected $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  protected 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  protected static function getRevisionLookup() {
77  return MediaWikiServices::getInstance()->getRevisionLookup();
78  }
79 
83  protected static function getRevisionFactory() {
84  return MediaWikiServices::getInstance()->getRevisionFactory();
85  }
86 
92  protected static function getBlobStore( $wiki = false ) {
93  // @phan-suppress-next-line PhanAccessMethodInternal
94  $store = MediaWikiServices::getInstance()
95  ->getBlobStoreFactory()
96  ->newSqlBlobStore( $wiki );
97 
98  if ( !$store instanceof SqlBlobStore ) {
99  throw new RuntimeException(
100  'The backwards compatibility code in Revision currently requires the BlobStore '
101  . 'service to be an SqlBlobStore instance, but it is a ' . get_class( $store )
102  );
103  }
104 
105  return $store;
106  }
107 
120  public static function newFromId( $id, $flags = 0 ) {
121  $rec = self::getRevisionLookup()->getRevisionById( $id, $flags );
122  return $rec ? new Revision( $rec, $flags ) : null;
123  }
124 
139  public static function newFromTitle( LinkTarget $linkTarget, $id = 0, $flags = 0 ) {
140  $rec = self::getRevisionLookup()->getRevisionByTitle( $linkTarget, $id, $flags );
141  return $rec ? new Revision( $rec, $flags ) : null;
142  }
143 
158  public static function newFromPageId( $pageId, $revId = 0, $flags = 0 ) {
159  $rec = self::getRevisionLookup()->getRevisionByPageId( $pageId, $revId, $flags );
160  return $rec ? new Revision( $rec, $flags ) : null;
161  }
162 
173  public static function newFromArchiveRow( $row, $overrides = [] ) {
180  if ( array_key_exists( 'page', $overrides ) ) {
181  $overrides['page_id'] = $overrides['page'];
182  unset( $overrides['page'] );
183  }
184 
190  $title = null;
191  if ( isset( $overrides['title'] ) ) {
192  if ( !( $overrides['title'] instanceof Title ) ) {
193  throw new MWException( 'title field override must contain a Title object.' );
194  }
195 
196  $title = $overrides['title'];
197  }
198  if ( $title !== null ) {
199  if ( isset( $row->ar_namespace ) && isset( $row->ar_title ) ) {
200  $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
201  } else {
202  throw new InvalidArgumentException(
203  'A Title or ar_namespace and ar_title must be given'
204  );
205  }
206  }
207 
208  $rec = self::getRevisionFactory()->newRevisionFromArchiveRow( $row, 0, $title, $overrides );
209  return new Revision( $rec, self::READ_NORMAL, $title );
210  }
211 
224  public static function newFromRow( $row ) {
225  if ( is_array( $row ) ) {
226  $rec = self::getRevisionFactory()->newMutableRevisionFromArray( $row );
227  } else {
228  $rec = self::getRevisionFactory()->newRevisionFromRow( $row );
229  }
230 
231  return new Revision( $rec );
232  }
233 
244  public static function loadFromId( $db, $id ) {
245  wfDeprecated( __METHOD__, '1.31' ); // no known callers
246  $rec = self::getRevisionStore()->loadRevisionFromId( $db, $id );
247  return $rec ? new Revision( $rec ) : null;
248  }
249 
262  public static function loadFromPageId( $db, $pageid, $id = 0 ) {
263  $rec = self::getRevisionStore()->loadRevisionFromPageId( $db, $pageid, $id );
264  return $rec ? new Revision( $rec ) : null;
265  }
266 
279  public static function loadFromTitle( $db, $title, $id = 0 ) {
280  $rec = self::getRevisionStore()->loadRevisionFromTitle( $db, $title, $id );
281  return $rec ? new Revision( $rec ) : null;
282  }
283 
297  public static function loadFromTimestamp( $db, $title, $timestamp ) {
298  $rec = self::getRevisionStore()->loadRevisionFromTimestamp( $db, $title, $timestamp );
299  return $rec ? new Revision( $rec ) : null;
300  }
301 
316  public static function getQueryInfo( $options = [] ) {
317  return self::getRevisionStore()->getQueryInfo( $options );
318  }
319 
330  public static function getArchiveQueryInfo() {
331  return self::getRevisionStore()->getArchiveQueryInfo();
332  }
333 
343  public static function getParentLengths( $db, array $revIds ) {
344  return self::getRevisionStore()->listRevisionSizes( $db, $revIds );
345  }
346 
354  function __construct( $row, $queryFlags = 0, Title $title = null ) {
355  global $wgUser;
356 
357  if ( $row instanceof RevisionRecord ) {
358  $this->mRecord = $row;
359  } elseif ( is_array( $row ) ) {
360  // If no user is specified, fall back to using the global user object, to stay
361  // compatible with pre-1.31 behavior.
362  if ( !isset( $row['user'] ) && !isset( $row['user_text'] ) ) {
363  $row['user'] = $wgUser;
364  }
365 
366  $this->mRecord = self::getRevisionFactory()->newMutableRevisionFromArray(
367  $row,
368  $queryFlags,
369  $this->ensureTitle( $row, $queryFlags, $title )
370  );
371  } elseif ( is_object( $row ) ) {
372  $this->mRecord = self::getRevisionFactory()->newRevisionFromRow(
373  $row,
374  $queryFlags,
375  $this->ensureTitle( $row, $queryFlags, $title )
376  );
377  } else {
378  throw new InvalidArgumentException(
379  '$row must be a row object, an associative array, or a RevisionRecord'
380  );
381  }
382 
383  Assert::postcondition( $this->mRecord !== null, 'Failed to construct a RevisionRecord' );
384  }
385 
396  private function ensureTitle( $row, $queryFlags, $title = null ) {
397  if ( $title ) {
398  return $title;
399  }
400 
401  if ( is_array( $row ) ) {
402  if ( isset( $row['title'] ) ) {
403  if ( !( $row['title'] instanceof Title ) ) {
404  throw new MWException( 'title field must contain a Title object.' );
405  }
406 
407  return $row['title'];
408  }
409 
410  $pageId = $row['page'] ?? 0;
411  $revId = $row['id'] ?? 0;
412  } else {
413  $pageId = $row->rev_page ?? 0;
414  $revId = $row->rev_id ?? 0;
415  }
416 
417  try {
418  $title = self::getRevisionStore()->getTitle( $pageId, $revId, $queryFlags );
419  } catch ( RevisionAccessException $ex ) {
420  // construct a dummy title!
421  wfLogWarning( __METHOD__ . ': ' . $ex->getMessage() );
422 
423  // NOTE: this Title will only be used inside RevisionRecord
424  $title = Title::makeTitleSafe( NS_SPECIAL, "Badtitle/ID=$pageId" );
425  $title->resetArticleID( $pageId );
426  }
427 
428  return $title;
429  }
430 
434  public function getRevisionRecord() {
435  return $this->mRecord;
436  }
437 
443  public function getId() {
444  return $this->mRecord->getId();
445  }
446 
459  public function setId( $id ) {
460  if ( $this->mRecord instanceof MutableRevisionRecord ) {
461  $this->mRecord->setId( intval( $id ) );
462  } else {
463  throw new MWException( __METHOD__ . ' is not supported on this instance' );
464  }
465  }
466 
481  public function setUserIdAndName( $id, $name ) {
482  if ( $this->mRecord instanceof MutableRevisionRecord ) {
483  $user = User::newFromAnyId( intval( $id ), $name, null );
484  $this->mRecord->setUser( $user );
485  } else {
486  throw new MWException( __METHOD__ . ' is not supported on this instance' );
487  }
488  }
489 
493  private function getMainSlotRaw() {
494  return $this->mRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW );
495  }
496 
509  public function getTextId() {
510  $slot = $this->getMainSlotRaw();
511  return $slot->hasAddress()
512  ? self::getBlobStore()->getTextIdFromAddress( $slot->getAddress() )
513  : null;
514  }
515 
522  public function getParentId() {
523  return $this->mRecord->getParentId();
524  }
525 
531  public function getSize() {
532  try {
533  return $this->mRecord->getSize();
534  } catch ( RevisionAccessException $ex ) {
535  return null;
536  }
537  }
538 
544  public function getSha1() {
545  try {
546  return $this->mRecord->getSha1();
547  } catch ( RevisionAccessException $ex ) {
548  return null;
549  }
550  }
551 
560  public function getTitle() {
561  $linkTarget = $this->mRecord->getPageAsLinkTarget();
562  return Title::newFromLinkTarget( $linkTarget );
563  }
564 
572  public function setTitle( $title ) {
573  if ( !$title->equals( $this->getTitle() ) ) {
574  throw new InvalidArgumentException(
575  $title->getPrefixedText()
576  . ' is not the same as '
577  . $this->mRecord->getPageAsLinkTarget()->__toString()
578  );
579  }
580  }
581 
587  public function getPage() {
588  return $this->mRecord->getPageId();
589  }
590 
604  public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
605  global $wgUser;
606 
607  if ( $audience === self::FOR_THIS_USER && !$user ) {
608  $user = $wgUser;
609  }
610 
611  $user = $this->mRecord->getUser( $audience, $user );
612  return $user ? $user->getId() : 0;
613  }
614 
628  public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
629  global $wgUser;
630 
631  if ( $audience === self::FOR_THIS_USER && !$user ) {
632  $user = $wgUser;
633  }
634 
635  $user = $this->mRecord->getUser( $audience, $user );
636  return $user ? $user->getName() : '';
637  }
638 
650  function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
651  global $wgUser;
652 
653  if ( $audience === self::FOR_THIS_USER && !$user ) {
654  $user = $wgUser;
655  }
656 
657  $comment = $this->mRecord->getComment( $audience, $user );
658  return $comment === null ? null : $comment->text;
659  }
660 
664  public function isMinor() {
665  return $this->mRecord->isMinor();
666  }
667 
671  public function isUnpatrolled() {
672  return self::getRevisionStore()->getRcIdIfUnpatrolled( $this->mRecord );
673  }
674 
684  public function getRecentChange( $flags = 0 ) {
685  return self::getRevisionStore()->getRecentChange( $this->mRecord, $flags );
686  }
687 
693  public function isDeleted( $field ) {
694  return $this->mRecord->isDeleted( $field );
695  }
696 
702  public function getVisibility() {
703  return $this->mRecord->getVisibility();
704  }
705 
720  public function getContent( $audience = self::FOR_PUBLIC, User $user = null ) {
721  global $wgUser;
722 
723  if ( $audience === self::FOR_THIS_USER && !$user ) {
724  $user = $wgUser;
725  }
726 
727  try {
728  return $this->mRecord->getContent( SlotRecord::MAIN, $audience, $user );
729  }
730  catch ( RevisionAccessException $e ) {
731  return null;
732  }
733  }
734 
743  public function getSerializedData() {
744  $slot = $this->getMainSlotRaw();
745  return $slot->getContent()->serialize();
746  }
747 
760  public function getContentModel() {
761  return $this->getMainSlotRaw()->getModel();
762  }
763 
775  public function getContentFormat() {
776  $format = $this->getMainSlotRaw()->getFormat();
777 
778  if ( $format === null ) {
779  // if no format was stored along with the blob, fall back to default format
780  $format = $this->getContentHandler()->getDefaultFormat();
781  }
782 
783  return $format;
784  }
785 
792  public function getContentHandler() {
794  }
795 
799  public function getTimestamp() {
800  return $this->mRecord->getTimestamp();
801  }
802 
806  public function isCurrent() {
807  return ( $this->mRecord instanceof RevisionStoreRecord ) && $this->mRecord->isCurrent();
808  }
809 
815  public function getPrevious() {
816  $rec = self::getRevisionLookup()->getPreviousRevision( $this->mRecord );
817  return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
818  }
819 
825  public function getNext() {
826  $rec = self::getRevisionLookup()->getNextRevision( $this->mRecord );
827  return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
828  }
829 
851  public static function getRevisionText( $row, $prefix = 'old_', $wiki = false ) {
852  wfDeprecated( __METHOD__, '1.32' );
854 
855  if ( !$row ) {
856  return false;
857  }
858 
859  $textField = $prefix . 'text';
860  $flagsField = $prefix . 'flags';
861 
862  if ( isset( $row->$textField ) ) {
863  if ( !( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) ) {
864  // The text field was read, but it's no longer being populated!
865  // We could gloss over this by using the text when it's there and loading
866  // if when it's not, but it seems preferable to complain loudly about a
867  // query that is no longer guaranteed to work reliably.
868  throw new LogicException(
869  'Cannot use ' . __METHOD__ . ' with the ' . $textField . ' field when'
870  . ' $wgMultiContentRevisionSchemaMigrationStage does not include'
871  . ' SCHEMA_COMPAT_WRITE_OLD. The field may not be populated for all revisions!'
872  );
873  }
874 
875  $text = $row->$textField;
876  } else {
877  // Missing text field, we are probably looking at the MCR-enabled DB schema.
878  $store = self::getRevisionStore( $wiki );
879  $rev = $prefix === 'ar_'
880  ? $store->newRevisionFromArchiveRow( $row )
881  : $store->newRevisionFromRow( $row );
882 
883  $content = $rev->getContent( SlotRecord::MAIN );
884  return $content ? $content->serialize() : false;
885  }
886 
887  if ( isset( $row->$flagsField ) ) {
888  $flags = explode( ',', $row->$flagsField );
889  } else {
890  $flags = [];
891  }
892 
893  $cacheKey = isset( $row->old_id )
894  ? SqlBlobStore::makeAddressFromTextId( $row->old_id )
895  : null;
896 
897  $revisionText = self::getBlobStore( $wiki )->expandBlob( $text, $flags, $cacheKey );
898 
899  if ( $revisionText === false ) {
900  if ( isset( $row->old_id ) ) {
901  wfLogWarning( __METHOD__ . ": Bad data in text row {$row->old_id}! " );
902  } else {
903  wfLogWarning( __METHOD__ . ": Bad data in text row! " );
904  }
905  return false;
906  }
907 
908  return $revisionText;
909  }
910 
921  public static function compressRevisionText( &$text ) {
922  return self::getBlobStore()->compressData( $text );
923  }
924 
932  public static function decompressRevisionText( $text, $flags ) {
933  if ( $text === false ) {
934  // Text failed to be fetched; nothing to do
935  return false;
936  }
937 
938  return self::getBlobStore()->decompressData( $text, $flags );
939  }
940 
949  public function insertOn( $dbw ) {
950  global $wgUser;
951 
952  // Note that $this->mRecord->getId() will typically return null here, but not always,
953  // e.g. not when restoring a revision.
954 
955  if ( $this->mRecord->getUser( RevisionRecord::RAW ) === null ) {
956  if ( $this->mRecord instanceof MutableRevisionRecord ) {
957  $this->mRecord->setUser( $wgUser );
958  } else {
959  throw new MWException( 'Cannot insert revision with no associated user.' );
960  }
961  }
962 
963  $rec = self::getRevisionStore()->insertRevisionOn( $this->mRecord, $dbw );
964 
965  $this->mRecord = $rec;
966  Assert::postcondition( $this->mRecord !== null, 'Failed to acquire a RevisionRecord' );
967 
968  return $rec->getId();
969  }
970 
976  public static function base36Sha1( $text ) {
977  return SlotRecord::base36Sha1( $text );
978  }
979 
995  public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
996  global $wgUser;
997  if ( !$user ) {
998  $user = $wgUser;
999  }
1000 
1001  $comment = CommentStoreComment::newUnsavedComment( $summary, null );
1002 
1003  $title = Title::newFromID( $pageId, Title::READ_LATEST );
1004  if ( $title === null ) {
1005  return null;
1006  }
1007 
1008  $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
1009 
1010  return $rec ? new Revision( $rec ) : null;
1011  }
1012 
1023  public function userCan( $field, User $user = null ) {
1024  return self::userCanBitfield( $this->getVisibility(), $field, $user );
1025  }
1026 
1041  public static function userCanBitfield( $bitfield, $field, User $user = null,
1042  Title $title = null
1043  ) {
1044  global $wgUser;
1045 
1046  if ( !$user ) {
1047  $user = $wgUser;
1048  }
1049 
1050  return RevisionRecord::userCanBitfield( $bitfield, $field, $user, $title );
1051  }
1052 
1061  static function getTimestampFromId( $title, $id, $flags = 0 ) {
1062  return self::getRevisionStore()->getTimestampFromId( $id, $flags );
1063  }
1064 
1072  static function countByPageId( $db, $id ) {
1073  return self::getRevisionStore()->countRevisionsByPageId( $db, $id );
1074  }
1075 
1083  static function countByTitle( $db, $title ) {
1084  return self::getRevisionStore()->countRevisionsByTitle( $db, $title );
1085  }
1086 
1103  public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
1104  if ( is_int( $db ) ) {
1105  $db = wfGetDB( $db );
1106  }
1107 
1108  return self::getRevisionStore()->userWasLastToEdit( $db, $pageId, $userId, $since );
1109  }
1110 
1124  public static function newKnownCurrent( IDatabase $db, $pageIdOrTitle, $revId = 0 ) {
1125  $title = $pageIdOrTitle instanceof Title
1126  ? $pageIdOrTitle
1127  : Title::newFromID( $pageIdOrTitle );
1128 
1129  if ( !$title ) {
1130  return false;
1131  }
1132 
1133  $record = self::getRevisionLookup()->getKnownCurrentRevision( $title, $revId );
1134  return $record ? new Revision( $record ) : false;
1135  }
1136 }
const SCHEMA_COMPAT_WRITE_OLD
Definition: Defines.php:264
Service for storing and loading Content objects.
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision, if it&#39;s marked as deleted.
Definition: Revision.php:1023
getUserText( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision&#39;s username if it&#39;s available to the specified audience.
Definition: Revision.php:628
const FOR_THIS_USER
Definition: Revision.php:55
static newFromArchiveRow( $row, $overrides=[])
Make a fake revision object from an archive table row.
Definition: Revision.php:173
const TEXT_CACHE_GROUP
Definition: Revision.php:58
A RevisionRecord representing an existing revision persisted in the revision table.
static getTimestampFromId( $title, $id, $flags=0)
Get rev_timestamp from rev_id, without loading the rest of the row.
Definition: Revision.php:1061
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:465
getRevisionRecord()
Definition: Revision.php:434
getPage()
Get the page ID.
Definition: Revision.php:587
static countByPageId( $db, $id)
Get count of revisions per page...not very efficient.
Definition: Revision.php:1072
int $wgMultiContentRevisionSchemaMigrationStage
RevisionStore table schema migration stage (content, slots, content_models & slot_roles tables)...
getTimestamp()
Definition: Revision.php:799
setTitle( $title)
Set the title of the revision.
Definition: Revision.php:572
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static loadFromTimestamp( $db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
Definition: Revision.php:297
static newFromAnyId( $userId, $userName, $actorId, $dbDomain=false)
Static factory method for creation from an ID, name, and/or actor ID.
Definition: User.php:617
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
Definition: Revision.php:343
static getRevisionLookup()
Definition: Revision.php:76
setUserIdAndName( $id, $name)
Set the user ID/name.
Definition: Revision.php:481
const NS_SPECIAL
Definition: Defines.php:49
static newFromPageId( $pageId, $revId=0, $flags=0)
Load either the current, or a specified, revision that&#39;s attached to a given page ID...
Definition: Revision.php:158
getRecentChange( $flags=0)
Get the RC object belonging to the current revision, if there&#39;s one.
Definition: Revision.php:684
static loadFromPageId( $db, $pageid, $id=0)
Load either the current, or a specified, revision that&#39;s attached to a given page.
Definition: Revision.php:262
isUnpatrolled()
Definition: Revision.php:671
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it&#39;s available to the specified audience.
Definition: Revision.php:720
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:1103
static decompressRevisionText( $text, $flags)
Re-converts revision text according to it&#39;s flags.
Definition: Revision.php:932
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that&#39;s attached to a given link target...
Definition: Revision.php:139
static newUnsavedComment( $comment, array $data=null)
Create a new, unsaved CommentStoreComment.
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
Definition: Revision.php:851
getSerializedData()
Get original serialized data (without checking view restrictions)
Definition: Revision.php:743
getMainSlotRaw()
Definition: Revision.php:493
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
Definition: User.php:51
static getRevisionStore( $wiki=false)
Definition: Revision.php:64
RevisionRecord $mRecord
Definition: Revision.php:43
getTitle()
Returns the title of the page associated with this entry.
Definition: Revision.php:560
getParentId()
Get parent revision ID (the original previous page revision)
Definition: Revision.php:522
getUser( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision&#39;s user id if it&#39;s available to the specified audience.
Definition: Revision.php:604
const FOR_PUBLIC
Definition: Revision.php:54
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
__construct( $row, $queryFlags=0, Title $title=null)
Definition: Revision.php:354
isDeleted( $field)
Definition: Revision.php:693
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:1124
getId()
Get revision ID.
Definition: Revision.php:443
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&#39;s marked as deleted.
Definition: Revision.php:1041
getContentHandler()
Returns the content handler appropriate for this revision&#39;s content model.
Definition: Revision.php:792
static userCanBitfield( $bitfield, $field, User $user, Title $title=null)
Determine if the current user is allowed to view a particular field of this revision, if it&#39;s marked as deleted.
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
Definition: Revision.php:921
static getRevisionFactory()
Definition: Revision.php:83
static loadFromId( $db, $id)
Load a page revision from a given revision ID number.
Definition: Revision.php:244
getComment( $audience=self::FOR_PUBLIC, User $user=null)
Definition: Revision.php:650
static loadFromTitle( $db, $title, $id=0)
Load either the current, or a specified, revision that&#39;s attached to a given page.
Definition: Revision.php:279
const DELETED_RESTRICTED
Definition: Revision.php:49
static getArchiveQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new archived revision objec...
Definition: Revision.php:330
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object...
Definition: Revision.php:316
getPrevious()
Get previous revision for this title.
Definition: Revision.php:815
const RAW
Definition: Revision.php:56
getContentModel()
Returns the content model for the main slot of this revision.
Definition: Revision.php:760
insertOn( $dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
Definition: Revision.php:949
const DELETED_TEXT
Definition: Revision.php:46
static countByTitle( $db, $title)
Get count of revisions per page...not very efficient.
Definition: Revision.php:1083
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:610
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
Definition: Title.php:269
const SUPPRESSED_USER
Definition: Revision.php:50
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:584
getVisibility()
Get the deletion bitfield of the revision.
Definition: Revision.php:702
static base36Sha1( $blob)
Get the base 36 SHA-1 value for a string of text.
Definition: SlotRecord.php:612
const DELETED_USER
Definition: Revision.php:48
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
static getBlobStore( $wiki=false)
Definition: Revision.php:92
getTextId()
Get the ID of the row of the text table that contains the content of the revision&#39;s main slot...
Definition: Revision.php:509
static newFromRow( $row)
Definition: Revision.php:224
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
static base36Sha1( $text)
Get the base 36 SHA-1 value for a string of text.
Definition: Revision.php:976
Exception representing a failure to look up a revision.
getNext()
Get next revision for this title.
Definition: Revision.php:825
setId( $id)
Set the revision ID.
Definition: Revision.php:459
Page revision base class.
$content
Definition: router.php:78
const DELETED_COMMENT
Definition: Revision.php:47
ensureTitle( $row, $queryFlags, $title=null)
Make sure we have some Title object for use by the constructor.
Definition: Revision.php:396
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition: Revision.php:120
getContentFormat()
Returns the content format for the main slot of this revision.
Definition: Revision.php:775
getSize()
Returns the length of the text in this revision, or null if unknown.
Definition: Revision.php:531
static newNullRevision( $dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page&#39;s history.
Definition: Revision.php:995
getSha1()
Returns the base36 sha1 of the content in this revision, or null if unknown.
Definition: Revision.php:544
const SUPPRESSED_ALL
Definition: Revision.php:51
isCurrent()
Definition: Revision.php:806