MediaWiki REL1_32
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 used anymore.
325 throw new BadMethodCallException(
326 'Cannot use ' . __METHOD__
327 . ' when $wgActorTableSchemaMigrationStage has SCHEMA_COMPAT_READ_NEW'
328 );
329 }
330
331 return [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ];
332 }
333
341 public static function pageJoinCond() {
342 wfDeprecated( __METHOD__, '1.31' );
343 return [ 'INNER JOIN', [ 'page_id = rev_page' ] ];
344 }
345
352 public static function selectFields() {
355
357 // If code is using this instead of self::getQueryInfo(), there's a
358 // decent chance it's going to try to directly access
359 // $row->rev_user or $row->rev_user_text and we can't give it
360 // useful values here once those aren't being used anymore.
361 throw new BadMethodCallException(
362 'Cannot use ' . __METHOD__
363 . ' when $wgActorTableSchemaMigrationStage has SCHEMA_COMPAT_READ_NEW'
364 );
365 }
366
368 // If code is using this instead of self::getQueryInfo(), there's a
369 // decent chance it's going to try to directly access
370 // $row->rev_text_id or $row->rev_content_model and we can't give it
371 // useful values here once those aren't being written anymore,
372 // and may not exist at all.
373 throw new BadMethodCallException(
374 'Cannot use ' . __METHOD__ . ' when $wgMultiContentRevisionSchemaMigrationStage '
375 . 'does not have SCHEMA_COMPAT_WRITE_OLD set.'
376 );
377 }
378
379 wfDeprecated( __METHOD__, '1.31' );
380
381 $fields = [
382 'rev_id',
383 'rev_page',
384 'rev_text_id',
385 'rev_timestamp',
386 'rev_user_text',
387 'rev_user',
388 'rev_actor' => 'NULL',
389 'rev_minor_edit',
390 'rev_deleted',
391 'rev_len',
392 'rev_parent_id',
393 'rev_sha1',
394 ];
395
396 $fields += CommentStore::getStore()->getFields( 'rev_comment' );
397
399 $fields[] = 'rev_content_format';
400 $fields[] = 'rev_content_model';
401 }
402
403 return $fields;
404 }
405
412 public static function selectArchiveFields() {
415
417 // If code is using this instead of self::getQueryInfo(), there's a
418 // decent chance it's going to try to directly access
419 // $row->ar_user or $row->ar_user_text and we can't give it
420 // useful values here once those aren't being used anymore.
421 throw new BadMethodCallException(
422 'Cannot use ' . __METHOD__
423 . ' when $wgActorTableSchemaMigrationStage has SCHEMA_COMPAT_READ_NEW'
424 );
425 }
426
428 // If code is using this instead of self::getQueryInfo(), there's a
429 // decent chance it's going to try to directly access
430 // $row->ar_text_id or $row->ar_content_model and we can't give it
431 // useful values here once those aren't being written anymore,
432 // and may not exist at all.
433 throw new BadMethodCallException(
434 'Cannot use ' . __METHOD__ . ' when $wgMultiContentRevisionSchemaMigrationStage '
435 . 'does not have SCHEMA_COMPAT_WRITE_OLD set.'
436 );
437 }
438
439 wfDeprecated( __METHOD__, '1.31' );
440
441 $fields = [
442 'ar_id',
443 'ar_page_id',
444 'ar_rev_id',
445 'ar_text_id',
446 'ar_timestamp',
447 'ar_user_text',
448 'ar_user',
449 'ar_actor' => 'NULL',
450 'ar_minor_edit',
451 'ar_deleted',
452 'ar_len',
453 'ar_parent_id',
454 'ar_sha1',
455 ];
456
457 $fields += CommentStore::getStore()->getFields( 'ar_comment' );
458
460 $fields[] = 'ar_content_format';
461 $fields[] = 'ar_content_model';
462 }
463 return $fields;
464 }
465
472 public static function selectTextFields() {
473 wfDeprecated( __METHOD__, '1.31' );
474 return [
475 'old_text',
476 'old_flags'
477 ];
478 }
479
485 public static function selectPageFields() {
486 wfDeprecated( __METHOD__, '1.31' );
487 return [
488 'page_namespace',
489 'page_title',
490 'page_id',
491 'page_latest',
492 'page_is_redirect',
493 'page_len',
494 ];
495 }
496
502 public static function selectUserFields() {
503 wfDeprecated( __METHOD__, '1.31' );
504 return [ 'user_name' ];
505 }
506
521 public static function getQueryInfo( $options = [] ) {
522 return self::getRevisionStore()->getQueryInfo( $options );
523 }
524
535 public static function getArchiveQueryInfo() {
536 return self::getRevisionStore()->getArchiveQueryInfo();
537 }
538
548 public static function getParentLengths( $db, array $revIds ) {
549 return self::getRevisionStore()->listRevisionSizes( $db, $revIds );
550 }
551
559 function __construct( $row, $queryFlags = 0, Title $title = null ) {
560 global $wgUser;
561
562 if ( $row instanceof RevisionRecord ) {
563 $this->mRecord = $row;
564 } elseif ( is_array( $row ) ) {
565 // If no user is specified, fall back to using the global user object, to stay
566 // compatible with pre-1.31 behavior.
567 if ( !isset( $row['user'] ) && !isset( $row['user_text'] ) ) {
568 $row['user'] = $wgUser;
569 }
570
571 $this->mRecord = self::getRevisionFactory()->newMutableRevisionFromArray(
572 $row,
573 $queryFlags,
574 $this->ensureTitle( $row, $queryFlags, $title )
575 );
576 } elseif ( is_object( $row ) ) {
577 $this->mRecord = self::getRevisionFactory()->newRevisionFromRow(
578 $row,
579 $queryFlags,
580 $this->ensureTitle( $row, $queryFlags, $title )
581 );
582 } else {
583 throw new InvalidArgumentException(
584 '$row must be a row object, an associative array, or a RevisionRecord'
585 );
586 }
587 }
588
599 private function ensureTitle( $row, $queryFlags, $title = null ) {
600 if ( $title ) {
601 return $title;
602 }
603
604 if ( is_array( $row ) ) {
605 if ( isset( $row['title'] ) ) {
606 if ( !( $row['title'] instanceof Title ) ) {
607 throw new MWException( 'title field must contain a Title object.' );
608 }
609
610 return $row['title'];
611 }
612
613 $pageId = $row['page'] ?? 0;
614 $revId = $row['id'] ?? 0;
615 } else {
616 $pageId = $row->rev_page ?? 0;
617 $revId = $row->rev_id ?? 0;
618 }
619
620 try {
621 $title = self::getRevisionStore()->getTitle( $pageId, $revId, $queryFlags );
622 } catch ( RevisionAccessException $ex ) {
623 // construct a dummy title!
624 wfLogWarning( __METHOD__ . ': ' . $ex->getMessage() );
625
626 // NOTE: this Title will only be used inside RevisionRecord
627 $title = Title::makeTitleSafe( NS_SPECIAL, "Badtitle/ID=$pageId" );
628 $title->resetArticleID( $pageId );
629 }
630
631 return $title;
632 }
633
637 public function getRevisionRecord() {
638 return $this->mRecord;
639 }
640
646 public function getId() {
647 return $this->mRecord->getId();
648 }
649
662 public function setId( $id ) {
663 if ( $this->mRecord instanceof MutableRevisionRecord ) {
664 $this->mRecord->setId( intval( $id ) );
665 } else {
666 throw new MWException( __METHOD__ . ' is not supported on this instance' );
667 }
668 }
669
684 public function setUserIdAndName( $id, $name ) {
685 if ( $this->mRecord instanceof MutableRevisionRecord ) {
686 $user = User::newFromAnyId( intval( $id ), $name, null );
687 $this->mRecord->setUser( $user );
688 } else {
689 throw new MWException( __METHOD__ . ' is not supported on this instance' );
690 }
691 }
692
696 private function getMainSlotRaw() {
697 return $this->mRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW );
698 }
699
712 public function getTextId() {
713 $slot = $this->getMainSlotRaw();
714 return $slot->hasAddress()
715 ? self::getBlobStore()->getTextIdFromAddress( $slot->getAddress() )
716 : null;
717 }
718
725 public function getParentId() {
726 return $this->mRecord->getParentId();
727 }
728
734 public function getSize() {
735 try {
736 return $this->mRecord->getSize();
737 } catch ( RevisionAccessException $ex ) {
738 return null;
739 }
740 }
741
747 public function getSha1() {
748 try {
749 return $this->mRecord->getSha1();
750 } catch ( RevisionAccessException $ex ) {
751 return null;
752 }
753 }
754
763 public function getTitle() {
764 $linkTarget = $this->mRecord->getPageAsLinkTarget();
765 return Title::newFromLinkTarget( $linkTarget );
766 }
767
775 public function setTitle( $title ) {
776 if ( !$title->equals( $this->getTitle() ) ) {
777 throw new InvalidArgumentException(
778 $title->getPrefixedText()
779 . ' is not the same as '
780 . $this->mRecord->getPageAsLinkTarget()->__toString()
781 );
782 }
783 }
784
790 public function getPage() {
791 return $this->mRecord->getPageId();
792 }
793
807 public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
808 global $wgUser;
809
810 if ( $audience === self::FOR_THIS_USER && !$user ) {
811 $user = $wgUser;
812 }
813
814 $user = $this->mRecord->getUser( $audience, $user );
815 return $user ? $user->getId() : 0;
816 }
817
831 public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
832 global $wgUser;
833
834 if ( $audience === self::FOR_THIS_USER && !$user ) {
835 $user = $wgUser;
836 }
837
838 $user = $this->mRecord->getUser( $audience, $user );
839 return $user ? $user->getName() : '';
840 }
854 function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
855 global $wgUser;
856
857 if ( $audience === self::FOR_THIS_USER && !$user ) {
858 $user = $wgUser;
859 }
860
861 $comment = $this->mRecord->getComment( $audience, $user );
862 return $comment === null ? null : $comment->text;
863 }
864
868 public function isMinor() {
869 return $this->mRecord->isMinor();
870 }
871
875 public function isUnpatrolled() {
876 return self::getRevisionStore()->getRcIdIfUnpatrolled( $this->mRecord );
877 }
878
888 public function getRecentChange( $flags = 0 ) {
889 return self::getRevisionStore()->getRecentChange( $this->mRecord, $flags );
890 }
891
897 public function isDeleted( $field ) {
898 return $this->mRecord->isDeleted( $field );
899 }
900
906 public function getVisibility() {
907 return $this->mRecord->getVisibility();
908 }
909
924 public function getContent( $audience = self::FOR_PUBLIC, User $user = null ) {
925 global $wgUser;
926
927 if ( $audience === self::FOR_THIS_USER && !$user ) {
928 $user = $wgUser;
929 }
930
931 try {
932 return $this->mRecord->getContent( SlotRecord::MAIN, $audience, $user );
933 }
934 catch ( RevisionAccessException $e ) {
935 return null;
936 }
937 }
938
947 public function getSerializedData() {
948 $slot = $this->getMainSlotRaw();
949 return $slot->getContent()->serialize();
950 }
951
964 public function getContentModel() {
965 return $this->getMainSlotRaw()->getModel();
966 }
967
979 public function getContentFormat() {
980 $format = $this->getMainSlotRaw()->getFormat();
981
982 if ( $format === null ) {
983 // if no format was stored along with the blob, fall back to default format
984 $format = $this->getContentHandler()->getDefaultFormat();
985 }
986
987 return $format;
988 }
989
996 public function getContentHandler() {
997 return ContentHandler::getForModelID( $this->getContentModel() );
998 }
999
1003 public function getTimestamp() {
1004 return $this->mRecord->getTimestamp();
1005 }
1006
1010 public function isCurrent() {
1011 return ( $this->mRecord instanceof RevisionStoreRecord ) && $this->mRecord->isCurrent();
1012 }
1013
1019 public function getPrevious() {
1020 $title = $this->getTitle();
1021 $rec = self::getRevisionLookup()->getPreviousRevision( $this->mRecord, $title );
1022 return $rec === null ? null : new Revision( $rec, self::READ_NORMAL, $title );
1023 }
1024
1030 public function getNext() {
1031 $title = $this->getTitle();
1032 $rec = self::getRevisionLookup()->getNextRevision( $this->mRecord, $title );
1033 return $rec === null ? null : new Revision( $rec, self::READ_NORMAL, $title );
1034 }
1035
1050 public static function getRevisionText( $row, $prefix = 'old_', $wiki = false ) {
1051 $textField = $prefix . 'text';
1052 $flagsField = $prefix . 'flags';
1053
1054 if ( isset( $row->$flagsField ) ) {
1055 $flags = explode( ',', $row->$flagsField );
1056 } else {
1057 $flags = [];
1058 }
1059
1060 if ( isset( $row->$textField ) ) {
1061 $text = $row->$textField;
1062 } else {
1063 return false;
1064 }
1065
1066 $cacheKey = isset( $row->old_id )
1067 ? SqlBlobStore::makeAddressFromTextId( $row->old_id )
1068 : null;
1069
1070 $revisionText = self::getBlobStore( $wiki )->expandBlob( $text, $flags, $cacheKey );
1071
1072 if ( $revisionText === false ) {
1073 if ( isset( $row->old_id ) ) {
1074 wfLogWarning( __METHOD__ . ": Bad data in text row {$row->old_id}! " );
1075 } else {
1076 wfLogWarning( __METHOD__ . ": Bad data in text row! " );
1077 }
1078 return false;
1079 }
1080
1081 return $revisionText;
1082 }
1083
1094 public static function compressRevisionText( &$text ) {
1095 return self::getBlobStore()->compressData( $text );
1096 }
1097
1105 public static function decompressRevisionText( $text, $flags ) {
1106 if ( $text === false ) {
1107 // Text failed to be fetched; nothing to do
1108 return false;
1109 }
1110
1111 return self::getBlobStore()->decompressData( $text, $flags );
1112 }
1113
1122 public function insertOn( $dbw ) {
1123 global $wgUser;
1124
1125 // Note that $this->mRecord->getId() will typically return null here, but not always,
1126 // e.g. not when restoring a revision.
1127
1128 if ( $this->mRecord->getUser( RevisionRecord::RAW ) === null ) {
1129 if ( $this->mRecord instanceof MutableRevisionRecord ) {
1130 $this->mRecord->setUser( $wgUser );
1131 } else {
1132 throw new MWException( 'Cannot insert revision with no associated user.' );
1133 }
1134 }
1135
1136 $rec = self::getRevisionStore()->insertRevisionOn( $this->mRecord, $dbw );
1137
1138 $this->mRecord = $rec;
1139
1140 // Avoid PHP 7.1 warning of passing $this by reference
1141 $revision = $this;
1142
1143 return $rec->getId();
1144 }
1145
1151 public static function base36Sha1( $text ) {
1152 return SlotRecord::base36Sha1( $text );
1153 }
1154
1170 public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
1171 global $wgUser;
1172 if ( !$user ) {
1173 $user = $wgUser;
1174 }
1175
1176 $comment = CommentStoreComment::newUnsavedComment( $summary, null );
1177
1178 $title = Title::newFromID( $pageId, Title::GAID_FOR_UPDATE );
1179 if ( $title === null ) {
1180 return null;
1181 }
1182
1183 $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
1184
1185 return $rec ? new Revision( $rec ) : null;
1186 }
1187
1198 public function userCan( $field, User $user = null ) {
1199 return self::userCanBitfield( $this->getVisibility(), $field, $user );
1200 }
1201
1216 public static function userCanBitfield( $bitfield, $field, User $user = null,
1217 Title $title = null
1218 ) {
1219 global $wgUser;
1220
1221 if ( !$user ) {
1222 $user = $wgUser;
1223 }
1224
1225 return RevisionRecord::userCanBitfield( $bitfield, $field, $user, $title );
1226 }
1227
1236 static function getTimestampFromId( $title, $id, $flags = 0 ) {
1237 return self::getRevisionStore()->getTimestampFromId( $title, $id, $flags );
1238 }
1239
1247 static function countByPageId( $db, $id ) {
1248 return self::getRevisionStore()->countRevisionsByPageId( $db, $id );
1249 }
1250
1258 static function countByTitle( $db, $title ) {
1259 return self::getRevisionStore()->countRevisionsByTitle( $db, $title );
1260 }
1261
1278 public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
1279 if ( is_int( $db ) ) {
1280 $db = wfGetDB( $db );
1281 }
1282
1283 return self::getRevisionStore()->userWasLastToEdit( $db, $pageId, $userId, $since );
1284 }
1285
1299 public static function newKnownCurrent( IDatabase $db, $pageIdOrTitle, $revId = 0 ) {
1300 $title = $pageIdOrTitle instanceof Title
1301 ? $pageIdOrTitle
1302 : Title::newFromID( $pageIdOrTitle );
1303
1304 if ( !$title ) {
1305 return false;
1306 }
1307
1308 $record = self::getRevisionLookup()->getKnownCurrentRevision( $title, $revId );
1309 return $record ? new Revision( $record ) : false;
1310 }
1311}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
int $wgMultiContentRevisionSchemaMigrationStage
RevisionStore table schema migration stage (content, slots, content_models & slot_roles tables).
$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.
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:888
getUserText( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's username if it's available to the specified audience.
Definition Revision.php:831
static getRevisionStore()
Definition Revision.php:64
getTitle()
Returns the title of the page associated with this entry.
Definition Revision.php:763
static selectArchiveFields()
Return the list of revision fields that should be selected to create a new revision from an archive r...
Definition Revision.php:412
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:599
getSize()
Returns the length of the text in this revision, or null if unknown.
Definition Revision.php:734
getSerializedData()
Get original serialized data (without checking view restrictions)
Definition Revision.php:947
getId()
Get revision ID.
Definition Revision.php:646
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
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:684
getContentHandler()
Returns the content handler appropriate for this revision's content model.
Definition Revision.php:996
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:854
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:712
static selectTextFields()
Return the list of text fields that should be selected to read the revision text.
Definition Revision.php:472
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:485
getMainSlotRaw()
Definition Revision.php:696
getContentFormat()
Returns the content format for the main slot of this revision.
Definition Revision.php:979
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
Definition Revision.php:352
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:790
static getArchiveQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new archived revision objec...
Definition Revision.php:535
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:502
getContentModel()
Returns the content model for the main slot of this revision.
Definition Revision.php:964
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:807
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:924
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:341
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:521
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:747
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
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:906
setTitle( $title)
Set the title of the revision.
Definition Revision.php:775
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:559
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:637
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
Definition Revision.php:548
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:875
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:725
const SUPPRESSED_ALL
Definition Revision.php:52
setId( $id)
Set the revision ID.
Definition Revision.php:662
const RAW
Definition Revision.php:57
isDeleted( $field)
Definition Revision.php:897
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:47
static newFromAnyId( $userId, $userName, $actorId)
Static factory method for creation from an ID, name, and/or actor ID.
Definition User.php:682
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.
const SCHEMA_COMPAT_READ_NEW
Definition Defines.php:287
const SCHEMA_COMPAT_WRITE_OLD
Definition Defines.php:284
const NS_SPECIAL
Definition Defines.php:53
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:2050
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:994
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:2226
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))