15use Wikimedia\Assert\Assert;
64 $this->me = $this->
getConfig()[
'mode'] ===
'me';
76 $user = RequestContext::getMain()->getUser();
77 if ( $user->isAnon() ) {
87 Assert::invariant( $name !==
null,
'"name" parameter must be given if mode is not "me"' );
89 if ( $this->userNameUtils->isIP( $name ) ) {
94 $user->setName( $name );
98 $user = $this->userFactory->newFromName( $name );
105 if ( !$user->isRegistered() ) {
107 new MessageValue(
'rest-nonexistent-user', [ $user->getName() ] ), 404
119 $performer = RequestContext::getMain()->getUser();
125 $contributionsSegment =
126 $this->contributionsLookup->getContributions( $target, $limit, $performer, $segment, $tag );
131 $response = $urls + [
'revisions' => $revisions ];
146 $id = $revision->getId();
149 "comment" => $revision->getComment()->text,
150 "timestamp" =>
wfTimestamp( TS_ISO_8601, $revision->getTimestamp() ),
152 "size" => $revision->getSize(),
155 "id" => $revision->getPageId(),
156 "key" => $revision->getPageAsLinkTarget()->getDBkey(),
157 "title" => $revision->getPageAsLinkTarget()->getText()
161 return $revisionsData;
174 $query = [
'limit' => $limit,
'tag' => $tag ];
175 $pathParams = [
'name' => $name ];
178 $urls[
'older'] =
null;
180 $urls[
'older'] = $this->
getRouteUrl( $pathParams, $query + [
'segment' => $segment->
getBefore() ] );
183 $urls[
'newer'] = $this->
getRouteUrl( $pathParams, $query + [
'segment' => $segment->
getAfter() ] );
184 $urls[
'latest'] = $this->
getRouteUrl( $pathParams, $query );
191 self::PARAM_SOURCE =>
'path',
192 ParamValidator::PARAM_TYPE =>
'string',
193 ParamValidator::PARAM_REQUIRED => false
196 self::PARAM_SOURCE =>
'query',
197 ParamValidator::PARAM_TYPE =>
'integer',
198 ParamValidator::PARAM_REQUIRED =>
false,
199 ParamValidator::PARAM_DEFAULT => self::MAX_LIMIT,
200 IntegerDef::PARAM_MIN => 1,
201 IntegerDef::PARAM_MAX => self::MAX_LIMIT,
204 self::PARAM_SOURCE =>
'query',
205 ParamValidator::PARAM_TYPE =>
'string',
206 ParamValidator::PARAM_REQUIRED =>
false,
207 ParamValidator::PARAM_DEFAULT =>
''
210 self::PARAM_SOURCE =>
'query',
211 ParamValidator::PARAM_TYPE =>
'string',
212 ParamValidator::PARAM_REQUIRED =>
false,
213 ParamValidator::PARAM_DEFAULT =>
null,
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Group all the pieces relevant to the context of a request into one instance @newable.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...