Go to the documentation of this file.
33 if ( !$user->isLoggedIn() ) {
34 $this->
dieWithError(
'watchlistanontext',
'notloggedin' );
47 if ( !isset( $params[
'title'] ) ) {
49 $res = $pageSet->getInvalidTitlesAndRevisions( [
57 foreach ( $pageSet->getMissingTitles() as
$title ) {
63 foreach ( $pageSet->getGoodTitles() as
$title ) {
70 $extraParams = array_keys( array_filter( $pageSet->extractRequestParams(),
function ( $x ) {
71 return $x !==
null && $x !==
false;
77 'apierror-invalidparammix-cannotusewith',
79 $pageSet->encodeParamName( $extraParams[0] )
87 $this->
dieWithError( [
'invalidtitle', $params[
'title'] ] );
94 $continuationManager->setContinuationIntoResult( $this->
getResult() );
98 $compatibilityMode =
false
100 if ( !
$title->isWatchable() ) {
101 return [
'title' =>
$title->getPrefixedText(),
'watchable' => 0 ];
104 $res = [
'title' =>
$title->getPrefixedText() ];
106 if ( $params[
'unwatch'] ) {
115 if ( $compatibilityMode ) {
120 if ( !
$res[
'warnings'] ) {
121 unset(
$res[
'warnings'] );
133 if ( $this->mPageSet ===
null ) {
164 $result += $this->
getPageSet()->getFinalParams( $flags );
172 'action=watch&titles=Main_Page&token=123ABC'
173 =>
'apihelp-watch-example-watch',
174 'action=watch&titles=Main_Page&unwatch=&token=123ABC'
175 =>
'apihelp-watch-example-unwatch',
176 'action=watch&generator=allpages&gapnamespace=0&token=123ABC'
177 =>
'apihelp-watch-example-generator',
182 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Watch';
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
getPageSet()
Get a cached instance of an ApiPageSet object.
getHelpUrls()
Return links to more detailed help pages about the module.
API module to allow users to watch a page.
This manages continuation state.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
static doUnwatch(Title $title, User $user)
Unwatch a page.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
checkUserRightsAny( $rights, $user=null)
Helper function for permission-denied errors.
setContinuationManager(ApiContinuationManager $manager=null)
Set the continuation manager.
getAllowedParams( $flags=0)
This class contains a list of pages that the client has requested.
This abstract class implements many basic API functions, and is the base of all API classes.
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
static doWatch(Title $title, User $user, $checkRights=User::CHECK_USER_RIGHTS)
Watch a page.
mustBePosted()
Indicates whether this module must be called with a POST request.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
watchTitle(Title $title, User $user, array $params, $compatibilityMode=false)
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
Represents a title within MediaWiki.
isWriteMode()
Indicates whether this module requires write mode.
needsToken()
Returns the token type this module requires in order to execute.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
getModuleName()
Get the name of the module being executed by this instance.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getExamplesMessages()
Returns usage examples for this module.
getErrorFormatter()
Get the error formatter.