27 private $revisionStore;
30 private $linkRendererFactory;
33 private $linkBatchFactory;
36 private $hookContainer;
39 private $loadBalancer;
42 private $actorMigration;
45 private $namespaceInfo;
48 private $commentFormatter;
70 $this->revisionStore = $revisionStore;
71 $this->linkRendererFactory = $linkRendererFactory;
72 $this->linkBatchFactory = $linkBatchFactory;
73 $this->hookContainer = $hookContainer;
74 $this->loadBalancer = $loadBalancer;
75 $this->actorMigration = $actorMigration;
76 $this->namespaceInfo = $namespaceInfo;
77 $this->commentFormatter = $commentFormatter;
91 private function getPagerParams(
int $limit,
string $segment ): array {
93 $seg = explode(
'|', $segment, 2 );
94 if ( count( $seg ) > 1 ) {
95 if ( $seg[0] ===
'after' ) {
98 } elseif ( $seg[0] ==
'before' ) {
109 'offset' => $segment,
128 string $segment =
'',
134 $paramArr = $this->getPagerParams( $limit, $segment );
135 $context->setRequest(
new FauxRequest( $paramArr ) );
138 $pager = $this->getContribsPager( $context, $target, [
140 'revisionsOnly' =>
true
145 if ( $pager->getNumRows() > 0 ) {
146 foreach ( $pager->mResult as $row ) {
148 if ( ++$count > $limit ) {
153 $revision = $this->revisionStore->newRevisionFromRow( $row, 0 );
154 $revisions[] = $revision;
155 if ( $row->ts_tags ) {
156 $tagNames = explode(
',', $row->ts_tags );
157 $tags[ $row->rev_id ] = $this->getContributionTags( $tagNames );
162 $deltas = $this->getContributionDeltas( $revisions );
165 'newest' => $pager->mIsFirst,
166 'oldest' => $pager->mIsLast,
170 $pager->mIsFirst =
false;
171 $pagingQueries = $pager->getPagingQueries();
173 $prev = $pagingQueries[
'prev'][
'offset'] ??
null;
174 $next = $pagingQueries[
'next'][
'offset'] ??
null;
176 $after = $prev ?
'after|' . $prev :
null;
177 $before = $next ?
'before|' . $next :
null;
181 if ( $paramArr[
'dir'] ===
'prev' ) {
182 $revisions = array_reverse( $revisions );
184 return new ContributionsSegment( $revisions, $tags, $before, $after, $deltas, $flags );
191 private function getContributionTags( array $tagNames ): array {
193 foreach ( $tagNames as $name ) {
196 $tagMetadata[$name] = $tagDisplay;
209 private function getContributionDeltas( $revisions ): array {
214 foreach ( $revisions as $revision ) {
215 $revId = $revision->getId();
216 $parentIds[$revId] = $revision->getParentId();
218 $parentSizes = $this->revisionStore->getRevisionSizes( $parentIds );
220 foreach ( $revisions as $revision ) {
221 $parentId = $revision->getParentId();
222 if ( $parentId === 0 ) {
223 $delta = $revision->getSize();
224 } elseif ( !isset( $parentSizes[$parentId] ) ) {
227 $delta = $revision->getSize() - $parentSizes[$parentId];
229 $deltas[ $revision->getId() ] = $delta;
249 $pager = $this->getContribsPager( $context, $user, [
253 $query = $pager->getQueryInfo();
255 $count = $pager->mDb->selectField(
267 private function getContribsPager(
275 $this->linkRendererFactory->create(),
276 $this->linkBatchFactory,
277 $this->hookContainer,
279 $this->actorMigration,
280 $this->revisionStore,
281 $this->namespaceInfo,
283 $this->commentFormatter
The Message class deals with fetching and processing of interface message into a variety of formats.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Group all the pieces relevant to the context of a request into one instance.
setAuthority(Authority $authority)
Interface for objects which can provide a MediaWiki context on request.