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 
409  private function ensureTitle( $row, $queryFlags, $title = null ) {
410  if ( $title ) {
411  return $title;
412  }
413 
414  if ( is_array( $row ) ) {
415  if ( isset( $row['title'] ) ) {
416  if ( !( $row['title'] instanceof Title ) ) {
417  throw new MWException( 'title field must contain a Title object.' );
418  }
419 
420  return $row['title'];
421  }
422 
423  $pageId = $row['page'] ?? 0;
424  $revId = $row['id'] ?? 0;
425  } else {
426  $pageId = $row->rev_page ?? 0;
427  $revId = $row->rev_id ?? 0;
428  }
429 
430  try {
431  $title = self::getRevisionStore()->getTitle( $pageId, $revId, $queryFlags );
432  } catch ( RevisionAccessException $ex ) {
433  // construct a dummy title!
434  wfLogWarning( __METHOD__ . ': ' . $ex->getMessage() );
435 
436  // NOTE: this Title will only be used inside RevisionRecord
437  $title = Title::makeTitleSafe( NS_SPECIAL, "Badtitle/ID=$pageId" );
438  $title->resetArticleID( $pageId );
439  }
440 
441  return $title;
442  }
443 
448  public function getRevisionRecord() {
449  wfDeprecated( __METHOD__, '1.31' );
450  return $this->mRecord;
451  }
452 
460  public function getId() {
461  wfDeprecated( __METHOD__, '1.31' );
462  return $this->mRecord->getId();
463  }
464 
478  public function setId( $id ) {
479  wfDeprecated( __METHOD__, '1.31' );
480  if ( $this->mRecord instanceof MutableRevisionRecord ) {
481  $this->mRecord->setId( intval( $id ) );
482  } else {
483  throw new MWException( __METHOD__ . ' is not supported on this instance' );
484  }
485  }
486 
499  public function setUserIdAndName( $id, $name ) {
500  wfDeprecated( __METHOD__, '1.31' );
501  if ( $this->mRecord instanceof MutableRevisionRecord ) {
502  $user = User::newFromAnyId( intval( $id ), $name, null );
503  $this->mRecord->setUser( $user );
504  } else {
505  throw new MWException( __METHOD__ . ' is not supported on this instance' );
506  }
507  }
508 
512  private function getMainSlotRaw() {
513  if ( !$this->mRecord->hasSlot( SlotRecord::MAIN ) ) {
514  return null;
515  }
516 
517  return $this->mRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW );
518  }
519 
533  public function getTextId() {
534  wfDeprecated( __METHOD__, '1.31' );
535  $slot = $this->getMainSlotRaw();
536  return $slot && $slot->hasAddress()
537  ? self::getBlobStore()->getTextIdFromAddress( $slot->getAddress() )
538  : null;
539  }
540 
549  public function getParentId() {
550  wfDeprecated( __METHOD__, '1.31' );
551  return $this->mRecord->getParentId();
552  }
553 
561  public function getSize() {
562  wfDeprecated( __METHOD__, '1.31' );
563  try {
564  return $this->mRecord->getSize();
565  } catch ( RevisionAccessException $ex ) {
566  return null;
567  }
568  }
569 
577  public function getSha1() {
578  wfDeprecated( __METHOD__, '1.31' );
579  try {
580  return $this->mRecord->getSha1();
581  } catch ( RevisionAccessException $ex ) {
582  return null;
583  }
584  }
585 
596  public function getTitle() {
597  wfDeprecated( __METHOD__, '1.31' );
598  $linkTarget = $this->mRecord->getPageAsLinkTarget();
599  return Title::newFromLinkTarget( $linkTarget );
600  }
601 
610  public function setTitle( $title ) {
611  wfDeprecated( __METHOD__, '1.31' );
612  if ( !$title->equals( $this->getTitle() ) ) {
613  throw new InvalidArgumentException(
614  $title->getPrefixedText()
615  . ' is not the same as '
616  . $this->mRecord->getPageAsLinkTarget()->__toString()
617  );
618  }
619  }
620 
628  public function getPage() {
629  wfDeprecated( __METHOD__, '1.31' );
630  return $this->mRecord->getPageId();
631  }
632 
648  public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
649  wfDeprecated( __METHOD__, '1.31' );
650  if ( $audience === self::FOR_THIS_USER && !$user ) {
651  global $wgUser;
652  $user = $wgUser;
653  }
654 
655  $user = $this->mRecord->getUser( $audience, $user );
656  return $user ? $user->getId() : 0;
657  }
658 
674  public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
675  wfDeprecated( __METHOD__, '1.31' );
676  if ( $audience === self::FOR_THIS_USER && !$user ) {
677  global $wgUser;
678  $user = $wgUser;
679  }
680 
681  $user = $this->mRecord->getUser( $audience, $user );
682  return $user ? $user->getName() : '';
683  }
684 
698  public function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
699  wfDeprecated( __METHOD__, '1.31' );
700  if ( $audience === self::FOR_THIS_USER && !$user ) {
701  global $wgUser;
702  $user = $wgUser;
703  }
704 
705  $comment = $this->mRecord->getComment( $audience, $user );
706  return $comment === null ? null : $comment->text;
707  }
708 
714  public function isMinor() {
715  wfDeprecated( __METHOD__, '1.31' );
716  return $this->mRecord->isMinor();
717  }
718 
723  public function isUnpatrolled() {
724  wfDeprecated( __METHOD__, '1.31' );
725  return self::getRevisionStore()->getRcIdIfUnpatrolled( $this->mRecord );
726  }
727 
739  public function getRecentChange( $flags = 0 ) {
740  wfDeprecated( __METHOD__, '1.31' );
741  return self::getRevisionStore()->getRecentChange( $this->mRecord, $flags );
742  }
743 
751  public function isDeleted( $field ) {
752  wfDeprecated( __METHOD__, '1.31' );
753  return $this->mRecord->isDeleted( $field );
754  }
755 
763  public function getVisibility() {
764  wfDeprecated( __METHOD__, '1.31' );
765  return $this->mRecord->getVisibility();
766  }
767 
784  public function getContent( $audience = self::FOR_PUBLIC, User $user = null ) {
785  wfDeprecated( __METHOD__, '1.31' );
786 
787  global $wgUser;
788 
789  if ( $audience === self::FOR_THIS_USER && !$user ) {
790  $user = $wgUser;
791  }
792 
793  try {
794  return $this->mRecord->getContent( SlotRecord::MAIN, $audience, $user );
795  }
796  catch ( RevisionAccessException $e ) {
797  return null;
798  }
799  }
800 
809  public function getSerializedData() {
810  wfDeprecated( __METHOD__, '1.31' );
811  $slot = $this->getMainSlotRaw();
812  return $slot ? $slot->getContent()->serialize() : '';
813  }
814 
827  public function getContentModel() {
828  wfDeprecated( __METHOD__, '1.31' );
829 
830  $slot = $this->getMainSlotRaw();
831 
832  if ( $slot ) {
833  return $slot->getModel();
834  } else {
835  $slotRoleRegistry = MediaWikiServices::getInstance()->getSlotRoleRegistry();
836  $slotRoleHandler = $slotRoleRegistry->getRoleHandler( SlotRecord::MAIN );
837  return $slotRoleHandler->getDefaultModel( $this->getTitle() );
838  }
839  }
840 
852  public function getContentFormat() {
853  wfDeprecated( __METHOD__, '1.31' );
854 
855  $slot = $this->getMainSlotRaw();
856  $format = $slot ? $this->getMainSlotRaw()->getFormat() : null;
857 
858  if ( $format === null ) {
859  // if no format was stored along with the blob, fall back to default format
860  $format = $this->getContentHandler()->getDefaultFormat();
861  }
862 
863  return $format;
864  }
865 
874  public function getContentHandler() {
875  wfDeprecated( __METHOD__, '1.31' );
876 
877  return MediaWikiServices::getInstance()
878  ->getContentHandlerFactory()
879  ->getContentHandler( $this->getContentModel() );
880  }
881 
887  public function getTimestamp() {
888  wfDeprecated( __METHOD__, '1.31' );
889  return $this->mRecord->getTimestamp();
890  }
891 
897  public function isCurrent() {
898  wfDeprecated( __METHOD__, '1.31' );
899  return $this->mRecord->isCurrent();
900  }
901 
909  public function getPrevious() {
910  wfDeprecated( __METHOD__, '1.31' );
911  $rec = self::getRevisionLookup()->getPreviousRevision( $this->mRecord );
912  return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
913  }
914 
922  public function getNext() {
923  wfDeprecated( __METHOD__, '1.31' );
924  $rec = self::getRevisionLookup()->getNextRevision( $this->mRecord );
925  return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
926  }
927 
949  public static function getRevisionText( $row, $prefix = 'old_', $wiki = false ) {
950  wfDeprecated( __METHOD__, '1.32' );
951 
952  if ( !$row ) {
953  return false;
954  }
955 
956  $textField = $prefix . 'text';
957 
958  if ( isset( $row->$textField ) ) {
959  throw new LogicException(
960  'Cannot use ' . __METHOD__ . ' with the ' . $textField . ' field since 1.35.'
961  );
962  }
963 
964  // Missing text field, we are probably looking at the MCR-enabled DB schema.
965  $store = self::getRevisionStore( $wiki );
966  $rev = $prefix === 'ar_'
967  ? $store->newRevisionFromArchiveRow( $row )
968  : $store->newRevisionFromRow( $row );
969 
970  $content = $rev->getContent( SlotRecord::MAIN );
971  return $content ? $content->serialize() : false;
972  }
973 
986  public static function compressRevisionText( &$text ) {
987  wfDeprecated( __METHOD__, '1.31' );
988  return self::getBlobStore()->compressData( $text );
989  }
990 
1000  public static function decompressRevisionText( $text, $flags ) {
1001  wfDeprecated( __METHOD__, '1.31' );
1002  if ( $text === false ) {
1003  // Text failed to be fetched; nothing to do
1004  return false;
1005  }
1006 
1007  return self::getBlobStore()->decompressData( $text, $flags );
1008  }
1009 
1020  public function insertOn( $dbw ) {
1021  wfDeprecated( __METHOD__, '1.31' );
1022 
1023  global $wgUser;
1024 
1025  // Note that $this->mRecord->getId() will typically return null here, but not always,
1026  // e.g. not when restoring a revision.
1027 
1028  if ( $this->mRecord->getUser( RevisionRecord::RAW ) === null ) {
1029  if ( $this->mRecord instanceof MutableRevisionRecord ) {
1030  $this->mRecord->setUser( $wgUser );
1031  } else {
1032  throw new MWException( 'Cannot insert revision with no associated user.' );
1033  }
1034  }
1035 
1036  $rec = self::getRevisionStore()->insertRevisionOn( $this->mRecord, $dbw );
1037 
1038  $this->mRecord = $rec;
1039  Assert::postcondition( $this->mRecord !== null, 'Failed to acquire a RevisionRecord' );
1040 
1041  return $rec->getId();
1042  }
1043 
1050  public static function base36Sha1( $text ) {
1051  wfDeprecated( __METHOD__, '1.31' );
1052  return SlotRecord::base36Sha1( $text );
1053  }
1054 
1072  public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
1073  wfDeprecated( __METHOD__, '1.35' );
1074 
1075  if ( !$user ) {
1076  global $wgUser;
1077  $user = $wgUser;
1078  }
1079 
1080  $comment = CommentStoreComment::newUnsavedComment( $summary, null );
1081 
1082  $title = Title::newFromID( $pageId, Title::READ_LATEST );
1083  if ( $title === null ) {
1084  return null;
1085  }
1086 
1087  $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
1088 
1089  return $rec ? new Revision( $rec ) : null;
1090  }
1091 
1104  public function userCan( $field, User $user = null ) {
1105  wfDeprecated( __METHOD__, '1.31' );
1106  if ( !$user ) {
1107  global $wgUser;
1108  $user = $wgUser;
1109  }
1110  return RevisionRecord::userCanBitfield( $this->mRecord->getVisibility(), $field, $user );
1111  }
1112 
1127  public static function userCanBitfield( $bitfield, $field, User $user = null,
1128  Title $title = null
1129  ) {
1130  wfDeprecated( __METHOD__, '1.31' );
1131  if ( !$user ) {
1132  global $wgUser;
1133  $user = $wgUser;
1134  }
1135 
1136  return RevisionRecord::userCanBitfield( $bitfield, $field, $user, $title );
1137  }
1138 
1149  public static function getTimestampFromId( $title, $id, $flags = 0 ) {
1150  wfDeprecated( __METHOD__, '1.35' );
1151  return self::getRevisionStore()->getTimestampFromId( $id, $flags );
1152  }
1153 
1163  public static function countByPageId( $db, $id ) {
1164  wfDeprecated( __METHOD__, '1.31' );
1165  return self::getRevisionStore()->countRevisionsByPageId( $db, $id );
1166  }
1167 
1177  public static function countByTitle( $db, $title ) {
1178  wfDeprecated( __METHOD__, '1.31' );
1179  return self::getRevisionStore()->countRevisionsByTitle( $db, $title );
1180  }
1181 
1198  public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
1199  wfDeprecated( __METHOD__, '1.24' );
1200  if ( is_int( $db ) ) {
1201  $db = wfGetDB( $db );
1202  }
1203 
1204  return self::getRevisionStore()->userWasLastToEdit( $db, $pageId, $userId, $since );
1205  }
1206 
1221  public static function newKnownCurrent( IDatabase $db, $pageIdOrTitle, $revId = 0 ) {
1222  wfDeprecated( __METHOD__, '1.31' );
1223  $title = $pageIdOrTitle instanceof Title
1224  ? $pageIdOrTitle
1225  : Title::newFromID( $pageIdOrTitle );
1226 
1227  if ( !$title ) {
1228  return false;
1229  }
1230 
1231  $record = self::getRevisionLookup()->getKnownCurrentRevision( $title, $revId );
1232  return $record ? new Revision( $record ) : false;
1233  }
1234 }
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:887
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:1221
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:674
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: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:648
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:1127
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:166
Revision\getSize
getSize()
Returns the length of the text in this revision, or null if unknown.
Definition: Revision.php:561
Revision\RevisionStore
Service for looking up page revisions.
Definition: RevisionStore.php:80
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:478
Revision\getContent
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
Definition: Revision.php:784
Revision\getPage
getPage()
Get the page ID.
Definition: Revision.php:628
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:949
Revision\getParentId
getParentId()
Get parent revision ID (the original previous page revision)
Definition: Revision.php:549
Revision\setTitle
setTitle( $title)
Set the title of the revision.
Definition: Revision.php:610
Revision\getContentHandler
getContentHandler()
Returns the content handler appropriate for this revision's content model.
Definition: Revision.php:874
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:809
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1093
Revision\getRecentChange
getRecentChange( $flags=0)
Get the RC object belonging to the current revision, if there's one.
Definition: Revision.php:739
Revision\TEXT_CACHE_GROUP
const TEXT_CACHE_GROUP
Definition: Revision.php:58
Revision\isCurrent
isCurrent()
Definition: Revision.php:897
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:577
IDBAccessObject
Interface for database access objects.
Definition: IDBAccessObject.php:57
Revision\getId
getId()
Get revision ID.
Definition: Revision.php:460
Revision\getContentModel
getContentModel()
Returns the content model for the main slot of this revision.
Definition: Revision.php:827
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:1020
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:1050
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
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:52
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:922
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Definition: GlobalFunctions.php:1033
Revision\setUserIdAndName
setUserIdAndName( $id, $name)
This should only be used for proposed revisions that turn out to be null edits.
Definition: Revision.php:499
Revision\getTimestampFromId
static getTimestampFromId( $title, $id, $flags=0)
Get rev_timestamp from rev_id, without loading the rest of the row.
Definition: Revision.php:1149
Revision\isUnpatrolled
isUnpatrolled()
Definition: Revision.php:723
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2466
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:986
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:506
Revision\RevisionRecord\RAW
const RAW
Definition: RevisionRecord.php:61
$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:624
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:646
Revision\SlotRecord\base36Sha1
static base36Sha1( $blob)
Get the base 36 SHA-1 value for a string of text.
Definition: SlotRecord.php:605
Revision\countByTitle
static countByTitle( $db, $title)
Get count of revisions per page...not very efficient.
Definition: Revision.php:1177
Revision\getPrevious
getPrevious()
Get previous revision for this title.
Definition: Revision.php:909
Revision\countByPageId
static countByPageId( $db, $id)
Get count of revisions per page...not very efficient.
Definition: Revision.php:1163
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:409
Revision\getTitle
getTitle()
Returns the title of the page associated with this entry.
Definition: Revision.php:596
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:1198
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:650
Revision\RevisionRecord\SUPPRESSED_USER
const SUPPRESSED_USER
Definition: RevisionRecord.php:54
$content
$content
Definition: router.php:76
Revision\RevisionRecord\DELETED_USER
const DELETED_USER
Definition: RevisionRecord.php:52
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:763
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:533
Revision\isDeleted
isDeleted( $field)
Definition: Revision.php:751
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
Title\newFromLinkTarget
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
Definition: Title.php:289
Revision\getMainSlotRaw
getMainSlotRaw()
Definition: Revision.php:512
Revision\getContentFormat
getContentFormat()
Returns the content format for the main slot of this revision.
Definition: Revision.php:852
Revision\RevisionRecord\FOR_PUBLIC
const FOR_PUBLIC
Definition: RevisionRecord.php:59
Title
Represents a title within MediaWiki.
Definition: Title.php:46
Revision\RevisionRecord\DELETED_COMMENT
const DELETED_COMMENT
Definition: RevisionRecord.php:51
Revision\RevisionRecord\DELETED_TEXT
const DELETED_TEXT
Definition: RevisionRecord.php:50
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:698
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:1072
Revision\__construct
__construct( $row, $queryFlags=0, Title $title=null)
Definition: Revision.php:365
Revision\isMinor
isMinor()
Definition: Revision.php:714
Revision\RevisionRecord\SUPPRESSED_ALL
const SUPPRESSED_ALL
Definition: RevisionRecord.php:55
Revision\RevisionRecord\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: RevisionRecord.php:53
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
Revision\getRevisionRecord
getRevisionRecord()
Definition: Revision.php:448
Revision\decompressRevisionText
static decompressRevisionText( $text, $flags)
Re-converts revision text according to it's flags.
Definition: Revision.php:1000
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:56
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:505
Revision\RevisionRecord\FOR_THIS_USER
const FOR_THIS_USER
Definition: RevisionRecord.php:60
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:1104
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