MediaWiki  master
Revision.php
Go to the documentation of this file.
1 <?php
33 use Wikimedia\Assert\Assert;
35 
39 class Revision implements IDBAccessObject {
40 
42  private $mRecord;
43 
44  // Revision deletion constants
51 
52  // Audience options for accessors
55  public const RAW = RevisionRecord::RAW;
56 
57  public const TEXT_CACHE_GROUP = SqlBlobStore::TEXT_CACHE_GROUP;
58 
63  private static function getRevisionStore( $wiki = false ) {
64  if ( $wiki ) {
65  return MediaWikiServices::getInstance()->getRevisionStoreFactory()
66  ->getRevisionStore( $wiki );
67  } else {
68  return MediaWikiServices::getInstance()->getRevisionStore();
69  }
70  }
71 
75  private static function getRevisionLookup() {
76  return MediaWikiServices::getInstance()->getRevisionLookup();
77  }
78 
82  private static function getRevisionFactory() {
83  return MediaWikiServices::getInstance()->getRevisionFactory();
84  }
85 
91  private static function getBlobStore( $wiki = false ) {
92  $store = MediaWikiServices::getInstance()
93  ->getBlobStoreFactory()
94  ->newSqlBlobStore( $wiki );
95 
96  if ( !$store instanceof SqlBlobStore ) {
97  throw new RuntimeException(
98  'The backwards compatibility code in Revision currently requires the BlobStore '
99  . 'service to be an SqlBlobStore instance, but it is a ' . get_class( $store )
100  );
101  }
102 
103  return $store;
104  }
105 
120  public static function newFromId( $id, $flags = 0 ) {
121  wfDeprecated( __METHOD__, '1.31' );
122  $rec = self::getRevisionLookup()->getRevisionById( $id, $flags );
123  return $rec ? new Revision( $rec, $flags ) : null;
124  }
125 
142  public static function newFromTitle( LinkTarget $linkTarget, $id = 0, $flags = 0 ) {
143  wfDeprecated( __METHOD__, '1.31' );
144  $rec = self::getRevisionLookup()->getRevisionByTitle( $linkTarget, $id, $flags );
145  return $rec ? new Revision( $rec, $flags ) : null;
146  }
147 
164  public static function newFromPageId( $pageId, $revId = 0, $flags = 0 ) {
165  wfDeprecated( __METHOD__, '1.31' );
166  $rec = self::getRevisionLookup()->getRevisionByPageId( $pageId, $revId, $flags );
167  return $rec ? new Revision( $rec, $flags ) : null;
168  }
169 
182  public static function newFromArchiveRow( $row, $overrides = [] ) {
183  wfDeprecated( __METHOD__, '1.31' );
184 
191  if ( array_key_exists( 'page', $overrides ) ) {
192  $overrides['page_id'] = $overrides['page'];
193  unset( $overrides['page'] );
194  }
195 
201  $title = null;
202  if ( isset( $overrides['title'] ) ) {
203  if ( !( $overrides['title'] instanceof Title ) ) {
204  throw new MWException( 'title field override must contain a Title object.' );
205  }
206 
207  $title = $overrides['title'];
208  }
209  if ( $title !== null ) {
210  if ( isset( $row->ar_namespace ) && isset( $row->ar_title ) ) {
211  $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
212  } else {
213  throw new InvalidArgumentException(
214  'A Title or ar_namespace and ar_title must be given'
215  );
216  }
217  }
218 
219  $rec = self::getRevisionFactory()->newRevisionFromArchiveRow( $row, 0, $title, $overrides );
220  return new Revision( $rec, self::READ_NORMAL, $title );
221  }
222 
236  public static function newFromRow( $row ) {
237  wfDeprecated( __METHOD__, '1.31' );
238  if ( is_array( $row ) ) {
239  $rec = self::getRevisionFactory()->newMutableRevisionFromArray( $row );
240  } else {
241  $rec = self::getRevisionFactory()->newRevisionFromRow( $row );
242  }
243 
244  return new Revision( $rec );
245  }
246 
260  public static function loadFromPageId( $db, $pageid, $id = 0 ) {
261  wfDeprecated( __METHOD__, '1.31' );
262  $rec = self::getRevisionStore()->loadRevisionFromPageId( $db, $pageid, $id );
263  return $rec ? new Revision( $rec ) : null;
264  }
265 
279  public static function loadFromTitle( $db, $title, $id = 0 ) {
280  wfDeprecated( __METHOD__, '1.31' );
281  $rec = self::getRevisionStore()->loadRevisionFromTitle( $db, $title, $id );
282  return $rec ? new Revision( $rec ) : null;
283  }
284 
298  public static function loadFromTimestamp( $db, $title, $timestamp ) {
299  wfDeprecated( __METHOD__, '1.31' );
300  $rec = self::getRevisionStore()->loadRevisionFromTimestamp( $db, $title, $timestamp );
301  return $rec ? new Revision( $rec ) : null;
302  }
303 
318  public static function getQueryInfo( $options = [] ) {
319  wfDeprecated( __METHOD__, '1.31' );
320  return self::getRevisionStore()->getQueryInfo( $options );
321  }
322 
334  public static function getArchiveQueryInfo() {
335  wfDeprecated( __METHOD__, '1.31' );
336  return self::getRevisionStore()->getArchiveQueryInfo();
337  }
338 
349  public static function getParentLengths( $db, array $revIds ) {
350  wfDeprecated( __METHOD__, '1.31' );
351  return self::getRevisionStore()->getRevisionSizes( $revIds );
352  }
353 
364  public function __construct( $row, $queryFlags = 0, Title $title = null ) {
365  global $wgUser;
366 
367  if ( $row instanceof RevisionRecord ) {
368  $this->mRecord = $row;
369  } elseif ( is_array( $row ) ) {
370  wfDeprecated( __METHOD__ . ' with an array', '1.31' );
371  // If no user is specified, fall back to using the global user object, to stay
372  // compatible with pre-1.31 behavior.
373  if ( !isset( $row['user'] ) && !isset( $row['user_text'] ) ) {
374  $row['user'] = $wgUser;
375  }
376 
377  $this->mRecord = self::getRevisionFactory()->newMutableRevisionFromArray(
378  $row,
379  $queryFlags,
380  $this->ensureTitle( $row, $queryFlags, $title )
381  );
382  } elseif ( is_object( $row ) ) {
383  wfDeprecated( __METHOD__ . ' with an object', '1.31' );
384  $this->mRecord = self::getRevisionFactory()->newRevisionFromRow(
385  $row,
386  $queryFlags,
387  $this->ensureTitle( $row, $queryFlags, $title )
388  );
389  } else {
390  throw new InvalidArgumentException(
391  '$row must be a row object, an associative array, or a RevisionRecord'
392  );
393  }
394 
395  Assert::postcondition( $this->mRecord !== null, 'Failed to construct a RevisionRecord' );
396  }
397 
408  private function ensureTitle( $row, $queryFlags, $title = null ) {
409  if ( $title ) {
410  return $title;
411  }
412 
413  if ( is_array( $row ) ) {
414  if ( isset( $row['title'] ) ) {
415  if ( !( $row['title'] instanceof Title ) ) {
416  throw new MWException( 'title field must contain a Title object.' );
417  }
418 
419  return $row['title'];
420  }
421 
422  $pageId = $row['page'] ?? 0;
423  $revId = $row['id'] ?? 0;
424  } else {
425  $pageId = $row->rev_page ?? 0;
426  $revId = $row->rev_id ?? 0;
427  }
428 
429  try {
430  $title = self::getRevisionStore()->getTitle( $pageId, $revId, $queryFlags );
431  } catch ( RevisionAccessException $ex ) {
432  // construct a dummy title!
433  wfLogWarning( __METHOD__ . ': ' . $ex->getMessage() );
434 
435  // NOTE: this Title will only be used inside RevisionRecord
436  $title = Title::makeTitleSafe( NS_SPECIAL, "Badtitle/ID=$pageId" );
437  $title->resetArticleID( $pageId );
438  }
439 
440  return $title;
441  }
442 
446  public function getRevisionRecord() {
447  return $this->mRecord;
448  }
449 
455  public function getId() {
456  return $this->mRecord->getId();
457  }
458 
472  public function setId( $id ) {
473  wfDeprecated( __METHOD__, '1.31' );
474  if ( $this->mRecord instanceof MutableRevisionRecord ) {
475  $this->mRecord->setId( intval( $id ) );
476  } else {
477  throw new MWException( __METHOD__ . ' is not supported on this instance' );
478  }
479  }
480 
495  public function setUserIdAndName( $id, $name ) {
496  wfDeprecated( __METHOD__, '1.31' );
497  if ( $this->mRecord instanceof MutableRevisionRecord ) {
498  $user = User::newFromAnyId( intval( $id ), $name, null );
499  $this->mRecord->setUser( $user );
500  } else {
501  throw new MWException( __METHOD__ . ' is not supported on this instance' );
502  }
503  }
504 
508  private function getMainSlotRaw() {
509  if ( !$this->mRecord->hasSlot( SlotRecord::MAIN ) ) {
510  return null;
511  }
512 
513  return $this->mRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW );
514  }
515 
529  public function getTextId() {
530  wfDeprecated( __METHOD__, '1.31' );
531  $slot = $this->getMainSlotRaw();
532  return $slot && $slot->hasAddress()
533  ? self::getBlobStore()->getTextIdFromAddress( $slot->getAddress() )
534  : null;
535  }
536 
545  public function getParentId() {
546  wfDeprecated( __METHOD__, '1.31' );
547  return $this->mRecord->getParentId();
548  }
549 
557  public function getSize() {
558  wfDeprecated( __METHOD__, '1.31' );
559  try {
560  return $this->mRecord->getSize();
561  } catch ( RevisionAccessException $ex ) {
562  return null;
563  }
564  }
565 
573  public function getSha1() {
574  wfDeprecated( __METHOD__, '1.31' );
575  try {
576  return $this->mRecord->getSha1();
577  } catch ( RevisionAccessException $ex ) {
578  return null;
579  }
580  }
581 
590  public function getTitle() {
591  $linkTarget = $this->mRecord->getPageAsLinkTarget();
592  return Title::newFromLinkTarget( $linkTarget );
593  }
594 
603  public function setTitle( $title ) {
604  wfDeprecated( __METHOD__, '1.31' );
605  if ( !$title->equals( $this->getTitle() ) ) {
606  throw new InvalidArgumentException(
607  $title->getPrefixedText()
608  . ' is not the same as '
609  . $this->mRecord->getPageAsLinkTarget()->__toString()
610  );
611  }
612  }
613 
621  public function getPage() {
622  wfDeprecated( __METHOD__, '1.31' );
623  return $this->mRecord->getPageId();
624  }
625 
639  public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
640  if ( $audience === self::FOR_THIS_USER && !$user ) {
641  wfDeprecated(
642  __METHOD__ . ' using FOR_THIS_USER without a user',
643  '1.35'
644  );
645  global $wgUser;
646  $user = $wgUser;
647  }
648 
649  $user = $this->mRecord->getUser( $audience, $user );
650  return $user ? $user->getId() : 0;
651  }
652 
668  public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
669  wfDeprecated( __METHOD__, '1.31' );
670  if ( $audience === self::FOR_THIS_USER && !$user ) {
671  global $wgUser;
672  $user = $wgUser;
673  }
674 
675  $user = $this->mRecord->getUser( $audience, $user );
676  return $user ? $user->getName() : '';
677  }
678 
692  public function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
693  wfDeprecated( __METHOD__, '1.31' );
694  if ( $audience === self::FOR_THIS_USER && !$user ) {
695  global $wgUser;
696  $user = $wgUser;
697  }
698 
699  $comment = $this->mRecord->getComment( $audience, $user );
700  return $comment === null ? null : $comment->text;
701  }
702 
708  public function isMinor() {
709  wfDeprecated( __METHOD__, '1.31' );
710  return $this->mRecord->isMinor();
711  }
712 
717  public function isUnpatrolled() {
718  wfDeprecated( __METHOD__, '1.31' );
719  return self::getRevisionStore()->getRcIdIfUnpatrolled( $this->mRecord );
720  }
721 
733  public function getRecentChange( $flags = 0 ) {
734  wfDeprecated( __METHOD__, '1.31' );
735  return self::getRevisionStore()->getRecentChange( $this->mRecord, $flags );
736  }
737 
745  public function isDeleted( $field ) {
746  wfDeprecated( __METHOD__, '1.31' );
747  return $this->mRecord->isDeleted( $field );
748  }
749 
757  public function getVisibility() {
758  wfDeprecated( __METHOD__, '1.31' );
759  return $this->mRecord->getVisibility();
760  }
761 
778  public function getContent( $audience = self::FOR_PUBLIC, User $user = null ) {
779  wfDeprecated( __METHOD__, '1.31' );
780 
781  global $wgUser;
782 
783  if ( $audience === self::FOR_THIS_USER && !$user ) {
784  $user = $wgUser;
785  }
786 
787  try {
788  return $this->mRecord->getContent( SlotRecord::MAIN, $audience, $user );
789  }
790  catch ( RevisionAccessException $e ) {
791  return null;
792  }
793  }
794 
803  public function getSerializedData() {
804  wfDeprecated( __METHOD__, '1.31' );
805  $slot = $this->getMainSlotRaw();
806  return $slot ? $slot->getContent()->serialize() : '';
807  }
808 
821  public function getContentModel() {
822  wfDeprecated( __METHOD__, '1.31' );
823 
824  $slot = $this->getMainSlotRaw();
825 
826  if ( $slot ) {
827  return $slot->getModel();
828  } else {
829  $slotRoleRegistry = MediaWikiServices::getInstance()->getSlotRoleRegistry();
830  $slotRoleHandler = $slotRoleRegistry->getRoleHandler( SlotRecord::MAIN );
831  return $slotRoleHandler->getDefaultModel( $this->getTitle() );
832  }
833  }
834 
846  public function getContentFormat() {
847  wfDeprecated( __METHOD__, '1.31' );
848 
849  $slot = $this->getMainSlotRaw();
850  $format = $slot ? $this->getMainSlotRaw()->getFormat() : null;
851 
852  if ( $format === null ) {
853  // if no format was stored along with the blob, fall back to default format
854  $format = $this->getContentHandler()->getDefaultFormat();
855  }
856 
857  return $format;
858  }
859 
868  public function getContentHandler() {
869  wfDeprecated( __METHOD__, '1.31' );
870 
871  return MediaWikiServices::getInstance()
872  ->getContentHandlerFactory()
873  ->getContentHandler( $this->getContentModel() );
874  }
875 
881  public function getTimestamp() {
882  wfDeprecated( __METHOD__, '1.31' );
883  return $this->mRecord->getTimestamp();
884  }
885 
891  public function isCurrent() {
892  wfDeprecated( __METHOD__, '1.31' );
893  return $this->mRecord->isCurrent();
894  }
895 
903  public function getPrevious() {
904  wfDeprecated( __METHOD__, '1.31' );
905  $rec = self::getRevisionLookup()->getPreviousRevision( $this->mRecord );
906  return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
907  }
908 
916  public function getNext() {
917  wfDeprecated( __METHOD__, '1.31' );
918  $rec = self::getRevisionLookup()->getNextRevision( $this->mRecord );
919  return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
920  }
921 
943  public static function getRevisionText( $row, $prefix = 'old_', $wiki = false ) {
944  wfDeprecated( __METHOD__, '1.32' );
945 
946  if ( !$row ) {
947  return false;
948  }
949 
950  $textField = $prefix . 'text';
951 
952  if ( isset( $row->$textField ) ) {
953  throw new LogicException(
954  'Cannot use ' . __METHOD__ . ' with the ' . $textField . ' field since 1.35.'
955  );
956  }
957 
958  // Missing text field, we are probably looking at the MCR-enabled DB schema.
959  $store = self::getRevisionStore( $wiki );
960  $rev = $prefix === 'ar_'
961  ? $store->newRevisionFromArchiveRow( $row )
962  : $store->newRevisionFromRow( $row );
963 
964  $content = $rev->getContent( SlotRecord::MAIN );
965  return $content ? $content->serialize() : false;
966  }
967 
980  public static function compressRevisionText( &$text ) {
981  wfDeprecated( __METHOD__, '1.31' );
982  return self::getBlobStore()->compressData( $text );
983  }
984 
994  public static function decompressRevisionText( $text, $flags ) {
995  wfDeprecated( __METHOD__, '1.31' );
996  if ( $text === false ) {
997  // Text failed to be fetched; nothing to do
998  return false;
999  }
1000 
1001  return self::getBlobStore()->decompressData( $text, $flags );
1002  }
1003 
1014  public function insertOn( $dbw ) {
1015  wfDeprecated( __METHOD__, '1.31' );
1016 
1017  global $wgUser;
1018 
1019  // Note that $this->mRecord->getId() will typically return null here, but not always,
1020  // e.g. not when restoring a revision.
1021 
1022  if ( $this->mRecord->getUser( RevisionRecord::RAW ) === null ) {
1023  if ( $this->mRecord instanceof MutableRevisionRecord ) {
1024  $this->mRecord->setUser( $wgUser );
1025  } else {
1026  throw new MWException( 'Cannot insert revision with no associated user.' );
1027  }
1028  }
1029 
1030  $rec = self::getRevisionStore()->insertRevisionOn( $this->mRecord, $dbw );
1031 
1032  $this->mRecord = $rec;
1033  Assert::postcondition( $this->mRecord !== null, 'Failed to acquire a RevisionRecord' );
1034 
1035  return $rec->getId();
1036  }
1037 
1044  public static function base36Sha1( $text ) {
1045  wfDeprecated( __METHOD__, '1.31' );
1046  return SlotRecord::base36Sha1( $text );
1047  }
1048 
1066  public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
1067  wfDeprecated( __METHOD__, '1.35' );
1068 
1069  if ( !$user ) {
1070  global $wgUser;
1071  $user = $wgUser;
1072  }
1073 
1074  $comment = CommentStoreComment::newUnsavedComment( $summary, null );
1075 
1076  $title = Title::newFromID( $pageId, Title::READ_LATEST );
1077  if ( $title === null ) {
1078  return null;
1079  }
1080 
1081  $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
1082 
1083  return $rec ? new Revision( $rec ) : null;
1084  }
1085 
1098  public function userCan( $field, User $user = null ) {
1099  wfDeprecated( __METHOD__, '1.31' );
1100  if ( !$user ) {
1101  global $wgUser;
1102  $user = $wgUser;
1103  }
1104  return RevisionRecord::userCanBitfield( $this->mRecord->getVisibility(), $field, $user );
1105  }
1106 
1121  public static function userCanBitfield( $bitfield, $field, User $user = null,
1122  Title $title = null
1123  ) {
1124  wfDeprecated( __METHOD__, '1.31' );
1125  if ( !$user ) {
1126  global $wgUser;
1127  $user = $wgUser;
1128  }
1129 
1130  return RevisionRecord::userCanBitfield( $bitfield, $field, $user, $title );
1131  }
1132 
1143  public static function getTimestampFromId( $title, $id, $flags = 0 ) {
1144  wfDeprecated( __METHOD__, '1.35' );
1145  return self::getRevisionStore()->getTimestampFromId( $id, $flags );
1146  }
1147 
1157  public static function countByPageId( $db, $id ) {
1158  wfDeprecated( __METHOD__, '1.31' );
1159  return self::getRevisionStore()->countRevisionsByPageId( $db, $id );
1160  }
1161 
1171  public static function countByTitle( $db, $title ) {
1172  wfDeprecated( __METHOD__, '1.31' );
1173  return self::getRevisionStore()->countRevisionsByTitle( $db, $title );
1174  }
1175 
1192  public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
1193  wfDeprecated( __METHOD__, '1.24' );
1194  if ( is_int( $db ) ) {
1195  $db = wfGetDB( $db );
1196  }
1197 
1198  return self::getRevisionStore()->userWasLastToEdit( $db, $pageId, $userId, $since );
1199  }
1200 
1215  public static function newKnownCurrent( IDatabase $db, $pageIdOrTitle, $revId = 0 ) {
1216  wfDeprecated( __METHOD__, '1.31' );
1217  $title = $pageIdOrTitle instanceof Title
1218  ? $pageIdOrTitle
1219  : Title::newFromID( $pageIdOrTitle );
1220 
1221  if ( !$title ) {
1222  return false;
1223  }
1224 
1225  $record = self::getRevisionLookup()->getKnownCurrentRevision( $title, $revId );
1226  return $record ? new Revision( $record ) : false;
1227  }
1228 }
Revision\FOR_PUBLIC
const FOR_PUBLIC
Definition: Revision.php:53
Revision\newFromArchiveRow
static newFromArchiveRow( $row, $overrides=[])
Make a fake revision object from an archive table row.
Definition: Revision.php:182
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:47
Revision\getTimestamp
getTimestamp()
Definition: Revision.php:881
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:48
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:1215
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:668
Revision\RevisionRecord
Page revision base class.
Definition: RevisionRecord.php:46
Revision\SUPPRESSED_ALL
const SUPPRESSED_ALL
Definition: Revision.php:50
Revision\DELETED_COMMENT
const DELETED_COMMENT
Definition: Revision.php:46
Revision\newFromId
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition: Revision.php:120
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:639
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:1121
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:152
Revision\getSize
getSize()
Returns the length of the text in this revision, or null if unknown.
Definition: Revision.php:557
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:472
Revision\getContent
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
Definition: Revision.php:778
Revision\getPage
getPage()
Get the page ID.
Definition: Revision.php:621
Revision\getBlobStore
static getBlobStore( $wiki=false)
Definition: Revision.php:91
Revision\getRevisionText
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
Definition: Revision.php:943
Revision\getParentId
getParentId()
Get parent revision ID (the original previous page revision)
Definition: Revision.php:545
Revision\setTitle
setTitle( $title)
Set the title of the revision.
Definition: Revision.php:603
Revision\getContentHandler
getContentHandler()
Returns the content handler appropriate for this revision's content model.
Definition: Revision.php:868
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:334
Revision\getSerializedData
getSerializedData()
Get original serialized data (without checking view restrictions)
Definition: Revision.php:803
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1089
Revision\getRecentChange
getRecentChange( $flags=0)
Get the RC object belonging to the current revision, if there's one.
Definition: Revision.php:733
Revision\TEXT_CACHE_GROUP
const TEXT_CACHE_GROUP
Definition: Revision.php:57
Revision\isCurrent
isCurrent()
Definition: Revision.php:891
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:164
Revision\getSha1
getSha1()
Returns the base36 sha1 of the content in this revision, or null if unknown.
Definition: Revision.php:573
IDBAccessObject
Interface for database access objects.
Definition: IDBAccessObject.php:55
Revision\getId
getId()
Get revision ID.
Definition: Revision.php:455
Revision\getContentModel
getContentModel()
Returns the content model for the main slot of this revision.
Definition: Revision.php:821
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:1014
Revision\getRevisionFactory
static getRevisionFactory()
Definition: Revision.php:82
Revision\base36Sha1
static base36Sha1( $text)
Get the base 36 SHA-1 value for a string of text.
Definition: Revision.php:1044
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:54
Revision
Definition: Revision.php:39
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:142
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:58
Revision\SUPPRESSED_USER
const SUPPRESSED_USER
Definition: Revision.php:49
Revision\getQueryInfo
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
Definition: Revision.php:318
MWException
MediaWiki exception.
Definition: MWException.php:26
Revision\getNext
getNext()
Get next revision for this title.
Definition: Revision.php:916
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Definition: GlobalFunctions.php:1029
Revision\setUserIdAndName
setUserIdAndName( $id, $name)
Set the user ID/name.
Definition: Revision.php:495
Revision\getTimestampFromId
static getTimestampFromId( $title, $id, $flags=0)
Get rev_timestamp from rev_id, without loading the rest of the row.
Definition: Revision.php:1143
Revision\isUnpatrolled
isUnpatrolled()
Definition: Revision.php:717
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2464
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:260
Revision\compressRevisionText
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
Definition: Revision.php:980
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:592
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:608
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:1171
Revision\getPrevious
getPrevious()
Get previous revision for this title.
Definition: Revision.php:903
Revision\countByPageId
static countByPageId( $db, $id)
Get count of revisions per page...not very efficient.
Definition: Revision.php:1157
Revision\getRevisionStore
static getRevisionStore( $wiki=false)
Definition: Revision.php:63
Revision\ensureTitle
ensureTitle( $row, $queryFlags, $title=null)
Make sure we have some Title object for use by the constructor.
Definition: Revision.php:408
Revision\getTitle
getTitle()
Returns the title of the page associated with this entry.
Definition: Revision.php:590
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:1192
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:618
Revision\RevisionRecord\SUPPRESSED_USER
const SUPPRESSED_USER
Definition: RevisionRecord.php:53
$content
$content
Definition: router.php:76
Revision\RevisionRecord\DELETED_USER
const DELETED_USER
Definition: RevisionRecord.php:51
Revision\$mRecord
RevisionRecord $mRecord
Definition: Revision.php:42
Revision\MutableRevisionRecord
Definition: MutableRevisionRecord.php:43
Revision\getParentLengths
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
Definition: Revision.php:349
Revision\getVisibility
getVisibility()
Get the deletion bitfield of the revision.
Definition: Revision.php:757
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:529
Revision\isDeleted
isDeleted( $field)
Definition: Revision.php:745
Revision\newFromRow
static newFromRow( $row)
Definition: Revision.php:236
Revision\RAW
const RAW
Definition: Revision.php:55
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:281
Revision\getMainSlotRaw
getMainSlotRaw()
Definition: Revision.php:508
Revision\getContentFormat
getContentFormat()
Returns the content format for the main slot of this revision.
Definition: Revision.php:846
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:298
Revision\getComment
getComment( $audience=self::FOR_PUBLIC, User $user=null)
Definition: Revision.php:692
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:1066
Revision\__construct
__construct( $row, $queryFlags=0, Title $title=null)
Definition: Revision.php:364
Revision\isMinor
isMinor()
Definition: Revision.php:708
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:446
Revision\decompressRevisionText
static decompressRevisionText( $text, $flags)
Re-converts revision text according to it's flags.
Definition: Revision.php:994
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:279
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:54
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:473
Revision\RevisionRecord\FOR_THIS_USER
const FOR_THIS_USER
Definition: RevisionRecord.php:59
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:45
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:1098
Revision\SlotRecord
Value object representing a content slot associated with a page revision.
Definition: SlotRecord.php:39
Revision\getRevisionLookup
static getRevisionLookup()
Definition: Revision.php:75