MediaWiki  1.34.0
Revision.php
Go to the documentation of this file.
1 <?php
32 use Wikimedia\Assert\Assert;
36 
40 class Revision implements IDBAccessObject {
41 
43  protected $mRecord;
44 
45  // Revision deletion constants
46  const DELETED_TEXT = RevisionRecord::DELETED_TEXT;
47  const DELETED_COMMENT = RevisionRecord::DELETED_COMMENT;
48  const DELETED_USER = RevisionRecord::DELETED_USER;
49  const DELETED_RESTRICTED = RevisionRecord::DELETED_RESTRICTED;
50  const SUPPRESSED_USER = RevisionRecord::SUPPRESSED_USER;
51  const SUPPRESSED_ALL = RevisionRecord::SUPPRESSED_ALL;
52 
53  // Audience options for accessors
54  const FOR_PUBLIC = RevisionRecord::FOR_PUBLIC;
55  const FOR_THIS_USER = RevisionRecord::FOR_THIS_USER;
56  const RAW = RevisionRecord::RAW;
57 
58  const TEXT_CACHE_GROUP = SqlBlobStore::TEXT_CACHE_GROUP;
59 
63  protected static function getRevisionStore( $wiki = false ) {
64  if ( $wiki ) {
65  return MediaWikiServices::getInstance()->getRevisionStoreFactory()
66  ->getRevisionStore( $wiki );
67  } else {
68  return MediaWikiServices::getInstance()->getRevisionStore();
69  }
70  }
71 
75  protected static function getRevisionLookup() {
76  return MediaWikiServices::getInstance()->getRevisionLookup();
77  }
78 
82  protected static function getRevisionFactory() {
83  return MediaWikiServices::getInstance()->getRevisionFactory();
84  }
85 
91  protected static function getBlobStore( $wiki = false ) {
92  // @phan-suppress-next-line PhanAccessMethodInternal
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 
119  public static function newFromId( $id, $flags = 0 ) {
120  $rec = self::getRevisionLookup()->getRevisionById( $id, $flags );
121  return $rec ? new Revision( $rec, $flags ) : null;
122  }
123 
138  public static function newFromTitle( LinkTarget $linkTarget, $id = 0, $flags = 0 ) {
139  $rec = self::getRevisionLookup()->getRevisionByTitle( $linkTarget, $id, $flags );
140  return $rec ? new Revision( $rec, $flags ) : null;
141  }
142 
157  public static function newFromPageId( $pageId, $revId = 0, $flags = 0 ) {
158  $rec = self::getRevisionLookup()->getRevisionByPageId( $pageId, $revId, $flags );
159  return $rec ? new Revision( $rec, $flags ) : null;
160  }
161 
172  public static function newFromArchiveRow( $row, $overrides = [] ) {
179  if ( array_key_exists( 'page', $overrides ) ) {
180  $overrides['page_id'] = $overrides['page'];
181  unset( $overrides['page'] );
182  }
183 
189  $title = null;
190  if ( isset( $overrides['title'] ) ) {
191  if ( !( $overrides['title'] instanceof Title ) ) {
192  throw new MWException( 'title field override must contain a Title object.' );
193  }
194 
195  $title = $overrides['title'];
196  }
197  if ( $title !== null ) {
198  if ( isset( $row->ar_namespace ) && isset( $row->ar_title ) ) {
199  $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
200  } else {
201  throw new InvalidArgumentException(
202  'A Title or ar_namespace and ar_title must be given'
203  );
204  }
205  }
206 
207  $rec = self::getRevisionFactory()->newRevisionFromArchiveRow( $row, 0, $title, $overrides );
208  return new Revision( $rec, self::READ_NORMAL, $title );
209  }
210 
223  public static function newFromRow( $row ) {
224  if ( is_array( $row ) ) {
225  $rec = self::getRevisionFactory()->newMutableRevisionFromArray( $row );
226  } else {
227  $rec = self::getRevisionFactory()->newRevisionFromRow( $row );
228  }
229 
230  return new Revision( $rec );
231  }
232 
243  public static function loadFromId( $db, $id ) {
244  wfDeprecated( __METHOD__, '1.31' ); // no known callers
245  $rec = self::getRevisionStore()->loadRevisionFromId( $db, $id );
246  return $rec ? new Revision( $rec ) : null;
247  }
248 
261  public static function loadFromPageId( $db, $pageid, $id = 0 ) {
262  $rec = self::getRevisionStore()->loadRevisionFromPageId( $db, $pageid, $id );
263  return $rec ? new Revision( $rec ) : null;
264  }
265 
278  public static function loadFromTitle( $db, $title, $id = 0 ) {
279  $rec = self::getRevisionStore()->loadRevisionFromTitle( $db, $title, $id );
280  return $rec ? new Revision( $rec ) : null;
281  }
282 
296  public static function loadFromTimestamp( $db, $title, $timestamp ) {
297  $rec = self::getRevisionStore()->loadRevisionFromTimestamp( $db, $title, $timestamp );
298  return $rec ? new Revision( $rec ) : null;
299  }
300 
315  public static function getQueryInfo( $options = [] ) {
316  return self::getRevisionStore()->getQueryInfo( $options );
317  }
318 
329  public static function getArchiveQueryInfo() {
330  return self::getRevisionStore()->getArchiveQueryInfo();
331  }
332 
342  public static function getParentLengths( $db, array $revIds ) {
343  return self::getRevisionStore()->listRevisionSizes( $db, $revIds );
344  }
345 
353  function __construct( $row, $queryFlags = 0, Title $title = null ) {
354  global $wgUser;
355 
356  if ( $row instanceof RevisionRecord ) {
357  $this->mRecord = $row;
358  } elseif ( is_array( $row ) ) {
359  // If no user is specified, fall back to using the global user object, to stay
360  // compatible with pre-1.31 behavior.
361  if ( !isset( $row['user'] ) && !isset( $row['user_text'] ) ) {
362  $row['user'] = $wgUser;
363  }
364 
365  $this->mRecord = self::getRevisionFactory()->newMutableRevisionFromArray(
366  $row,
367  $queryFlags,
368  $this->ensureTitle( $row, $queryFlags, $title )
369  );
370  } elseif ( is_object( $row ) ) {
371  $this->mRecord = self::getRevisionFactory()->newRevisionFromRow(
372  $row,
373  $queryFlags,
374  $this->ensureTitle( $row, $queryFlags, $title )
375  );
376  } else {
377  throw new InvalidArgumentException(
378  '$row must be a row object, an associative array, or a RevisionRecord'
379  );
380  }
381 
382  Assert::postcondition( $this->mRecord !== null, 'Failed to construct a RevisionRecord' );
383  }
384 
395  private function ensureTitle( $row, $queryFlags, $title = null ) {
396  if ( $title ) {
397  return $title;
398  }
399 
400  if ( is_array( $row ) ) {
401  if ( isset( $row['title'] ) ) {
402  if ( !( $row['title'] instanceof Title ) ) {
403  throw new MWException( 'title field must contain a Title object.' );
404  }
405 
406  return $row['title'];
407  }
408 
409  $pageId = $row['page'] ?? 0;
410  $revId = $row['id'] ?? 0;
411  } else {
412  $pageId = $row->rev_page ?? 0;
413  $revId = $row->rev_id ?? 0;
414  }
415 
416  try {
417  $title = self::getRevisionStore()->getTitle( $pageId, $revId, $queryFlags );
418  } catch ( RevisionAccessException $ex ) {
419  // construct a dummy title!
420  wfLogWarning( __METHOD__ . ': ' . $ex->getMessage() );
421 
422  // NOTE: this Title will only be used inside RevisionRecord
423  $title = Title::makeTitleSafe( NS_SPECIAL, "Badtitle/ID=$pageId" );
424  $title->resetArticleID( $pageId );
425  }
426 
427  return $title;
428  }
429 
433  public function getRevisionRecord() {
434  return $this->mRecord;
435  }
436 
442  public function getId() {
443  return $this->mRecord->getId();
444  }
445 
458  public function setId( $id ) {
459  if ( $this->mRecord instanceof MutableRevisionRecord ) {
460  $this->mRecord->setId( intval( $id ) );
461  } else {
462  throw new MWException( __METHOD__ . ' is not supported on this instance' );
463  }
464  }
465 
480  public function setUserIdAndName( $id, $name ) {
481  if ( $this->mRecord instanceof MutableRevisionRecord ) {
482  $user = User::newFromAnyId( intval( $id ), $name, null );
483  $this->mRecord->setUser( $user );
484  } else {
485  throw new MWException( __METHOD__ . ' is not supported on this instance' );
486  }
487  }
488 
492  private function getMainSlotRaw() {
493  return $this->mRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW );
494  }
495 
508  public function getTextId() {
509  $slot = $this->getMainSlotRaw();
510  return $slot->hasAddress()
511  ? self::getBlobStore()->getTextIdFromAddress( $slot->getAddress() )
512  : null;
513  }
514 
521  public function getParentId() {
522  return $this->mRecord->getParentId();
523  }
524 
530  public function getSize() {
531  try {
532  return $this->mRecord->getSize();
533  } catch ( RevisionAccessException $ex ) {
534  return null;
535  }
536  }
537 
543  public function getSha1() {
544  try {
545  return $this->mRecord->getSha1();
546  } catch ( RevisionAccessException $ex ) {
547  return null;
548  }
549  }
550 
559  public function getTitle() {
560  $linkTarget = $this->mRecord->getPageAsLinkTarget();
561  return Title::newFromLinkTarget( $linkTarget );
562  }
563 
571  public function setTitle( $title ) {
572  if ( !$title->equals( $this->getTitle() ) ) {
573  throw new InvalidArgumentException(
574  $title->getPrefixedText()
575  . ' is not the same as '
576  . $this->mRecord->getPageAsLinkTarget()->__toString()
577  );
578  }
579  }
580 
586  public function getPage() {
587  return $this->mRecord->getPageId();
588  }
589 
603  public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
604  global $wgUser;
605 
606  if ( $audience === self::FOR_THIS_USER && !$user ) {
607  $user = $wgUser;
608  }
609 
610  $user = $this->mRecord->getUser( $audience, $user );
611  return $user ? $user->getId() : 0;
612  }
613 
627  public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
628  global $wgUser;
629 
630  if ( $audience === self::FOR_THIS_USER && !$user ) {
631  $user = $wgUser;
632  }
633 
634  $user = $this->mRecord->getUser( $audience, $user );
635  return $user ? $user->getName() : '';
636  }
637 
649  function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
650  global $wgUser;
651 
652  if ( $audience === self::FOR_THIS_USER && !$user ) {
653  $user = $wgUser;
654  }
655 
656  $comment = $this->mRecord->getComment( $audience, $user );
657  return $comment === null ? null : $comment->text;
658  }
659 
663  public function isMinor() {
664  return $this->mRecord->isMinor();
665  }
666 
670  public function isUnpatrolled() {
671  return self::getRevisionStore()->getRcIdIfUnpatrolled( $this->mRecord );
672  }
673 
683  public function getRecentChange( $flags = 0 ) {
684  return self::getRevisionStore()->getRecentChange( $this->mRecord, $flags );
685  }
686 
692  public function isDeleted( $field ) {
693  return $this->mRecord->isDeleted( $field );
694  }
695 
701  public function getVisibility() {
702  return $this->mRecord->getVisibility();
703  }
704 
719  public function getContent( $audience = self::FOR_PUBLIC, User $user = null ) {
720  global $wgUser;
721 
722  if ( $audience === self::FOR_THIS_USER && !$user ) {
723  $user = $wgUser;
724  }
725 
726  try {
727  return $this->mRecord->getContent( SlotRecord::MAIN, $audience, $user );
728  }
729  catch ( RevisionAccessException $e ) {
730  return null;
731  }
732  }
733 
742  public function getSerializedData() {
743  $slot = $this->getMainSlotRaw();
744  return $slot->getContent()->serialize();
745  }
746 
759  public function getContentModel() {
760  return $this->getMainSlotRaw()->getModel();
761  }
762 
774  public function getContentFormat() {
775  $format = $this->getMainSlotRaw()->getFormat();
776 
777  if ( $format === null ) {
778  // if no format was stored along with the blob, fall back to default format
779  $format = $this->getContentHandler()->getDefaultFormat();
780  }
781 
782  return $format;
783  }
784 
791  public function getContentHandler() {
793  }
794 
798  public function getTimestamp() {
799  return $this->mRecord->getTimestamp();
800  }
801 
805  public function isCurrent() {
806  return ( $this->mRecord instanceof RevisionStoreRecord ) && $this->mRecord->isCurrent();
807  }
808 
814  public function getPrevious() {
815  $rec = self::getRevisionLookup()->getPreviousRevision( $this->mRecord );
816  return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
817  }
818 
824  public function getNext() {
825  $rec = self::getRevisionLookup()->getNextRevision( $this->mRecord );
826  return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
827  }
828 
850  public static function getRevisionText( $row, $prefix = 'old_', $wiki = false ) {
852 
853  if ( !$row ) {
854  return false;
855  }
856 
857  $textField = $prefix . 'text';
858  $flagsField = $prefix . 'flags';
859 
860  if ( isset( $row->$textField ) ) {
862  // The text field was read, but it's no longer being populated!
863  // We could gloss over this by using the text when it's there and loading
864  // if when it's not, but it seems preferable to complain loudly about a
865  // query that is no longer guaranteed to work reliably.
866  throw new LogicException(
867  'Cannot use ' . __METHOD__ . ' with the ' . $textField . ' field when'
868  . ' $wgMultiContentRevisionSchemaMigrationStage does not include'
869  . ' SCHEMA_COMPAT_WRITE_OLD. The field may not be populated for all revisions!'
870  );
871  }
872 
873  $text = $row->$textField;
874  } else {
875  // Missing text field, we are probably looking at the MCR-enabled DB schema.
876 
878  // This method should no longer be used with the new schema. Ideally, we
879  // would already trigger a deprecation warning when SCHEMA_COMPAT_READ_NEW is set.
880  wfDeprecated( __METHOD__ . ' (MCR without SCHEMA_COMPAT_WRITE_OLD)', '1.32' );
881  }
882 
883  $store = self::getRevisionStore( $wiki );
884  $rev = $prefix === 'ar_'
885  ? $store->newRevisionFromArchiveRow( $row )
886  : $store->newRevisionFromRow( $row );
887 
888  $content = $rev->getContent( SlotRecord::MAIN );
889  return $content ? $content->serialize() : false;
890  }
891 
892  if ( isset( $row->$flagsField ) ) {
893  $flags = explode( ',', $row->$flagsField );
894  } else {
895  $flags = [];
896  }
897 
898  $cacheKey = isset( $row->old_id )
899  ? SqlBlobStore::makeAddressFromTextId( $row->old_id )
900  : null;
901 
902  $revisionText = self::getBlobStore( $wiki )->expandBlob( $text, $flags, $cacheKey );
903 
904  if ( $revisionText === false ) {
905  if ( isset( $row->old_id ) ) {
906  wfLogWarning( __METHOD__ . ": Bad data in text row {$row->old_id}! " );
907  } else {
908  wfLogWarning( __METHOD__ . ": Bad data in text row! " );
909  }
910  return false;
911  }
912 
913  return $revisionText;
914  }
915 
926  public static function compressRevisionText( &$text ) {
927  return self::getBlobStore()->compressData( $text );
928  }
929 
937  public static function decompressRevisionText( $text, $flags ) {
938  if ( $text === false ) {
939  // Text failed to be fetched; nothing to do
940  return false;
941  }
942 
943  return self::getBlobStore()->decompressData( $text, $flags );
944  }
945 
954  public function insertOn( $dbw ) {
955  global $wgUser;
956 
957  // Note that $this->mRecord->getId() will typically return null here, but not always,
958  // e.g. not when restoring a revision.
959 
960  if ( $this->mRecord->getUser( RevisionRecord::RAW ) === null ) {
961  if ( $this->mRecord instanceof MutableRevisionRecord ) {
962  $this->mRecord->setUser( $wgUser );
963  } else {
964  throw new MWException( 'Cannot insert revision with no associated user.' );
965  }
966  }
967 
968  $rec = self::getRevisionStore()->insertRevisionOn( $this->mRecord, $dbw );
969 
970  $this->mRecord = $rec;
971  Assert::postcondition( $this->mRecord !== null, 'Failed to acquire a RevisionRecord' );
972 
973  return $rec->getId();
974  }
975 
981  public static function base36Sha1( $text ) {
982  return SlotRecord::base36Sha1( $text );
983  }
984 
1000  public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
1001  global $wgUser;
1002  if ( !$user ) {
1003  $user = $wgUser;
1004  }
1005 
1006  $comment = CommentStoreComment::newUnsavedComment( $summary, null );
1007 
1008  $title = Title::newFromID( $pageId, Title::READ_LATEST );
1009  if ( $title === null ) {
1010  return null;
1011  }
1012 
1013  $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
1014 
1015  return $rec ? new Revision( $rec ) : null;
1016  }
1017 
1028  public function userCan( $field, User $user = null ) {
1029  return self::userCanBitfield( $this->getVisibility(), $field, $user );
1030  }
1031 
1046  public static function userCanBitfield( $bitfield, $field, User $user = null,
1047  Title $title = null
1048  ) {
1049  global $wgUser;
1050 
1051  if ( !$user ) {
1052  $user = $wgUser;
1053  }
1054 
1055  return RevisionRecord::userCanBitfield( $bitfield, $field, $user, $title );
1056  }
1057 
1066  static function getTimestampFromId( $title, $id, $flags = 0 ) {
1067  return self::getRevisionStore()->getTimestampFromId( $id, $flags );
1068  }
1069 
1077  static function countByPageId( $db, $id ) {
1078  return self::getRevisionStore()->countRevisionsByPageId( $db, $id );
1079  }
1080 
1088  static function countByTitle( $db, $title ) {
1089  return self::getRevisionStore()->countRevisionsByTitle( $db, $title );
1090  }
1091 
1108  public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
1109  if ( is_int( $db ) ) {
1110  $db = wfGetDB( $db );
1111  }
1112 
1113  return self::getRevisionStore()->userWasLastToEdit( $db, $pageId, $userId, $since );
1114  }
1115 
1129  public static function newKnownCurrent( IDatabase $db, $pageIdOrTitle, $revId = 0 ) {
1130  $title = $pageIdOrTitle instanceof Title
1131  ? $pageIdOrTitle
1132  : Title::newFromID( $pageIdOrTitle );
1133 
1134  if ( !$title ) {
1135  return false;
1136  }
1137 
1138  $record = self::getRevisionLookup()->getKnownCurrentRevision( $title, $revId );
1139  return $record ? new Revision( $record ) : false;
1140  }
1141 }
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:172
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:48
Revision\getTimestamp
getTimestamp()
Definition: Revision.php:798
ContentHandler\getForModelID
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
Definition: ContentHandler.php:254
CommentStoreComment\newUnsavedComment
static newUnsavedComment( $comment, array $data=null)
Create a new, unsaved CommentStoreComment.
Definition: CommentStoreComment.php:66
Revision\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: Revision.php:49
Revision\RevisionAccessException
Exception representing a failure to look up a revision.
Definition: RevisionAccessException.php:33
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:1129
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:627
Revision\RevisionRecord
Page revision base class.
Definition: RevisionRecord.php:46
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:119
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:603
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:1046
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
Revision\getSize
getSize()
Returns the length of the text in this revision, or null if unknown.
Definition: Revision.php:530
Revision\RevisionStore
Service for looking up page revisions.
Definition: RevisionStore.php:79
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:458
Revision\getContent
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
Definition: Revision.php:719
Revision\getPage
getPage()
Get the page ID.
Definition: Revision.php:586
Revision\getBlobStore
static getBlobStore( $wiki=false)
Definition: Revision.php:91
$wgMultiContentRevisionSchemaMigrationStage
int $wgMultiContentRevisionSchemaMigrationStage
RevisionStore table schema migration stage (content, slots, content_models & slot_roles tables).
Definition: DefaultSettings.php:9003
Revision\getRevisionText
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
Definition: Revision.php:850
Revision\getParentId
getParentId()
Get parent revision ID (the original previous page revision)
Definition: Revision.php:521
Revision\setTitle
setTitle( $title)
Set the title of the revision.
Definition: Revision.php:571
Revision\getContentHandler
getContentHandler()
Returns the content handler appropriate for this revision's content model.
Definition: Revision.php:791
Revision\RevisionFactory
Service for constructing revision objects.
Definition: RevisionFactory.php:37
Revision\getArchiveQueryInfo
static getArchiveQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new archived revision objec...
Definition: Revision.php:329
Revision\getSerializedData
getSerializedData()
Get original serialized data (without checking view restrictions)
Definition: Revision.php:742
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1078
Revision\getRecentChange
getRecentChange( $flags=0)
Get the RC object belonging to the current revision, if there's one.
Definition: Revision.php:683
Revision\TEXT_CACHE_GROUP
const TEXT_CACHE_GROUP
Definition: Revision.php:58
Revision\isCurrent
isCurrent()
Definition: Revision.php:805
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:157
Revision\getSha1
getSha1()
Returns the base36 sha1 of the content in this revision, or null if unknown.
Definition: Revision.php:543
Revision\loadFromId
static loadFromId( $db, $id)
Load a page revision from a given revision ID number.
Definition: Revision.php:243
IDBAccessObject
Interface for database access objects.
Definition: IDBAccessObject.php:55
Revision\getId
getId()
Get revision ID.
Definition: Revision.php:442
Revision\getContentModel
getContentModel()
Returns the content model for the main slot of this revision.
Definition: Revision.php:759
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:954
Revision\getRevisionFactory
static getRevisionFactory()
Definition: Revision.php:82
Revision\base36Sha1
static base36Sha1( $text)
Get the base 36 SHA-1 value for a string of text.
Definition: Revision.php:981
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
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:138
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:49
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:315
MWException
MediaWiki exception.
Definition: MWException.php:26
Revision\getNext
getNext()
Get next revision for this title.
Definition: Revision.php:824
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1044
Revision\setUserIdAndName
setUserIdAndName( $id, $name)
Set the user ID/name.
Definition: Revision.php:480
Revision\getTimestampFromId
static getTimestampFromId( $title, $id, $flags=0)
Get rev_timestamp from rev_id, without loading the rest of the row.
Definition: Revision.php:1066
Revision\isUnpatrolled
isUnpatrolled()
Definition: Revision.php:670
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2575
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:926
$title
$title
Definition: testCompression.php:34
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:586
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:596
Revision\countByTitle
static countByTitle( $db, $title)
Get count of revisions per page...not very efficient.
Definition: Revision.php:1088
Revision\getPrevious
getPrevious()
Get previous revision for this title.
Definition: Revision.php:814
Revision\countByPageId
static countByPageId( $db, $id)
Get count of revisions per page...not very efficient.
Definition: Revision.php:1077
Revision\getRevisionStore
static getRevisionStore( $wiki=false)
Definition: Revision.php:63
Revision\ensureTitle
ensureTitle( $row, $queryFlags, $title=null)
Make sure we have some Title object for use by the constructor.
Definition: Revision.php:395
Revision\getTitle
getTitle()
Returns the title of the page associated with this entry.
Definition: Revision.php:559
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:1108
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:613
$content
$content
Definition: router.php:78
Revision\$mRecord
RevisionRecord $mRecord
Definition: Revision.php:43
Revision\MutableRevisionRecord
Definition: MutableRevisionRecord.php:42
Revision\getParentLengths
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
Definition: Revision.php:342
Revision\getVisibility
getVisibility()
Get the deletion bitfield of the revision.
Definition: Revision.php:701
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:508
SCHEMA_COMPAT_WRITE_OLD
const SCHEMA_COMPAT_WRITE_OLD
Definition: Defines.php:264
Revision\isDeleted
isDeleted( $field)
Definition: Revision.php:692
Revision\newFromRow
static newFromRow( $row)
Definition: Revision.php:223
Revision\RAW
const RAW
Definition: Revision.php:56
Revision\RevisionStoreRecord
A RevisionRecord representing an existing revision persisted in the revision table.
Definition: RevisionStoreRecord.php:39
Title\newFromLinkTarget
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
Definition: Title.php:268
Revision\getMainSlotRaw
getMainSlotRaw()
Definition: Revision.php:492
Revision\getContentFormat
getContentFormat()
Returns the content format for the main slot of this revision.
Definition: Revision.php:774
Title
Represents a title within MediaWiki.
Definition: Title.php:42
Revision\loadFromTimestamp
static loadFromTimestamp( $db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
Definition: Revision.php:296
Revision\getComment
getComment( $audience=self::FOR_PUBLIC, User $user=null)
Definition: Revision.php:649
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:1000
Revision\__construct
__construct( $row, $queryFlags=0, Title $title=null)
Definition: Revision.php:353
Revision\isMinor
isMinor()
Definition: Revision.php:663
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
Revision\getRevisionRecord
getRevisionRecord()
Definition: Revision.php:433
Revision\decompressRevisionText
static decompressRevisionText( $text, $flags)
Re-converts revision text according to it's flags.
Definition: Revision.php:937
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:278
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:51
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:467
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:1028
Revision\SlotRecord
Value object representing a content slot associated with a page revision.
Definition: SlotRecord.php:39
Revision\getRevisionLookup
static getRevisionLookup()
Definition: Revision.php:75