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 
159  public static function newFromPageId( $pageId, $revId = 0, $flags = 0 ) {
160  wfDeprecated( __METHOD__, '1.31' );
161  $rec = self::getRevisionLookup()->getRevisionByPageId( $pageId, $revId, $flags );
162  return $rec ? new Revision( $rec, $flags ) : null;
163  }
164 
175  public static function newFromArchiveRow( $row, $overrides = [] ) {
182  if ( array_key_exists( 'page', $overrides ) ) {
183  $overrides['page_id'] = $overrides['page'];
184  unset( $overrides['page'] );
185  }
186 
192  $title = null;
193  if ( isset( $overrides['title'] ) ) {
194  if ( !( $overrides['title'] instanceof Title ) ) {
195  throw new MWException( 'title field override must contain a Title object.' );
196  }
197 
198  $title = $overrides['title'];
199  }
200  if ( $title !== null ) {
201  if ( isset( $row->ar_namespace ) && isset( $row->ar_title ) ) {
202  $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
203  } else {
204  throw new InvalidArgumentException(
205  'A Title or ar_namespace and ar_title must be given'
206  );
207  }
208  }
209 
210  $rec = self::getRevisionFactory()->newRevisionFromArchiveRow( $row, 0, $title, $overrides );
211  return new Revision( $rec, self::READ_NORMAL, $title );
212  }
213 
227  public static function newFromRow( $row ) {
228  wfDeprecated( __METHOD__, '1.31' );
229  if ( is_array( $row ) ) {
230  $rec = self::getRevisionFactory()->newMutableRevisionFromArray( $row );
231  } else {
232  $rec = self::getRevisionFactory()->newRevisionFromRow( $row );
233  }
234 
235  return new Revision( $rec );
236  }
237 
251  public static function loadFromPageId( $db, $pageid, $id = 0 ) {
252  wfDeprecated( __METHOD__, '1.31' );
253  $rec = self::getRevisionStore()->loadRevisionFromPageId( $db, $pageid, $id );
254  return $rec ? new Revision( $rec ) : null;
255  }
256 
270  public static function loadFromTitle( $db, $title, $id = 0 ) {
271  wfDeprecated( __METHOD__, '1.31' );
272  $rec = self::getRevisionStore()->loadRevisionFromTitle( $db, $title, $id );
273  return $rec ? new Revision( $rec ) : null;
274  }
275 
289  public static function loadFromTimestamp( $db, $title, $timestamp ) {
290  wfDeprecated( __METHOD__, '1.31' );
291  $rec = self::getRevisionStore()->loadRevisionFromTimestamp( $db, $title, $timestamp );
292  return $rec ? new Revision( $rec ) : null;
293  }
294 
309  public static function getQueryInfo( $options = [] ) {
310  wfDeprecated( __METHOD__, '1.31' );
311  return self::getRevisionStore()->getQueryInfo( $options );
312  }
313 
325  public static function getArchiveQueryInfo() {
326  wfDeprecated( __METHOD__, '1.31' );
327  return self::getRevisionStore()->getArchiveQueryInfo();
328  }
329 
340  public static function getParentLengths( $db, array $revIds ) {
341  wfDeprecated( __METHOD__, '1.31' );
342  return self::getRevisionStore()->getRevisionSizes( $revIds );
343  }
344 
352  public function __construct( $row, $queryFlags = 0, Title $title = null ) {
353  global $wgUser;
354 
355  if ( $row instanceof RevisionRecord ) {
356  $this->mRecord = $row;
357  } elseif ( is_array( $row ) ) {
358  // If no user is specified, fall back to using the global user object, to stay
359  // compatible with pre-1.31 behavior.
360  if ( !isset( $row['user'] ) && !isset( $row['user_text'] ) ) {
361  $row['user'] = $wgUser;
362  }
363 
364  $this->mRecord = self::getRevisionFactory()->newMutableRevisionFromArray(
365  $row,
366  $queryFlags,
367  $this->ensureTitle( $row, $queryFlags, $title )
368  );
369  } elseif ( is_object( $row ) ) {
370  $this->mRecord = self::getRevisionFactory()->newRevisionFromRow(
371  $row,
372  $queryFlags,
373  $this->ensureTitle( $row, $queryFlags, $title )
374  );
375  } else {
376  throw new InvalidArgumentException(
377  '$row must be a row object, an associative array, or a RevisionRecord'
378  );
379  }
380 
381  Assert::postcondition( $this->mRecord !== null, 'Failed to construct a RevisionRecord' );
382  }
383 
394  private function ensureTitle( $row, $queryFlags, $title = null ) {
395  if ( $title ) {
396  return $title;
397  }
398 
399  if ( is_array( $row ) ) {
400  if ( isset( $row['title'] ) ) {
401  if ( !( $row['title'] instanceof Title ) ) {
402  throw new MWException( 'title field must contain a Title object.' );
403  }
404 
405  return $row['title'];
406  }
407 
408  $pageId = $row['page'] ?? 0;
409  $revId = $row['id'] ?? 0;
410  } else {
411  $pageId = $row->rev_page ?? 0;
412  $revId = $row->rev_id ?? 0;
413  }
414 
415  try {
416  $title = self::getRevisionStore()->getTitle( $pageId, $revId, $queryFlags );
417  } catch ( RevisionAccessException $ex ) {
418  // construct a dummy title!
419  wfLogWarning( __METHOD__ . ': ' . $ex->getMessage() );
420 
421  // NOTE: this Title will only be used inside RevisionRecord
422  $title = Title::makeTitleSafe( NS_SPECIAL, "Badtitle/ID=$pageId" );
423  $title->resetArticleID( $pageId );
424  }
425 
426  return $title;
427  }
428 
432  public function getRevisionRecord() {
433  return $this->mRecord;
434  }
435 
441  public function getId() {
442  return $this->mRecord->getId();
443  }
444 
457  public function setId( $id ) {
458  if ( $this->mRecord instanceof MutableRevisionRecord ) {
459  $this->mRecord->setId( intval( $id ) );
460  } else {
461  throw new MWException( __METHOD__ . ' is not supported on this instance' );
462  }
463  }
464 
479  public function setUserIdAndName( $id, $name ) {
480  wfDeprecated( __METHOD__, '1.31' );
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  if ( !$this->mRecord->hasSlot( SlotRecord::MAIN ) ) {
494  return null;
495  }
496 
497  return $this->mRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW );
498  }
499 
513  public function getTextId() {
514  wfDeprecated( __METHOD__, '1.31' );
515  $slot = $this->getMainSlotRaw();
516  return $slot && $slot->hasAddress()
517  ? self::getBlobStore()->getTextIdFromAddress( $slot->getAddress() )
518  : null;
519  }
520 
527  public function getParentId() {
528  return $this->mRecord->getParentId();
529  }
530 
536  public function getSize() {
537  try {
538  return $this->mRecord->getSize();
539  } catch ( RevisionAccessException $ex ) {
540  return null;
541  }
542  }
543 
549  public function getSha1() {
550  try {
551  return $this->mRecord->getSha1();
552  } catch ( RevisionAccessException $ex ) {
553  return null;
554  }
555  }
556 
565  public function getTitle() {
566  $linkTarget = $this->mRecord->getPageAsLinkTarget();
567  return Title::newFromLinkTarget( $linkTarget );
568  }
569 
578  public function setTitle( $title ) {
579  wfDeprecated( __METHOD__, '1.31' );
580  if ( !$title->equals( $this->getTitle() ) ) {
581  throw new InvalidArgumentException(
582  $title->getPrefixedText()
583  . ' is not the same as '
584  . $this->mRecord->getPageAsLinkTarget()->__toString()
585  );
586  }
587  }
588 
594  public function getPage() {
595  return $this->mRecord->getPageId();
596  }
597 
611  public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
612  if ( $audience === self::FOR_THIS_USER && !$user ) {
613  wfDeprecated(
614  __METHOD__ . ' using FOR_THIS_USER without a user',
615  '1.35'
616  );
617  global $wgUser;
618  $user = $wgUser;
619  }
620 
621  $user = $this->mRecord->getUser( $audience, $user );
622  return $user ? $user->getId() : 0;
623  }
624 
638  public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
639  if ( $audience === self::FOR_THIS_USER && !$user ) {
640  wfDeprecated(
641  __METHOD__ . ' using FOR_THIS_USER without a user',
642  '1.35'
643  );
644  global $wgUser;
645  $user = $wgUser;
646  }
647 
648  $user = $this->mRecord->getUser( $audience, $user );
649  return $user ? $user->getName() : '';
650  }
651 
663  public function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
664  if ( $audience === self::FOR_THIS_USER && !$user ) {
665  wfDeprecated(
666  __METHOD__ . ' using FOR_THIS_USER without a user',
667  '1.35'
668  );
669  global $wgUser;
670  $user = $wgUser;
671  }
672 
673  $comment = $this->mRecord->getComment( $audience, $user );
674  return $comment === null ? null : $comment->text;
675  }
676 
680  public function isMinor() {
681  return $this->mRecord->isMinor();
682  }
683 
688  public function isUnpatrolled() {
689  wfDeprecated( __METHOD__, '1.31' );
690  return self::getRevisionStore()->getRcIdIfUnpatrolled( $this->mRecord );
691  }
692 
704  public function getRecentChange( $flags = 0 ) {
705  wfDeprecated( __METHOD__, '1.31' );
706  return self::getRevisionStore()->getRecentChange( $this->mRecord, $flags );
707  }
708 
714  public function isDeleted( $field ) {
715  return $this->mRecord->isDeleted( $field );
716  }
717 
723  public function getVisibility() {
724  return $this->mRecord->getVisibility();
725  }
726 
741  public function getContent( $audience = self::FOR_PUBLIC, User $user = null ) {
742  global $wgUser;
743 
744  if ( $audience === self::FOR_THIS_USER && !$user ) {
745  $user = $wgUser;
746  }
747 
748  try {
749  return $this->mRecord->getContent( SlotRecord::MAIN, $audience, $user );
750  }
751  catch ( RevisionAccessException $e ) {
752  return null;
753  }
754  }
755 
764  public function getSerializedData() {
765  wfDeprecated( __METHOD__, '1.31' );
766  $slot = $this->getMainSlotRaw();
767  return $slot ? $slot->getContent()->serialize() : '';
768  }
769 
782  public function getContentModel() {
783  $slot = $this->getMainSlotRaw();
784 
785  if ( $slot ) {
786  return $slot->getModel();
787  } else {
788  $slotRoleRegistry = MediaWikiServices::getInstance()->getSlotRoleRegistry();
789  $slotRoleHandler = $slotRoleRegistry->getRoleHandler( SlotRecord::MAIN );
790  return $slotRoleHandler->getDefaultModel( $this->getTitle() );
791  }
792  }
793 
805  public function getContentFormat() {
806  $slot = $this->getMainSlotRaw();
807  $format = $slot ? $this->getMainSlotRaw()->getFormat() : null;
808 
809  if ( $format === null ) {
810  // if no format was stored along with the blob, fall back to default format
811  $format = $this->getContentHandler()->getDefaultFormat();
812  }
813 
814  return $format;
815  }
816 
823  public function getContentHandler() {
824  return MediaWikiServices::getInstance()
825  ->getContentHandlerFactory()
826  ->getContentHandler( $this->getContentModel() );
827  }
828 
832  public function getTimestamp() {
833  return $this->mRecord->getTimestamp();
834  }
835 
839  public function isCurrent() {
840  return ( $this->mRecord instanceof RevisionStoreRecord ) && $this->mRecord->isCurrent();
841  }
842 
848  public function getPrevious() {
849  $rec = self::getRevisionLookup()->getPreviousRevision( $this->mRecord );
850  return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
851  }
852 
858  public function getNext() {
859  $rec = self::getRevisionLookup()->getNextRevision( $this->mRecord );
860  return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
861  }
862 
884  public static function getRevisionText( $row, $prefix = 'old_', $wiki = false ) {
885  wfDeprecated( __METHOD__, '1.32' );
886 
887  if ( !$row ) {
888  return false;
889  }
890 
891  $textField = $prefix . 'text';
892 
893  if ( isset( $row->$textField ) ) {
894  throw new LogicException(
895  'Cannot use ' . __METHOD__ . ' with the ' . $textField . ' field since 1.35.'
896  );
897  }
898 
899  // Missing text field, we are probably looking at the MCR-enabled DB schema.
900  $store = self::getRevisionStore( $wiki );
901  $rev = $prefix === 'ar_'
902  ? $store->newRevisionFromArchiveRow( $row )
903  : $store->newRevisionFromRow( $row );
904 
905  $content = $rev->getContent( SlotRecord::MAIN );
906  return $content ? $content->serialize() : false;
907  }
908 
919  public static function compressRevisionText( &$text ) {
920  return self::getBlobStore()->compressData( $text );
921  }
922 
930  public static function decompressRevisionText( $text, $flags ) {
931  if ( $text === false ) {
932  // Text failed to be fetched; nothing to do
933  return false;
934  }
935 
936  return self::getBlobStore()->decompressData( $text, $flags );
937  }
938 
947  public function insertOn( $dbw ) {
948  global $wgUser;
949 
950  // Note that $this->mRecord->getId() will typically return null here, but not always,
951  // e.g. not when restoring a revision.
952 
953  if ( $this->mRecord->getUser( RevisionRecord::RAW ) === null ) {
954  if ( $this->mRecord instanceof MutableRevisionRecord ) {
955  $this->mRecord->setUser( $wgUser );
956  } else {
957  throw new MWException( 'Cannot insert revision with no associated user.' );
958  }
959  }
960 
961  $rec = self::getRevisionStore()->insertRevisionOn( $this->mRecord, $dbw );
962 
963  $this->mRecord = $rec;
964  Assert::postcondition( $this->mRecord !== null, 'Failed to acquire a RevisionRecord' );
965 
966  return $rec->getId();
967  }
968 
975  public static function base36Sha1( $text ) {
976  wfDeprecated( __METHOD__, '1.31' );
977  return SlotRecord::base36Sha1( $text );
978  }
979 
995  public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
996  if ( !$user ) {
997  wfDeprecated( __METHOD__ . ' without passing a $user parameter', '1.35' );
998  global $wgUser;
999  $user = $wgUser;
1000  }
1001 
1002  $comment = CommentStoreComment::newUnsavedComment( $summary, null );
1003 
1004  $title = Title::newFromID( $pageId, Title::READ_LATEST );
1005  if ( $title === null ) {
1006  return null;
1007  }
1008 
1009  $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
1010 
1011  return $rec ? new Revision( $rec ) : null;
1012  }
1013 
1026  public function userCan( $field, User $user = null ) {
1027  wfDeprecated( __METHOD__, '1.31' );
1028  if ( !$user ) {
1029  global $wgUser;
1030  $user = $wgUser;
1031  }
1032  return RevisionRecord::userCanBitfield( $this->getVisibility(), $field, $user );
1033  }
1034 
1049  public static function userCanBitfield( $bitfield, $field, User $user = null,
1050  Title $title = null
1051  ) {
1052  wfDeprecated( __METHOD__, '1.31' );
1053  if ( !$user ) {
1054  global $wgUser;
1055  $user = $wgUser;
1056  }
1057 
1058  return RevisionRecord::userCanBitfield( $bitfield, $field, $user, $title );
1059  }
1060 
1071  public static function getTimestampFromId( $title, $id, $flags = 0 ) {
1072  wfDeprecated( __METHOD__, '1.35' );
1073  return self::getRevisionStore()->getTimestampFromId( $id, $flags );
1074  }
1075 
1085  public static function countByPageId( $db, $id ) {
1086  wfDeprecated( __METHOD__, '1.31' );
1087  return self::getRevisionStore()->countRevisionsByPageId( $db, $id );
1088  }
1089 
1099  public static function countByTitle( $db, $title ) {
1100  wfDeprecated( __METHOD__, '1.31' );
1101  return self::getRevisionStore()->countRevisionsByTitle( $db, $title );
1102  }
1103 
1120  public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
1121  wfDeprecated( __METHOD__, '1.24' );
1122  if ( is_int( $db ) ) {
1123  $db = wfGetDB( $db );
1124  }
1125 
1126  return self::getRevisionStore()->userWasLastToEdit( $db, $pageId, $userId, $since );
1127  }
1128 
1143  public static function newKnownCurrent( IDatabase $db, $pageIdOrTitle, $revId = 0 ) {
1144  wfDeprecated( __METHOD__, '1.31' );
1145  $title = $pageIdOrTitle instanceof Title
1146  ? $pageIdOrTitle
1147  : Title::newFromID( $pageIdOrTitle );
1148 
1149  if ( !$title ) {
1150  return false;
1151  }
1152 
1153  $record = self::getRevisionLookup()->getKnownCurrentRevision( $title, $revId );
1154  return $record ? new Revision( $record ) : false;
1155  }
1156 }
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:175
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:48
Revision\getTimestamp
getTimestamp()
Definition: Revision.php:832
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:1143
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:638
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:611
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:1049
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:137
Revision\getSize
getSize()
Returns the length of the text in this revision, or null if unknown.
Definition: Revision.php:536
Revision\RevisionStore
Service for looking up page revisions.
Definition: RevisionStore.php:77
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:457
Revision\getContent
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
Definition: Revision.php:741
Revision\getPage
getPage()
Get the page ID.
Definition: Revision.php:594
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:884
Revision\getParentId
getParentId()
Get parent revision ID (the original previous page revision)
Definition: Revision.php:527
Revision\setTitle
setTitle( $title)
Set the title of the revision.
Definition: Revision.php:578
Revision\getContentHandler
getContentHandler()
Returns the content handler appropriate for this revision's content model.
Definition: Revision.php:823
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:325
Revision\getSerializedData
getSerializedData()
Get original serialized data (without checking view restrictions)
Definition: Revision.php:764
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1067
Revision\getRecentChange
getRecentChange( $flags=0)
Get the RC object belonging to the current revision, if there's one.
Definition: Revision.php:704
Revision\TEXT_CACHE_GROUP
const TEXT_CACHE_GROUP
Definition: Revision.php:58
Revision\isCurrent
isCurrent()
Definition: Revision.php:839
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:159
Revision\getSha1
getSha1()
Returns the base36 sha1 of the content in this revision, or null if unknown.
Definition: Revision.php:549
IDBAccessObject
Interface for database access objects.
Definition: IDBAccessObject.php:55
Revision\getId
getId()
Get revision ID.
Definition: Revision.php:441
Revision\getContentModel
getContentModel()
Returns the content model for the main slot of this revision.
Definition: Revision.php:782
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:947
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:58
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:309
MWException
MediaWiki exception.
Definition: MWException.php:26
Revision\getNext
getNext()
Get next revision for this title.
Definition: Revision.php:858
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)
Set the user ID/name.
Definition: Revision.php:479
Revision\getTimestampFromId
static getTimestampFromId( $title, $id, $flags=0)
Get rev_timestamp from rev_id, without loading the rest of the row.
Definition: Revision.php:1071
Revision\isUnpatrolled
isUnpatrolled()
Definition: Revision.php:688
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2500
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:251
Revision\compressRevisionText
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
Definition: Revision.php:919
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:38
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:595
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:616
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:1099
Revision\getPrevious
getPrevious()
Get previous revision for this title.
Definition: Revision.php:848
Revision\countByPageId
static countByPageId( $db, $id)
Get count of revisions per page...not very efficient.
Definition: Revision.php:1085
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:394
Revision\getTitle
getTitle()
Returns the title of the page associated with this entry.
Definition: Revision.php:565
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:1120
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:621
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:340
Revision\getVisibility
getVisibility()
Get the deletion bitfield of the revision.
Definition: Revision.php:723
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:513
Revision\isDeleted
isDeleted( $field)
Definition: Revision.php:714
Revision\newFromRow
static newFromRow( $row)
Definition: Revision.php:227
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:284
Revision\getMainSlotRaw
getMainSlotRaw()
Definition: Revision.php:492
Revision\getContentFormat
getContentFormat()
Returns the content format for the main slot of this revision.
Definition: Revision.php:805
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:289
Revision\getComment
getComment( $audience=self::FOR_PUBLIC, User $user=null)
Definition: Revision.php:663
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:995
Revision\__construct
__construct( $row, $queryFlags=0, Title $title=null)
Definition: Revision.php:352
Revision\isMinor
isMinor()
Definition: Revision.php:680
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:432
Revision\decompressRevisionText
static decompressRevisionText( $text, $flags)
Re-converts revision text according to it's flags.
Definition: Revision.php:930
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:270
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:53
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:476
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:1026
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