52 parent::__construct( $query, $moduleName,
'pt' );
53 $this->commentStore = $commentStore;
54 $this->commentFormatter = $commentFormatter;
62 $this->run( $resultPageSet );
69 private function run( $resultPageSet =
null ) {
73 $this->
addFields( [
'pt_namespace',
'pt_title',
'pt_timestamp' ] );
75 $prop = array_fill_keys( $params[
'prop'],
true );
76 $this->
addFieldsIf(
'pt_user', isset( $prop[
'user'] ) || isset( $prop[
'userid'] ) );
77 $this->
addFieldsIf(
'pt_expiry', isset( $prop[
'expiry'] ) );
78 $this->
addFieldsIf(
'pt_create_perm', isset( $prop[
'level'] ) );
80 if ( isset( $prop[
'comment'] ) || isset( $prop[
'parsedcomment'] ) ) {
81 $commentQuery = $this->commentStore->getJoin(
'pt_reason' );
82 $this->
addTables( $commentQuery[
'tables'] );
83 $this->
addFields( $commentQuery[
'fields'] );
88 $this->
addWhereFld(
'pt_namespace', $params[
'namespace'] );
89 $this->
addWhereFld(
'pt_create_perm', $params[
'level'] );
92 $this->
addWhereRange(
'pt_namespace', $params[
'dir'],
null,
null );
93 $this->
addWhereRange(
'pt_title', $params[
'dir'],
null,
null );
95 if ( $params[
'continue'] !==
null ) {
97 $op = ( $params[
'dir'] ===
'newer' ?
'>=' :
'<=' );
99 $this->
addWhere( $db->buildComparison( $op, [
100 'pt_timestamp' => $db->timestamp( $cont[0] ),
101 'pt_namespace' => $cont[1],
102 'pt_title' => $cont[2],
106 if ( isset( $prop[
'user'] ) ) {
114 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
115 $res = $this->
select( __METHOD__ );
117 if ( $resultPageSet ===
null ) {
119 if ( isset( $prop[
'parsedcomment'] ) ) {
120 $formattedComments = $this->commentFormatter->formatItems(
121 $this->commentFormatter->rows( $res )
122 ->commentKey(
'pt_reason' )
123 ->namespaceField(
'pt_namespace' )
124 ->titleField(
'pt_title' )
134 foreach ( $res as $rowOffset => $row ) {
135 if ( ++$count > $params[
'limit'] ) {
139 "$row->pt_timestamp|$row->pt_namespace|$row->pt_title"
144 $title = Title::makeTitle( $row->pt_namespace, $row->pt_title );
145 if ( $resultPageSet ===
null ) {
148 if ( isset( $prop[
'timestamp'] ) ) {
149 $vals[
'timestamp'] =
wfTimestamp( TS_ISO_8601, $row->pt_timestamp );
152 if ( isset( $prop[
'user'] ) && $row->user_name !==
null ) {
153 $vals[
'user'] = $row->user_name;
156 if ( isset( $prop[
'userid'] ) || isset( $prop[
'user'] ) ) {
157 $vals[
'userid'] = (int)$row->pt_user;
160 if ( isset( $prop[
'comment'] ) ) {
161 $vals[
'comment'] = $this->commentStore->getComment(
'pt_reason', $row )->text;
164 if ( isset( $prop[
'parsedcomment'] ) ) {
166 $vals[
'parsedcomment'] = $formattedComments[$rowOffset];
169 if ( isset( $prop[
'expiry'] ) ) {
173 if ( isset( $prop[
'level'] ) ) {
174 $vals[
'level'] = $row->pt_create_perm;
177 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
180 "$row->pt_timestamp|$row->pt_namespace|$row->pt_title"
189 if ( $resultPageSet ===
null ) {
190 $result->addIndexedTagName(
195 $resultPageSet->populateFromTitles( $titles );
200 if ( $params[
'prop'] !==
null && in_array(
'parsedcomment', $params[
'prop'] ) ) {
202 return 'anon-public-user-private';
211 ParamValidator::PARAM_ISMULTI =>
true,
212 ParamValidator::PARAM_TYPE =>
'namespace',
215 ParamValidator::PARAM_ISMULTI =>
true,
216 ParamValidator::PARAM_TYPE => array_diff(
217 $this->
getConfig()->
get( MainConfigNames::RestrictionLevels ), [
'' ] )
220 ParamValidator::PARAM_DEFAULT => 10,
221 ParamValidator::PARAM_TYPE =>
'limit',
222 IntegerDef::PARAM_MIN => 1,
227 ParamValidator::PARAM_DEFAULT =>
'older',
228 ParamValidator::PARAM_TYPE => [
234 'newer' =>
'api-help-paramvalue-direction-newer',
235 'older' =>
'api-help-paramvalue-direction-older',
239 ParamValidator::PARAM_TYPE =>
'timestamp'
242 ParamValidator::PARAM_TYPE =>
'timestamp'
245 ParamValidator::PARAM_ISMULTI =>
true,
246 ParamValidator::PARAM_DEFAULT =>
'timestamp|level',
247 ParamValidator::PARAM_TYPE => [
266 'action=query&list=protectedtitles'
267 =>
'apihelp-query+protectedtitles-example-simple',
268 'action=query&generator=protectedtitles&gptnamespace=0&prop=linkshere'
269 =>
'apihelp-query+protectedtitles-example-generator',
274 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Protectedtitles';
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
const LIMIT_BIG1
Fast query, standard limit.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
addWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.
addFields( $value)
Add a set of fields to select to the internal array.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
getDB()
Get the Query database connection (read-only)
executeGenderCacheFromResultWrapper(IResultWrapper $res, $fname=__METHOD__, $fieldPrefix='page')
Preprocess the result set to fill the GenderCache with the necessary information before using self::a...
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
addWhere( $value)
Add a set of WHERE clauses to the internal array.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
Query module to enumerate all create-protected pages.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getHelpUrls()
Return links to more detailed help pages about the module.
executeGenerator( $resultPageSet)
Execute this module as a generator.
__construct(ApiQuery $query, $moduleName, CommentStore $commentStore, RowCommentFormatter $commentFormatter)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getExamplesMessages()
Returns usage examples for this module.
This is the main query class.
static formatExpiry( $expiry, $infinity='infinity')
Format an expiry timestamp for API output.
A class containing constants representing the names of configuration variables.