MediaWiki  master
RevisionArchiveRecord.php
Go to the documentation of this file.
1 <?php
23 namespace MediaWiki\Revision;
24 
27 use Title;
28 use User;
30 
41 
45  protected $mArchiveId;
46 
60  function __construct(
61  Title $title,
62  UserIdentity $user,
63  CommentStoreComment $comment,
64  $row,
65  RevisionSlots $slots,
66  $wikiId = false
67  ) {
68  parent::__construct( $title, $slots, $wikiId );
69  Assert::parameterType( 'object', $row, '$row' );
70 
71  $timestamp = wfTimestamp( TS_MW, $row->ar_timestamp );
72  Assert::parameter( is_string( $timestamp ), '$row->rev_timestamp', 'must be a valid timestamp' );
73 
74  $this->mArchiveId = intval( $row->ar_id );
75 
76  // NOTE: ar_page_id may be different from $this->mTitle->getArticleID() in some cases,
77  // notably when a partially restored page has been moved, and a new page has been created
78  // with the same title. Archive rows for that title will then have the wrong page id.
79  $this->mPageId = isset( $row->ar_page_id ) ? intval( $row->ar_page_id ) : $title->getArticleID();
80 
81  // NOTE: ar_parent_id = 0 indicates that there is no parent revision, while null
82  // indicates that the parent revision is unknown. As per MW 1.31, the database schema
83  // allows ar_parent_id to be NULL.
84  $this->mParentId = isset( $row->ar_parent_id ) ? intval( $row->ar_parent_id ) : null;
85  $this->mId = isset( $row->ar_rev_id ) ? intval( $row->ar_rev_id ) : null;
86  $this->mComment = $comment;
87  $this->mUser = $user;
88  $this->mTimestamp = $timestamp;
89  $this->mMinorEdit = boolval( $row->ar_minor_edit );
90  $this->mDeleted = intval( $row->ar_deleted );
91  $this->mSize = isset( $row->ar_len ) ? intval( $row->ar_len ) : null;
92  $this->mSha1 = !empty( $row->ar_sha1 ) ? $row->ar_sha1 : null;
93  }
94 
100  public function getArchiveId() {
101  return $this->mArchiveId;
102  }
103 
108  public function getId() {
109  // overwritten just to refine the contract specification.
110  return parent::getId();
111  }
112 
117  public function getSize() {
118  // If length is null, calculate and remember it (potentially SLOW!).
119  // This is for compatibility with old database rows that don't have the field set.
120  if ( $this->mSize === null ) {
121  $this->mSize = $this->mSlots->computeSize();
122  }
123 
124  return $this->mSize;
125  }
126 
131  public function getSha1() {
132  // If hash is null, calculate it and remember (potentially SLOW!)
133  // This is for compatibility with old database rows that don't have the field set.
134  if ( $this->mSha1 === null ) {
135  $this->mSha1 = $this->mSlots->computeSha1();
136  }
137 
138  return $this->mSha1;
139  }
140 
147  public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
148  // overwritten just to add a guarantee to the contract
149  return parent::getUser( $audience, $user );
150  }
151 
158  public function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
159  // overwritten just to add a guarantee to the contract
160  return parent::getComment( $audience, $user );
161  }
162 
166  public function getTimestamp() {
167  // overwritten just to add a guarantee to the contract
168  return parent::getTimestamp();
169  }
170 
176  public function isReadyForInsertion() {
177  return true;
178  }
179 
180 }
181 
186 class_alias( RevisionArchiveRecord::class, 'MediaWiki\Storage\RevisionArchiveRecord' );
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:3005
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
__construct(Title $title, UserIdentity $user, CommentStoreComment $comment, $row, RevisionSlots $slots, $wikiId=false)
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
Definition: User.php:50
Created by PhpStorm.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:780
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
A RevisionRecord representing a revision of a deleted page persisted in the archive table...
getUser( $audience=self::FOR_PUBLIC, User $user=null)
getComment( $audience=self::FOR_PUBLIC, User $user=null)
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:35
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
Page revision base class.
Value object representing the set of slots belonging to a revision.
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1473