MediaWiki REL1_31
Revision.php
Go to the documentation of this file.
1<?php
37
41class Revision implements IDBAccessObject {
42
44 protected $mRecord;
45
46 // Revision deletion constants
47 const DELETED_TEXT = RevisionRecord::DELETED_TEXT;
48 const DELETED_COMMENT = RevisionRecord::DELETED_COMMENT;
49 const DELETED_USER = RevisionRecord::DELETED_USER;
50 const DELETED_RESTRICTED = RevisionRecord::DELETED_RESTRICTED;
51 const SUPPRESSED_USER = RevisionRecord::SUPPRESSED_USER;
52 const SUPPRESSED_ALL = RevisionRecord::SUPPRESSED_ALL;
53
54 // Audience options for accessors
55 const FOR_PUBLIC = RevisionRecord::FOR_PUBLIC;
56 const FOR_THIS_USER = RevisionRecord::FOR_THIS_USER;
57 const RAW = RevisionRecord::RAW;
58
59 const TEXT_CACHE_GROUP = SqlBlobStore::TEXT_CACHE_GROUP;
60
64 protected static function getRevisionStore() {
65 return MediaWikiServices::getInstance()->getRevisionStore();
66 }
67
71 protected static function getRevisionLookup() {
72 return MediaWikiServices::getInstance()->getRevisionLookup();
73 }
74
78 protected static function getRevisionFactory() {
79 return MediaWikiServices::getInstance()->getRevisionFactory();
80 }
81
87 protected static function getBlobStore( $wiki = false ) {
88 $store = MediaWikiServices::getInstance()
89 ->getBlobStoreFactory()
90 ->newSqlBlobStore( $wiki );
91
92 if ( !$store instanceof SqlBlobStore ) {
93 throw new RuntimeException(
94 'The backwards compatibility code in Revision currently requires the BlobStore '
95 . 'service to be an SqlBlobStore instance, but it is a ' . get_class( $store )
96 );
97 }
98
99 return $store;
100 }
101
114 public static function newFromId( $id, $flags = 0 ) {
115 $rec = self::getRevisionLookup()->getRevisionById( $id, $flags );
116 return $rec === null ? null : new Revision( $rec, $flags );
117 }
118
133 public static function newFromTitle( LinkTarget $linkTarget, $id = 0, $flags = 0 ) {
134 $rec = self::getRevisionLookup()->getRevisionByTitle( $linkTarget, $id, $flags );
135 return $rec === null ? null : new Revision( $rec, $flags );
136 }
137
152 public static function newFromPageId( $pageId, $revId = 0, $flags = 0 ) {
153 $rec = self::getRevisionLookup()->getRevisionByPageId( $pageId, $revId, $flags );
154 return $rec === null ? null : new Revision( $rec, $flags );
155 }
156
167 public static function newFromArchiveRow( $row, $overrides = [] ) {
174 if ( array_key_exists( 'page', $overrides ) ) {
175 $overrides['page_id'] = $overrides['page'];
176 unset( $overrides['page'] );
177 }
178
184 $title = null;
185 if ( isset( $overrides['title'] ) ) {
186 if ( !( $overrides['title'] instanceof Title ) ) {
187 throw new MWException( 'title field override must contain a Title object.' );
188 }
189
190 $title = $overrides['title'];
191 }
192 if ( $title !== null ) {
193 if ( isset( $row->ar_namespace ) && isset( $row->ar_title ) ) {
194 $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
195 } else {
196 throw new InvalidArgumentException(
197 'A Title or ar_namespace and ar_title must be given'
198 );
199 }
200 }
201
202 $rec = self::getRevisionFactory()->newRevisionFromArchiveRow( $row, 0, $title, $overrides );
203 return new Revision( $rec, self::READ_NORMAL, $title );
204 }
205
218 public static function newFromRow( $row ) {
219 if ( is_array( $row ) ) {
220 $rec = self::getRevisionFactory()->newMutableRevisionFromArray( $row );
221 } else {
222 $rec = self::getRevisionFactory()->newRevisionFromRow( $row );
223 }
224
225 return new Revision( $rec );
226 }
227
238 public static function loadFromId( $db, $id ) {
239 wfDeprecated( __METHOD__, '1.31' ); // no known callers
240 $rec = self::getRevisionStore()->loadRevisionFromId( $db, $id );
241 return $rec === null ? null : new Revision( $rec );
242 }
243
256 public static function loadFromPageId( $db, $pageid, $id = 0 ) {
257 $rec = self::getRevisionStore()->loadRevisionFromPageId( $db, $pageid, $id );
258 return $rec === null ? null : new Revision( $rec );
259 }
260
273 public static function loadFromTitle( $db, $title, $id = 0 ) {
274 $rec = self::getRevisionStore()->loadRevisionFromTitle( $db, $title, $id );
275 return $rec === null ? null : new Revision( $rec );
276 }
277
291 public static function loadFromTimestamp( $db, $title, $timestamp ) {
292 $rec = self::getRevisionStore()->loadRevisionFromTimestamp( $db, $title, $timestamp );
293 return $rec === null ? null : new Revision( $rec );
294 }
295
305 public static function fetchRevision( LinkTarget $title ) {
306 wfDeprecated( __METHOD__, '1.31' );
307 return new FakeResultWrapper( [] );
308 }
309
317 public static function userJoinCond() {
319
320 wfDeprecated( __METHOD__, '1.31' );
322 // If code is using this instead of self::getQueryInfo(), there's
323 // no way the join it's trying to do can work once the old fields
324 // aren't being written anymore.
325 throw new BadMethodCallException(
326 'Cannot use ' . __METHOD__ . ' when $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH'
327 );
328 }
329
330 return [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ];
331 }
332
340 public static function pageJoinCond() {
341 wfDeprecated( __METHOD__, '1.31' );
342 return [ 'INNER JOIN', [ 'page_id = rev_page' ] ];
343 }
344
351 public static function selectFields() {
353
355 // If code is using this instead of self::getQueryInfo(), there's a
356 // decent chance it's going to try to directly access
357 // $row->rev_user or $row->rev_user_text and we can't give it
358 // useful values here once those aren't being written anymore.
359 throw new BadMethodCallException(
360 'Cannot use ' . __METHOD__ . ' when $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH'
361 );
362 }
363
364 wfDeprecated( __METHOD__, '1.31' );
365
366 $fields = [
367 'rev_id',
368 'rev_page',
369 'rev_text_id',
370 'rev_timestamp',
371 'rev_user_text',
372 'rev_user',
373 'rev_actor' => 'NULL',
374 'rev_minor_edit',
375 'rev_deleted',
376 'rev_len',
377 'rev_parent_id',
378 'rev_sha1',
379 ];
380
381 $fields += CommentStore::getStore()->getFields( 'rev_comment' );
382
384 $fields[] = 'rev_content_format';
385 $fields[] = 'rev_content_model';
386 }
387
388 return $fields;
389 }
390
397 public static function selectArchiveFields() {
399
401 // If code is using this instead of self::getQueryInfo(), there's a
402 // decent chance it's going to try to directly access
403 // $row->ar_user or $row->ar_user_text and we can't give it
404 // useful values here once those aren't being written anymore.
405 throw new BadMethodCallException(
406 'Cannot use ' . __METHOD__ . ' when $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH'
407 );
408 }
409
410 wfDeprecated( __METHOD__, '1.31' );
411
412 $fields = [
413 'ar_id',
414 'ar_page_id',
415 'ar_rev_id',
416 'ar_text_id',
417 'ar_timestamp',
418 'ar_user_text',
419 'ar_user',
420 'ar_actor' => 'NULL',
421 'ar_minor_edit',
422 'ar_deleted',
423 'ar_len',
424 'ar_parent_id',
425 'ar_sha1',
426 ];
427
428 $fields += CommentStore::getStore()->getFields( 'ar_comment' );
429
431 $fields[] = 'ar_content_format';
432 $fields[] = 'ar_content_model';
433 }
434 return $fields;
435 }
436
443 public static function selectTextFields() {
444 wfDeprecated( __METHOD__, '1.31' );
445 return [
446 'old_text',
447 'old_flags'
448 ];
449 }
450
456 public static function selectPageFields() {
457 wfDeprecated( __METHOD__, '1.31' );
458 return [
459 'page_namespace',
460 'page_title',
461 'page_id',
462 'page_latest',
463 'page_is_redirect',
464 'page_len',
465 ];
466 }
467
473 public static function selectUserFields() {
474 wfDeprecated( __METHOD__, '1.31' );
475 return [ 'user_name' ];
476 }
477
492 public static function getQueryInfo( $options = [] ) {
493 return self::getRevisionStore()->getQueryInfo( $options );
494 }
495
506 public static function getArchiveQueryInfo() {
507 return self::getRevisionStore()->getArchiveQueryInfo();
508 }
509
519 public static function getParentLengths( $db, array $revIds ) {
520 return self::getRevisionStore()->listRevisionSizes( $db, $revIds );
521 }
522
530 function __construct( $row, $queryFlags = 0, Title $title = null ) {
532
533 if ( $row instanceof RevisionRecord ) {
534 $this->mRecord = $row;
535 } elseif ( is_array( $row ) ) {
536 // If no user is specified, fall back to using the global user object, to stay
537 // compatible with pre-1.31 behavior.
538 if ( !isset( $row['user'] ) && !isset( $row['user_text'] ) ) {
539 $row['user'] = $wgUser;
540 }
541
542 $this->mRecord = self::getRevisionFactory()->newMutableRevisionFromArray(
543 $row,
544 $queryFlags,
545 $this->ensureTitle( $row, $queryFlags, $title )
546 );
547 } elseif ( is_object( $row ) ) {
548 $this->mRecord = self::getRevisionFactory()->newRevisionFromRow(
549 $row,
550 $queryFlags,
551 $this->ensureTitle( $row, $queryFlags, $title )
552 );
553 } else {
554 throw new InvalidArgumentException(
555 '$row must be a row object, an associative array, or a RevisionRecord'
556 );
557 }
558 }
559
570 private function ensureTitle( $row, $queryFlags, $title = null ) {
571 if ( $title ) {
572 return $title;
573 }
574
575 if ( is_array( $row ) ) {
576 if ( isset( $row['title'] ) ) {
577 if ( !( $row['title'] instanceof Title ) ) {
578 throw new MWException( 'title field must contain a Title object.' );
579 }
580
581 return $row['title'];
582 }
583
584 $pageId = isset( $row['page'] ) ? $row['page'] : 0;
585 $revId = isset( $row['id'] ) ? $row['id'] : 0;
586 } else {
587 $pageId = isset( $row->rev_page ) ? $row->rev_page : 0;
588 $revId = isset( $row->rev_id ) ? $row->rev_id : 0;
589 }
590
591 try {
592 $title = self::getRevisionStore()->getTitle( $pageId, $revId, $queryFlags );
593 } catch ( RevisionAccessException $ex ) {
594 // construct a dummy title!
595 wfLogWarning( __METHOD__ . ': ' . $ex->getMessage() );
596
597 // NOTE: this Title will only be used inside RevisionRecord
598 $title = Title::makeTitleSafe( NS_SPECIAL, "Badtitle/ID=$pageId" );
599 $title->resetArticleID( $pageId );
600 }
601
602 return $title;
603 }
604
608 public function getRevisionRecord() {
609 return $this->mRecord;
610 }
611
617 public function getId() {
618 return $this->mRecord->getId();
619 }
620
633 public function setId( $id ) {
634 if ( $this->mRecord instanceof MutableRevisionRecord ) {
635 $this->mRecord->setId( intval( $id ) );
636 } else {
637 throw new MWException( __METHOD__ . ' is not supported on this instance' );
638 }
639 }
640
655 public function setUserIdAndName( $id, $name ) {
656 if ( $this->mRecord instanceof MutableRevisionRecord ) {
657 $user = User::newFromAnyId( intval( $id ), $name, null );
658 $this->mRecord->setUser( $user );
659 } else {
660 throw new MWException( __METHOD__ . ' is not supported on this instance' );
661 }
662 }
663
667 private function getMainSlotRaw() {
668 return $this->mRecord->getSlot( 'main', RevisionRecord::RAW );
669 }
670
683 public function getTextId() {
684 $slot = $this->getMainSlotRaw();
685 return $slot->hasAddress()
686 ? self::getBlobStore()->getTextIdFromAddress( $slot->getAddress() )
687 : null;
688 }
689
696 public function getParentId() {
697 return $this->mRecord->getParentId();
698 }
699
705 public function getSize() {
706 try {
707 return $this->mRecord->getSize();
708 } catch ( RevisionAccessException $ex ) {
709 return null;
710 }
711 }
712
718 public function getSha1() {
719 try {
720 return $this->mRecord->getSha1();
721 } catch ( RevisionAccessException $ex ) {
722 return null;
723 }
724 }
725
734 public function getTitle() {
735 $linkTarget = $this->mRecord->getPageAsLinkTarget();
736 return Title::newFromLinkTarget( $linkTarget );
737 }
738
746 public function setTitle( $title ) {
747 if ( !$title->equals( $this->getTitle() ) ) {
748 throw new InvalidArgumentException(
749 $title->getPrefixedText()
750 . ' is not the same as '
751 . $this->mRecord->getPageAsLinkTarget()->__toString()
752 );
753 }
754 }
755
761 public function getPage() {
762 return $this->mRecord->getPageId();
763 }
764
778 public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
780
781 if ( $audience === self::FOR_THIS_USER && !$user ) {
782 $user = $wgUser;
783 }
784
785 $user = $this->mRecord->getUser( $audience, $user );
786 return $user ? $user->getId() : 0;
787 }
788
795 public function getRawUser() {
796 wfDeprecated( __METHOD__, '1.25' );
797 return $this->getUser( self::RAW );
798 }
799
813 public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
815
816 if ( $audience === self::FOR_THIS_USER && !$user ) {
817 $user = $wgUser;
818 }
819
820 $user = $this->mRecord->getUser( $audience, $user );
821 return $user ? $user->getName() : '';
822 }
823
830 public function getRawUserText() {
831 wfDeprecated( __METHOD__, '1.25' );
832 return $this->getUserText( self::RAW );
833 }
834
848 function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
850
851 if ( $audience === self::FOR_THIS_USER && !$user ) {
852 $user = $wgUser;
853 }
854
855 $comment = $this->mRecord->getComment( $audience, $user );
856 return $comment === null ? null : $comment->text;
857 }
858
865 public function getRawComment() {
866 wfDeprecated( __METHOD__, '1.25' );
867 return $this->getComment( self::RAW );
868 }
869
873 public function isMinor() {
874 return $this->mRecord->isMinor();
875 }
876
880 public function isUnpatrolled() {
881 return self::getRevisionStore()->getRcIdIfUnpatrolled( $this->mRecord );
882 }
883
893 public function getRecentChange( $flags = 0 ) {
894 return self::getRevisionStore()->getRecentChange( $this->mRecord, $flags );
895 }
896
902 public function isDeleted( $field ) {
903 return $this->mRecord->isDeleted( $field );
904 }
905
911 public function getVisibility() {
912 return $this->mRecord->getVisibility();
913 }
914
929 public function getContent( $audience = self::FOR_PUBLIC, User $user = null ) {
931
932 if ( $audience === self::FOR_THIS_USER && !$user ) {
933 $user = $wgUser;
934 }
935
936 try {
937 return $this->mRecord->getContent( 'main', $audience, $user );
938 }
939 catch ( RevisionAccessException $e ) {
940 return null;
941 }
942 }
943
952 public function getSerializedData() {
953 $slot = $this->getMainSlotRaw();
954 return $slot->getContent()->serialize();
955 }
956
969 public function getContentModel() {
970 return $this->getMainSlotRaw()->getModel();
971 }
972
984 public function getContentFormat() {
985 $format = $this->getMainSlotRaw()->getFormat();
986
987 if ( $format === null ) {
988 // if no format was stored along with the blob, fall back to default format
989 $format = $this->getContentHandler()->getDefaultFormat();
990 }
991
992 return $format;
993 }
994
1001 public function getContentHandler() {
1002 return ContentHandler::getForModelID( $this->getContentModel() );
1003 }
1004
1008 public function getTimestamp() {
1009 return $this->mRecord->getTimestamp();
1010 }
1011
1015 public function isCurrent() {
1016 return ( $this->mRecord instanceof RevisionStoreRecord ) && $this->mRecord->isCurrent();
1017 }
1018
1024 public function getPrevious() {
1025 $title = $this->getTitle();
1026 $rec = self::getRevisionLookup()->getPreviousRevision( $this->mRecord, $title );
1027 return $rec === null ? null : new Revision( $rec, self::READ_NORMAL, $title );
1028 }
1029
1035 public function getNext() {
1036 $title = $this->getTitle();
1037 $rec = self::getRevisionLookup()->getNextRevision( $this->mRecord, $title );
1038 return $rec === null ? null : new Revision( $rec, self::READ_NORMAL, $title );
1039 }
1040
1055 public static function getRevisionText( $row, $prefix = 'old_', $wiki = false ) {
1056 $textField = $prefix . 'text';
1057 $flagsField = $prefix . 'flags';
1058
1059 if ( isset( $row->$flagsField ) ) {
1060 $flags = explode( ',', $row->$flagsField );
1061 } else {
1062 $flags = [];
1063 }
1064
1065 if ( isset( $row->$textField ) ) {
1066 $text = $row->$textField;
1067 } else {
1068 return false;
1069 }
1070
1071 $cacheKey = isset( $row->old_id ) ? ( 'tt:' . $row->old_id ) : null;
1072
1073 return self::getBlobStore( $wiki )->expandBlob( $text, $flags, $cacheKey );
1074 }
1075
1086 public static function compressRevisionText( &$text ) {
1087 return self::getBlobStore()->compressData( $text );
1088 }
1089
1097 public static function decompressRevisionText( $text, $flags ) {
1098 return self::getBlobStore()->decompressData( $text, $flags );
1099 }
1100
1109 public function insertOn( $dbw ) {
1111
1112 // Note that $this->mRecord->getId() will typically return null here, but not always,
1113 // e.g. not when restoring a revision.
1114
1115 if ( $this->mRecord->getUser( RevisionRecord::RAW ) === null ) {
1116 if ( $this->mRecord instanceof MutableRevisionRecord ) {
1117 $this->mRecord->setUser( $wgUser );
1118 } else {
1119 throw new MWException( 'Cannot insert revision with no associated user.' );
1120 }
1121 }
1122
1123 $rec = self::getRevisionStore()->insertRevisionOn( $this->mRecord, $dbw );
1124
1125 $this->mRecord = $rec;
1126
1127 // Avoid PHP 7.1 warning of passing $this by reference
1128 $revision = $this;
1129 // TODO: hard-deprecate in 1.32 (or even 1.31?)
1130 Hooks::run( 'RevisionInsertComplete', [ &$revision, null, null ] );
1131
1132 return $rec->getId();
1133 }
1134
1140 public static function base36Sha1( $text ) {
1141 return SlotRecord::base36Sha1( $text );
1142 }
1143
1159 public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
1161 if ( !$user ) {
1162 $user = $wgUser;
1163 }
1164
1165 $comment = CommentStoreComment::newUnsavedComment( $summary, null );
1166
1167 $title = Title::newFromID( $pageId, Title::GAID_FOR_UPDATE );
1168 if ( $title === null ) {
1169 return null;
1170 }
1171
1172 $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
1173
1174 return new Revision( $rec );
1175 }
1176
1187 public function userCan( $field, User $user = null ) {
1188 return self::userCanBitfield( $this->getVisibility(), $field, $user );
1189 }
1190
1205 public static function userCanBitfield( $bitfield, $field, User $user = null,
1206 Title $title = null
1207 ) {
1209
1210 if ( !$user ) {
1211 $user = $wgUser;
1212 }
1213
1214 return RevisionRecord::userCanBitfield( $bitfield, $field, $user, $title );
1215 }
1216
1225 static function getTimestampFromId( $title, $id, $flags = 0 ) {
1226 return self::getRevisionStore()->getTimestampFromId( $title, $id, $flags );
1227 }
1228
1236 static function countByPageId( $db, $id ) {
1237 return self::getRevisionStore()->countRevisionsByPageId( $db, $id );
1238 }
1239
1247 static function countByTitle( $db, $title ) {
1248 return self::getRevisionStore()->countRevisionsByTitle( $db, $title );
1249 }
1250
1267 public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
1268 if ( is_int( $db ) ) {
1269 $db = wfGetDB( $db );
1270 }
1271
1272 return self::getRevisionStore()->userWasLastToEdit( $db, $pageId, $userId, $since );
1273 }
1274
1288 public static function newKnownCurrent( IDatabase $db, $pageIdOrTitle, $revId = 0 ) {
1289 $title = $pageIdOrTitle instanceof Title
1290 ? $pageIdOrTitle
1291 : Title::newFromID( $pageIdOrTitle );
1292
1293 if ( !$title ) {
1294 return false;
1295 }
1296
1297 $record = self::getRevisionLookup()->getKnownCurrentRevision( $title, $revId );
1298 return $record ? new Revision( $record ) : false;
1299 }
1300}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility.
int $wgActorTableSchemaMigrationStage
Actor table schema migration stage.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
$wgUser
Definition Setup.php:902
MediaWiki exception.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Mutable RevisionRecord implementation, for building new revision entries programmatically.
Exception representing a failure to look up a revision.
Page revision base class.
A RevisionRecord representing an existing revision persisted in the revision table.
Service for looking up page revisions.
Value object representing a content slot associated with a page revision.
Service for storing and loading Content objects.
getRecentChange( $flags=0)
Get the RC object belonging to the current revision, if there's one.
Definition Revision.php:893
getUserText( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's username if it's available to the specified audience.
Definition Revision.php:813
static getRevisionStore()
Definition Revision.php:64
getTitle()
Returns the title of the page associated with this entry.
Definition Revision.php:734
static selectArchiveFields()
Return the list of revision fields that should be selected to create a new revision from an archive r...
Definition Revision.php:397
getPrevious()
Get previous revision for this title.
ensureTitle( $row, $queryFlags, $title=null)
Make sure we have some Title object for use by the constructor.
Definition Revision.php:570
getSize()
Returns the length of the text in this revision, or null if unknown.
Definition Revision.php:705
getSerializedData()
Get original serialized data (without checking view restrictions)
Definition Revision.php:952
getId()
Get revision ID.
Definition Revision.php:617
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
getRawUser()
Fetch revision's user id without regard for the current user's permissions.
Definition Revision.php:795
static userJoinCond()
Return the value of a select() JOIN conds array for the user table.
Definition Revision.php:317
static decompressRevisionText( $text, $flags)
Re-converts revision text according to it's flags.
setUserIdAndName( $id, $name)
Set the user ID/name.
Definition Revision.php:655
getContentHandler()
Returns the content handler appropriate for this revision's content model.
static newKnownCurrent(IDatabase $db, $pageIdOrTitle, $revId=0)
Load a revision based on a known page ID and current revision ID from the DB.
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
getComment( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision comment if it's available to the specified audience.
Definition Revision.php:848
static loadFromTitle( $db, $title, $id=0)
Load either the current, or a specified, revision that's attached to a given page.
Definition Revision.php:273
getNext()
Get next revision for this title.
getTextId()
Get the ID of the row of the text table that contains the content of the revision's main slot,...
Definition Revision.php:683
static selectTextFields()
Return the list of text fields that should be selected to read the revision text.
Definition Revision.php:443
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:152
static selectPageFields()
Return the list of page fields that should be selected from page table.
Definition Revision.php:456
getMainSlotRaw()
Definition Revision.php:667
getContentFormat()
Returns the content format for the main slot of this revision.
Definition Revision.php:984
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
Definition Revision.php:351
static loadFromTimestamp( $db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
Definition Revision.php:291
static getRevisionFactory()
Definition Revision.php:78
getPage()
Get the page ID.
Definition Revision.php:761
static getArchiveQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new archived revision objec...
Definition Revision.php:506
static newFromRow( $row)
Definition Revision.php:218
static newNullRevision( $dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
static loadFromId( $db, $id)
Load a page revision from a given revision ID number.
Definition Revision.php:238
static getTimestampFromId( $title, $id, $flags=0)
Get rev_timestamp from rev_id, without loading the rest of the row.
RevisionRecord $mRecord
Definition Revision.php:44
static selectUserFields()
Return the list of user fields that should be selected from user table.
Definition Revision.php:473
getContentModel()
Returns the content model for the main slot of this revision.
Definition Revision.php:969
static countByPageId( $db, $id)
Get count of revisions per page...not very efficient.
getUser( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's user id if it's available to the specified audience.
Definition Revision.php:778
static newFromArchiveRow( $row, $overrides=[])
Make a fake revision object from an archive table row.
Definition Revision.php:167
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
Definition Revision.php:929
static countByTitle( $db, $title)
Get count of revisions per page...not very efficient.
static pageJoinCond()
Return the value of a select() page conds array for the page table.
Definition Revision.php:340
const DELETED_USER
Definition Revision.php:49
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
Definition Revision.php:492
const TEXT_CACHE_GROUP
Definition Revision.php:59
const DELETED_TEXT
Definition Revision.php:47
static base36Sha1( $text)
Get the base 36 SHA-1 value for a string of text.
getSha1()
Returns the base36 sha1 of the content in this revision, or null if unknown.
Definition Revision.php:718
const DELETED_RESTRICTED
Definition Revision.php:50
static loadFromPageId( $db, $pageid, $id=0)
Load either the current, or a specified, revision that's attached to a given page.
Definition Revision.php:256
getRawComment()
Fetch revision comment without regard for the current user's permissions.
Definition Revision.php:865
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,...
getVisibility()
Get the deletion bitfield of the revision.
Definition Revision.php:911
setTitle( $title)
Set the title of the revision.
Definition Revision.php:746
insertOn( $dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
__construct( $row, $queryFlags=0, Title $title=null)
Definition Revision.php:530
static userWasLastToEdit( $db, $pageId, $userId, $since)
Check if no edits were made by other users since the time a user started editing the page.
getRevisionRecord()
Definition Revision.php:608
getRawUserText()
Fetch revision's username without regard for view restrictions.
Definition Revision.php:830
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
Definition Revision.php:519
static getRevisionLookup()
Definition Revision.php:71
static fetchRevision(LinkTarget $title)
Return a wrapper for a series of database rows to fetch all of a given page's revisions in turn.
Definition Revision.php:305
isUnpatrolled()
Definition Revision.php:880
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision,...
const FOR_PUBLIC
Definition Revision.php:55
static getBlobStore( $wiki=false)
Definition Revision.php:87
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:133
getParentId()
Get parent revision ID (the original previous page revision)
Definition Revision.php:696
const SUPPRESSED_ALL
Definition Revision.php:52
setId( $id)
Set the revision ID.
Definition Revision.php:633
const RAW
Definition Revision.php:57
isDeleted( $field)
Definition Revision.php:902
const DELETED_COMMENT
Definition Revision.php:48
const FOR_THIS_USER
Definition Revision.php:56
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition Revision.php:114
const SUPPRESSED_USER
Definition Revision.php:51
Represents a title within MediaWiki.
Definition Title.php:39
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:53
static newFromAnyId( $userId, $userName, $actorId)
Static factory method for creation from an ID, name, and/or actor ID.
Definition User.php:657
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
Result wrapper for grabbing data queried from an IDatabase object.
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
const NS_SPECIAL
Definition Defines.php:63
const MIGRATION_WRITE_BOTH
Definition Defines.php:303
the array() calling protocol came about after MediaWiki 1.4rc1.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:2001
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:964
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:302
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition hooks.txt:247
returning false will NOT prevent logging $e
Definition hooks.txt:2176
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
Interface for database access objects.
Service for constructing revision objects.
Service for looking up page revisions.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38