MediaWiki  master
Revision.php
Go to the documentation of this file.
1 <?php
34 use Wikimedia\Assert\Assert;
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  $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  public 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  public 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 ) {
851  wfDeprecated( __METHOD__, '1.32' );
853 
854  if ( !$row ) {
855  return false;
856  }
857 
858  $textField = $prefix . 'text';
859  $flagsField = $prefix . 'flags';
860 
861  if ( isset( $row->$textField ) ) {
863  // The text field was read, but it's no longer being populated!
864  // We could gloss over this by using the text when it's there and loading
865  // if when it's not, but it seems preferable to complain loudly about a
866  // query that is no longer guaranteed to work reliably.
867  throw new LogicException(
868  'Cannot use ' . __METHOD__ . ' with the ' . $textField . ' field when'
869  . ' $wgMultiContentRevisionSchemaMigrationStage does not include'
870  . ' SCHEMA_COMPAT_WRITE_OLD. The field may not be populated for all revisions!'
871  );
872  }
873 
874  $text = $row->$textField;
875  } else {
876  // Missing text field, we are probably looking at the MCR-enabled DB schema.
877  $store = self::getRevisionStore( $wiki );
878  $rev = $prefix === 'ar_'
879  ? $store->newRevisionFromArchiveRow( $row )
880  : $store->newRevisionFromRow( $row );
881 
882  $content = $rev->getContent( SlotRecord::MAIN );
883  return $content ? $content->serialize() : false;
884  }
885 
886  if ( isset( $row->$flagsField ) ) {
887  $flags = explode( ',', $row->$flagsField );
888  } else {
889  $flags = [];
890  }
891 
892  $cacheKey = isset( $row->old_id )
893  ? SqlBlobStore::makeAddressFromTextId( $row->old_id )
894  : null;
895 
896  $revisionText = self::getBlobStore( $wiki )->expandBlob( $text, $flags, $cacheKey );
897 
898  if ( $revisionText === false ) {
899  if ( isset( $row->old_id ) ) {
900  wfLogWarning( __METHOD__ . ": Bad data in text row {$row->old_id}! " );
901  } else {
902  wfLogWarning( __METHOD__ . ": Bad data in text row! " );
903  }
904  return false;
905  }
906 
907  return $revisionText;
908  }
909 
920  public static function compressRevisionText( &$text ) {
921  return self::getBlobStore()->compressData( $text );
922  }
923 
931  public static function decompressRevisionText( $text, $flags ) {
932  if ( $text === false ) {
933  // Text failed to be fetched; nothing to do
934  return false;
935  }
936 
937  return self::getBlobStore()->decompressData( $text, $flags );
938  }
939 
948  public function insertOn( $dbw ) {
949  global $wgUser;
950 
951  // Note that $this->mRecord->getId() will typically return null here, but not always,
952  // e.g. not when restoring a revision.
953 
954  if ( $this->mRecord->getUser( RevisionRecord::RAW ) === null ) {
955  if ( $this->mRecord instanceof MutableRevisionRecord ) {
956  $this->mRecord->setUser( $wgUser );
957  } else {
958  throw new MWException( 'Cannot insert revision with no associated user.' );
959  }
960  }
961 
962  $rec = self::getRevisionStore()->insertRevisionOn( $this->mRecord, $dbw );
963 
964  $this->mRecord = $rec;
965  Assert::postcondition( $this->mRecord !== null, 'Failed to acquire a RevisionRecord' );
966 
967  return $rec->getId();
968  }
969 
975  public static function base36Sha1( $text ) {
976  return SlotRecord::base36Sha1( $text );
977  }
978 
994  public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
995  global $wgUser;
996  if ( !$user ) {
997  $user = $wgUser;
998  }
999 
1000  $comment = CommentStoreComment::newUnsavedComment( $summary, null );
1001 
1002  $title = Title::newFromID( $pageId, Title::READ_LATEST );
1003  if ( $title === null ) {
1004  return null;
1005  }
1006 
1007  $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
1008 
1009  return $rec ? new Revision( $rec ) : null;
1010  }
1011 
1022  public function userCan( $field, User $user = null ) {
1023  return self::userCanBitfield( $this->getVisibility(), $field, $user );
1024  }
1025 
1040  public static function userCanBitfield( $bitfield, $field, User $user = null,
1041  Title $title = null
1042  ) {
1043  global $wgUser;
1044 
1045  if ( !$user ) {
1046  $user = $wgUser;
1047  }
1048 
1049  return RevisionRecord::userCanBitfield( $bitfield, $field, $user, $title );
1050  }
1051 
1060  public static function getTimestampFromId( $title, $id, $flags = 0 ) {
1061  return self::getRevisionStore()->getTimestampFromId( $id, $flags );
1062  }
1063 
1071  public static function countByPageId( $db, $id ) {
1072  return self::getRevisionStore()->countRevisionsByPageId( $db, $id );
1073  }
1074 
1082  public static function countByTitle( $db, $title ) {
1083  return self::getRevisionStore()->countRevisionsByTitle( $db, $title );
1084  }
1085 
1102  public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
1103  if ( is_int( $db ) ) {
1104  $db = wfGetDB( $db );
1105  }
1106 
1107  return self::getRevisionStore()->userWasLastToEdit( $db, $pageId, $userId, $since );
1108  }
1109 
1123  public static function newKnownCurrent( IDatabase $db, $pageIdOrTitle, $revId = 0 ) {
1124  $title = $pageIdOrTitle instanceof Title
1125  ? $pageIdOrTitle
1126  : Title::newFromID( $pageIdOrTitle );
1127 
1128  if ( !$title ) {
1129  return false;
1130  }
1131 
1132  $record = self::getRevisionLookup()->getKnownCurrentRevision( $title, $revId );
1133  return $record ? new Revision( $record ) : false;
1134  }
1135 }
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:1123
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:1040
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:130
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:92
$wgMultiContentRevisionSchemaMigrationStage
int $wgMultiContentRevisionSchemaMigrationStage
RevisionStore table schema migration stage (content, slots, content_models & slot_roles tables).
Definition: DefaultSettings.php:8970
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:948
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:975
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:1060
Revision\isUnpatrolled
isUnpatrolled()
Definition: Revision.php:670
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2562
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:920
Revision\RevisionRecord\userCanBitfield
static userCanBitfield( $bitfield, $field, User $user, Title $title=null)
Determine if the current user is allowed to view a particular field of this revision,...
Definition: RevisionRecord.php:514
Revision\RevisionRecord\RAW
const RAW
Definition: RevisionRecord.php:60
$title
$title
Definition: testCompression.php:36
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:584
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:618
Revision\SlotRecord\base36Sha1
static base36Sha1( $blob)
Get the base 36 SHA-1 value for a string of text.
Definition: SlotRecord.php:612
Revision\countByTitle
static countByTitle( $db, $title)
Get count of revisions per page...not very efficient.
Definition: Revision.php:1082
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:1071
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: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:1102
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:610
Revision\RevisionRecord\SUPPRESSED_USER
const SUPPRESSED_USER
Definition: RevisionRecord.php:53
$content
$content
Definition: router.php:78
Revision\RevisionRecord\DELETED_USER
const DELETED_USER
Definition: RevisionRecord.php:51
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
Revision\SlotRecord\MAIN
const MAIN
Definition: SlotRecord.php:41
Title\newFromLinkTarget
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
Definition: Title.php:269
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
Revision\RevisionRecord\FOR_PUBLIC
const FOR_PUBLIC
Definition: RevisionRecord.php:58
Title
Represents a title within MediaWiki.
Definition: Title.php:42
Revision\RevisionRecord\DELETED_COMMENT
const DELETED_COMMENT
Definition: RevisionRecord.php:50
Revision\RevisionRecord\DELETED_TEXT
const DELETED_TEXT
Definition: RevisionRecord.php:49
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:994
Revision\__construct
__construct( $row, $queryFlags=0, Title $title=null)
Definition: Revision.php:353
Revision\isMinor
isMinor()
Definition: Revision.php:663
Revision\RevisionRecord\SUPPRESSED_ALL
const SUPPRESSED_ALL
Definition: RevisionRecord.php:54
Revision\RevisionRecord\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: RevisionRecord.php:52
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:931
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:52
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:465
Revision\RevisionRecord\FOR_THIS_USER
const FOR_THIS_USER
Definition: RevisionRecord.php:59
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:1022
Revision\SlotRecord
Value object representing a content slot associated with a page revision.
Definition: SlotRecord.php:39
Revision\getRevisionLookup
static getRevisionLookup()
Definition: Revision.php:76