ApiQueryUserContributions.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <?php
  2. /**
  3. *
  4. *
  5. * Created on Oct 16, 2006
  6. *
  7. * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  22. * http://www.gnu.org/copyleft/gpl.html
  23. *
  24. * @file
  25. */
  26. /**
  27. * This query action adds a list of a specified user's contributions to the output.
  28. *
  29. * @ingroup API
  30. */
  31. class ApiQueryContributions extends ApiQueryBase {
  32. public function __construct( ApiQuery $query, $moduleName ) {
  33. parent::__construct( $query, $moduleName, 'uc' );
  34. }
  35. private $params, $prefixMode, $userprefix, $multiUserMode, $idMode, $usernames, $userids,
  36. $parentLens, $commentStore;
  37. private $fld_ids = false, $fld_title = false, $fld_timestamp = false,
  38. $fld_comment = false, $fld_parsedcomment = false, $fld_flags = false,
  39. $fld_patrolled = false, $fld_tags = false, $fld_size = false, $fld_sizediff = false;
  40. public function execute() {
  41. // Parse some parameters
  42. $this->params = $this->extractRequestParams();
  43. $this->commentStore = new CommentStore( 'rev_comment' );
  44. $prop = array_flip( $this->params['prop'] );
  45. $this->fld_ids = isset( $prop['ids'] );
  46. $this->fld_title = isset( $prop['title'] );
  47. $this->fld_comment = isset( $prop['comment'] );
  48. $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
  49. $this->fld_size = isset( $prop['size'] );
  50. $this->fld_sizediff = isset( $prop['sizediff'] );
  51. $this->fld_flags = isset( $prop['flags'] );
  52. $this->fld_timestamp = isset( $prop['timestamp'] );
  53. $this->fld_patrolled = isset( $prop['patrolled'] );
  54. $this->fld_tags = isset( $prop['tags'] );
  55. // Most of this code will use the 'contributions' group DB, which can map to replica DBs
  56. // with extra user based indexes or partioning by user. The additional metadata
  57. // queries should use a regular replica DB since the lookup pattern is not all by user.
  58. $dbSecondary = $this->getDB(); // any random replica DB
  59. // TODO: if the query is going only against the revision table, should this be done?
  60. $this->selectNamedDB( 'contributions', DB_REPLICA, 'contributions' );
  61. $this->requireOnlyOneParameter( $this->params, 'userprefix', 'userids', 'user' );
  62. $this->idMode = false;
  63. if ( isset( $this->params['userprefix'] ) ) {
  64. $this->prefixMode = true;
  65. $this->multiUserMode = true;
  66. $this->userprefix = $this->params['userprefix'];
  67. } elseif ( isset( $this->params['userids'] ) ) {
  68. $this->userids = [];
  69. if ( !count( $this->params['userids'] ) ) {
  70. $encParamName = $this->encodeParamName( 'userids' );
  71. $this->dieWithError( [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName" );
  72. }
  73. foreach ( $this->params['userids'] as $uid ) {
  74. if ( $uid <= 0 ) {
  75. $this->dieWithError( [ 'apierror-invaliduserid', $uid ], 'invaliduserid' );
  76. }
  77. $this->userids[] = $uid;
  78. }
  79. $this->prefixMode = false;
  80. $this->multiUserMode = ( count( $this->params['userids'] ) > 1 );
  81. $this->idMode = true;
  82. } else {
  83. $anyIPs = false;
  84. $this->userids = [];
  85. $this->usernames = [];
  86. if ( !count( $this->params['user'] ) ) {
  87. $encParamName = $this->encodeParamName( 'user' );
  88. $this->dieWithError(
  89. [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName"
  90. );
  91. }
  92. foreach ( $this->params['user'] as $u ) {
  93. if ( $u === '' ) {
  94. $encParamName = $this->encodeParamName( 'user' );
  95. $this->dieWithError(
  96. [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName"
  97. );
  98. }
  99. if ( User::isIP( $u ) ) {
  100. $anyIPs = true;
  101. $this->usernames[] = $u;
  102. } else {
  103. $name = User::getCanonicalName( $u, 'valid' );
  104. if ( $name === false ) {
  105. $encParamName = $this->encodeParamName( 'user' );
  106. $this->dieWithError(
  107. [ 'apierror-baduser', $encParamName, wfEscapeWikiText( $u ) ], "baduser_$encParamName"
  108. );
  109. }
  110. $this->usernames[] = $name;
  111. }
  112. }
  113. $this->prefixMode = false;
  114. $this->multiUserMode = ( count( $this->params['user'] ) > 1 );
  115. if ( !$anyIPs ) {
  116. $dbr = $this->getDB();
  117. $res = $dbr->select( 'user', 'user_id', [ 'user_name' => $this->usernames ], __METHOD__ );
  118. foreach ( $res as $row ) {
  119. $this->userids[] = $row->user_id;
  120. }
  121. $this->idMode = count( $this->userids ) === count( $this->usernames );
  122. }
  123. }
  124. $this->prepareQuery();
  125. $hookData = [];
  126. // Do the actual query.
  127. $res = $this->select( __METHOD__, [], $hookData );
  128. if ( $this->fld_sizediff ) {
  129. $revIds = [];
  130. foreach ( $res as $row ) {
  131. if ( $row->rev_parent_id ) {
  132. $revIds[] = $row->rev_parent_id;
  133. }
  134. }
  135. $this->parentLens = Revision::getParentLengths( $dbSecondary, $revIds );
  136. $res->rewind(); // reset
  137. }
  138. // Initialise some variables
  139. $count = 0;
  140. $limit = $this->params['limit'];
  141. // Fetch each row
  142. foreach ( $res as $row ) {
  143. if ( ++$count > $limit ) {
  144. // We've reached the one extra which shows that there are
  145. // additional pages to be had. Stop here...
  146. $this->setContinueEnumParameter( 'continue', $this->continueStr( $row ) );
  147. break;
  148. }
  149. $vals = $this->extractRowInfo( $row );
  150. $fit = $this->processRow( $row, $vals, $hookData ) &&
  151. $this->getResult()->addValue( [ 'query', $this->getModuleName() ], null, $vals );
  152. if ( !$fit ) {
  153. $this->setContinueEnumParameter( 'continue', $this->continueStr( $row ) );
  154. break;
  155. }
  156. }
  157. $this->getResult()->addIndexedTagName(
  158. [ 'query', $this->getModuleName() ],
  159. 'item'
  160. );
  161. }
  162. /**
  163. * Prepares the query and returns the limit of rows requested
  164. */
  165. private function prepareQuery() {
  166. // We're after the revision table, and the corresponding page
  167. // row for anything we retrieve. We may also need the
  168. // recentchanges row and/or tag summary row.
  169. $user = $this->getUser();
  170. $tables = [ 'page', 'revision' ]; // Order may change
  171. $this->addWhere( 'page_id=rev_page' );
  172. // Handle continue parameter
  173. if ( !is_null( $this->params['continue'] ) ) {
  174. $continue = explode( '|', $this->params['continue'] );
  175. $db = $this->getDB();
  176. if ( $this->multiUserMode ) {
  177. $this->dieContinueUsageIf( count( $continue ) != 4 );
  178. $modeFlag = array_shift( $continue );
  179. $this->dieContinueUsageIf( !in_array( $modeFlag, [ 'id', 'name' ] ) );
  180. if ( $this->idMode && $modeFlag === 'name' ) {
  181. // The users were created since this query started, but we
  182. // can't go back and change modes now. So just keep on with
  183. // name mode.
  184. $this->idMode = false;
  185. }
  186. $this->dieContinueUsageIf( ( $modeFlag === 'id' ) !== $this->idMode );
  187. $userField = $this->idMode ? 'rev_user' : 'rev_user_text';
  188. $encUser = $db->addQuotes( array_shift( $continue ) );
  189. } else {
  190. $this->dieContinueUsageIf( count( $continue ) != 2 );
  191. }
  192. $encTS = $db->addQuotes( $db->timestamp( $continue[0] ) );
  193. $encId = (int)$continue[1];
  194. $this->dieContinueUsageIf( $encId != $continue[1] );
  195. $op = ( $this->params['dir'] == 'older' ? '<' : '>' );
  196. if ( $this->multiUserMode ) {
  197. $this->addWhere(
  198. "$userField $op $encUser OR " .
  199. "($userField = $encUser AND " .
  200. "(rev_timestamp $op $encTS OR " .
  201. "(rev_timestamp = $encTS AND " .
  202. "rev_id $op= $encId)))"
  203. );
  204. } else {
  205. $this->addWhere(
  206. "rev_timestamp $op $encTS OR " .
  207. "(rev_timestamp = $encTS AND " .
  208. "rev_id $op= $encId)"
  209. );
  210. }
  211. }
  212. // Don't include any revisions where we're not supposed to be able to
  213. // see the username.
  214. if ( !$user->isAllowed( 'deletedhistory' ) ) {
  215. $bitmask = Revision::DELETED_USER;
  216. } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
  217. $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
  218. } else {
  219. $bitmask = 0;
  220. }
  221. if ( $bitmask ) {
  222. $this->addWhere( $this->getDB()->bitAnd( 'rev_deleted', $bitmask ) . " != $bitmask" );
  223. }
  224. // We only want pages by the specified users.
  225. if ( $this->prefixMode ) {
  226. $this->addWhere( 'rev_user_text' .
  227. $this->getDB()->buildLike( $this->userprefix, $this->getDB()->anyString() ) );
  228. } elseif ( $this->idMode ) {
  229. $this->addWhereFld( 'rev_user', $this->userids );
  230. } else {
  231. $this->addWhereFld( 'rev_user_text', $this->usernames );
  232. }
  233. // ... and in the specified timeframe.
  234. // Ensure the same sort order for rev_user/rev_user_text and rev_timestamp
  235. // so our query is indexed
  236. if ( $this->multiUserMode ) {
  237. $this->addWhereRange( $this->idMode ? 'rev_user' : 'rev_user_text',
  238. $this->params['dir'], null, null );
  239. }
  240. $this->addTimestampWhereRange( 'rev_timestamp',
  241. $this->params['dir'], $this->params['start'], $this->params['end'] );
  242. // Include in ORDER BY for uniqueness
  243. $this->addWhereRange( 'rev_id', $this->params['dir'], null, null );
  244. $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
  245. $show = $this->params['show'];
  246. if ( $this->params['toponly'] ) { // deprecated/old param
  247. $show[] = 'top';
  248. }
  249. if ( !is_null( $show ) ) {
  250. $show = array_flip( $show );
  251. if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
  252. || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
  253. || ( isset( $show['top'] ) && isset( $show['!top'] ) )
  254. || ( isset( $show['new'] ) && isset( $show['!new'] ) )
  255. ) {
  256. $this->dieWithError( 'apierror-show' );
  257. }
  258. $this->addWhereIf( 'rev_minor_edit = 0', isset( $show['!minor'] ) );
  259. $this->addWhereIf( 'rev_minor_edit != 0', isset( $show['minor'] ) );
  260. $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
  261. $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
  262. $this->addWhereIf( 'rev_id != page_latest', isset( $show['!top'] ) );
  263. $this->addWhereIf( 'rev_id = page_latest', isset( $show['top'] ) );
  264. $this->addWhereIf( 'rev_parent_id != 0', isset( $show['!new'] ) );
  265. $this->addWhereIf( 'rev_parent_id = 0', isset( $show['new'] ) );
  266. }
  267. $this->addOption( 'LIMIT', $this->params['limit'] + 1 );
  268. // Mandatory fields: timestamp allows request continuation
  269. // ns+title checks if the user has access rights for this page
  270. // user_text is necessary if multiple users were specified
  271. $this->addFields( [
  272. 'rev_id',
  273. 'rev_timestamp',
  274. 'page_namespace',
  275. 'page_title',
  276. 'rev_user',
  277. 'rev_user_text',
  278. 'rev_deleted'
  279. ] );
  280. if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ||
  281. $this->fld_patrolled
  282. ) {
  283. if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
  284. $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'permissiondenied' );
  285. }
  286. // Use a redundant join condition on both
  287. // timestamp and ID so we can use the timestamp
  288. // index
  289. $index['recentchanges'] = 'rc_user_text';
  290. if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) {
  291. // Put the tables in the right order for
  292. // STRAIGHT_JOIN
  293. $tables = [ 'revision', 'recentchanges', 'page' ];
  294. $this->addOption( 'STRAIGHT_JOIN' );
  295. $this->addWhere( 'rc_user_text=rev_user_text' );
  296. $this->addWhere( 'rc_timestamp=rev_timestamp' );
  297. $this->addWhere( 'rc_this_oldid=rev_id' );
  298. } else {
  299. $tables[] = 'recentchanges';
  300. $this->addJoinConds( [ 'recentchanges' => [
  301. 'LEFT JOIN', [
  302. 'rc_user_text=rev_user_text',
  303. 'rc_timestamp=rev_timestamp',
  304. 'rc_this_oldid=rev_id' ] ] ] );
  305. }
  306. }
  307. $this->addTables( $tables );
  308. $this->addFieldsIf( 'rev_page', $this->fld_ids );
  309. $this->addFieldsIf( 'page_latest', $this->fld_flags );
  310. // $this->addFieldsIf( 'rev_text_id', $this->fld_ids ); // Should this field be exposed?
  311. $this->addFieldsIf( 'rev_len', $this->fld_size || $this->fld_sizediff );
  312. $this->addFieldsIf( 'rev_minor_edit', $this->fld_flags );
  313. $this->addFieldsIf( 'rev_parent_id', $this->fld_flags || $this->fld_sizediff || $this->fld_ids );
  314. $this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled );
  315. if ( $this->fld_comment || $this->fld_parsedcomment ) {
  316. $commentQuery = $this->commentStore->getJoin();
  317. $this->addTables( $commentQuery['tables'] );
  318. $this->addFields( $commentQuery['fields'] );
  319. $this->addJoinConds( $commentQuery['joins'] );
  320. }
  321. if ( $this->fld_tags ) {
  322. $this->addTables( 'tag_summary' );
  323. $this->addJoinConds(
  324. [ 'tag_summary' => [ 'LEFT JOIN', [ 'rev_id=ts_rev_id' ] ] ]
  325. );
  326. $this->addFields( 'ts_tags' );
  327. }
  328. if ( isset( $this->params['tag'] ) ) {
  329. $this->addTables( 'change_tag' );
  330. $this->addJoinConds(
  331. [ 'change_tag' => [ 'INNER JOIN', [ 'rev_id=ct_rev_id' ] ] ]
  332. );
  333. $this->addWhereFld( 'ct_tag', $this->params['tag'] );
  334. }
  335. if ( isset( $index ) ) {
  336. $this->addOption( 'USE INDEX', $index );
  337. }
  338. }
  339. /**
  340. * Extract fields from the database row and append them to a result array
  341. *
  342. * @param stdClass $row
  343. * @return array
  344. */
  345. private function extractRowInfo( $row ) {
  346. $vals = [];
  347. $anyHidden = false;
  348. if ( $row->rev_deleted & Revision::DELETED_TEXT ) {
  349. $vals['texthidden'] = true;
  350. $anyHidden = true;
  351. }
  352. // Any rows where we can't view the user were filtered out in the query.
  353. $vals['userid'] = (int)$row->rev_user;
  354. $vals['user'] = $row->rev_user_text;
  355. if ( $row->rev_deleted & Revision::DELETED_USER ) {
  356. $vals['userhidden'] = true;
  357. $anyHidden = true;
  358. }
  359. if ( $this->fld_ids ) {
  360. $vals['pageid'] = intval( $row->rev_page );
  361. $vals['revid'] = intval( $row->rev_id );
  362. // $vals['textid'] = intval( $row->rev_text_id ); // todo: Should this field be exposed?
  363. if ( !is_null( $row->rev_parent_id ) ) {
  364. $vals['parentid'] = intval( $row->rev_parent_id );
  365. }
  366. }
  367. $title = Title::makeTitle( $row->page_namespace, $row->page_title );
  368. if ( $this->fld_title ) {
  369. ApiQueryBase::addTitleInfo( $vals, $title );
  370. }
  371. if ( $this->fld_timestamp ) {
  372. $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rev_timestamp );
  373. }
  374. if ( $this->fld_flags ) {
  375. $vals['new'] = $row->rev_parent_id == 0 && !is_null( $row->rev_parent_id );
  376. $vals['minor'] = (bool)$row->rev_minor_edit;
  377. $vals['top'] = $row->page_latest == $row->rev_id;
  378. }
  379. if ( $this->fld_comment || $this->fld_parsedcomment ) {
  380. if ( $row->rev_deleted & Revision::DELETED_COMMENT ) {
  381. $vals['commenthidden'] = true;
  382. $anyHidden = true;
  383. }
  384. $userCanView = Revision::userCanBitfield(
  385. $row->rev_deleted,
  386. Revision::DELETED_COMMENT, $this->getUser()
  387. );
  388. if ( $userCanView ) {
  389. $comment = $this->commentStore->getComment( $row )->text;
  390. if ( $this->fld_comment ) {
  391. $vals['comment'] = $comment;
  392. }
  393. if ( $this->fld_parsedcomment ) {
  394. $vals['parsedcomment'] = Linker::formatComment( $comment, $title );
  395. }
  396. }
  397. }
  398. if ( $this->fld_patrolled ) {
  399. $vals['patrolled'] = (bool)$row->rc_patrolled;
  400. }
  401. if ( $this->fld_size && !is_null( $row->rev_len ) ) {
  402. $vals['size'] = intval( $row->rev_len );
  403. }
  404. if ( $this->fld_sizediff
  405. && !is_null( $row->rev_len )
  406. && !is_null( $row->rev_parent_id )
  407. ) {
  408. $parentLen = isset( $this->parentLens[$row->rev_parent_id] )
  409. ? $this->parentLens[$row->rev_parent_id]
  410. : 0;
  411. $vals['sizediff'] = intval( $row->rev_len - $parentLen );
  412. }
  413. if ( $this->fld_tags ) {
  414. if ( $row->ts_tags ) {
  415. $tags = explode( ',', $row->ts_tags );
  416. ApiResult::setIndexedTagName( $tags, 'tag' );
  417. $vals['tags'] = $tags;
  418. } else {
  419. $vals['tags'] = [];
  420. }
  421. }
  422. if ( $anyHidden && $row->rev_deleted & Revision::DELETED_RESTRICTED ) {
  423. $vals['suppressed'] = true;
  424. }
  425. return $vals;
  426. }
  427. private function continueStr( $row ) {
  428. if ( $this->multiUserMode ) {
  429. if ( $this->idMode ) {
  430. return "id|$row->rev_user|$row->rev_timestamp|$row->rev_id";
  431. } else {
  432. return "name|$row->rev_user_text|$row->rev_timestamp|$row->rev_id";
  433. }
  434. } else {
  435. return "$row->rev_timestamp|$row->rev_id";
  436. }
  437. }
  438. public function getCacheMode( $params ) {
  439. // This module provides access to deleted revisions and patrol flags if
  440. // the requester is logged in
  441. return 'anon-public-user-private';
  442. }
  443. public function getAllowedParams() {
  444. return [
  445. 'limit' => [
  446. ApiBase::PARAM_DFLT => 10,
  447. ApiBase::PARAM_TYPE => 'limit',
  448. ApiBase::PARAM_MIN => 1,
  449. ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
  450. ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
  451. ],
  452. 'start' => [
  453. ApiBase::PARAM_TYPE => 'timestamp'
  454. ],
  455. 'end' => [
  456. ApiBase::PARAM_TYPE => 'timestamp'
  457. ],
  458. 'continue' => [
  459. ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
  460. ],
  461. 'user' => [
  462. ApiBase::PARAM_TYPE => 'user',
  463. ApiBase::PARAM_ISMULTI => true
  464. ],
  465. 'userids' => [
  466. ApiBase::PARAM_TYPE => 'integer',
  467. ApiBase::PARAM_ISMULTI => true
  468. ],
  469. 'userprefix' => null,
  470. 'dir' => [
  471. ApiBase::PARAM_DFLT => 'older',
  472. ApiBase::PARAM_TYPE => [
  473. 'newer',
  474. 'older'
  475. ],
  476. ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
  477. ],
  478. 'namespace' => [
  479. ApiBase::PARAM_ISMULTI => true,
  480. ApiBase::PARAM_TYPE => 'namespace'
  481. ],
  482. 'prop' => [
  483. ApiBase::PARAM_ISMULTI => true,
  484. ApiBase::PARAM_DFLT => 'ids|title|timestamp|comment|size|flags',
  485. ApiBase::PARAM_TYPE => [
  486. 'ids',
  487. 'title',
  488. 'timestamp',
  489. 'comment',
  490. 'parsedcomment',
  491. 'size',
  492. 'sizediff',
  493. 'flags',
  494. 'patrolled',
  495. 'tags'
  496. ],
  497. ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
  498. ],
  499. 'show' => [
  500. ApiBase::PARAM_ISMULTI => true,
  501. ApiBase::PARAM_TYPE => [
  502. 'minor',
  503. '!minor',
  504. 'patrolled',
  505. '!patrolled',
  506. 'top',
  507. '!top',
  508. 'new',
  509. '!new',
  510. ],
  511. ApiBase::PARAM_HELP_MSG => [
  512. 'apihelp-query+usercontribs-param-show',
  513. $this->getConfig()->get( 'RCMaxAge' )
  514. ],
  515. ],
  516. 'tag' => null,
  517. 'toponly' => [
  518. ApiBase::PARAM_DFLT => false,
  519. ApiBase::PARAM_DEPRECATED => true,
  520. ],
  521. ];
  522. }
  523. protected function getExamplesMessages() {
  524. return [
  525. 'action=query&list=usercontribs&ucuser=Example'
  526. => 'apihelp-query+usercontribs-example-user',
  527. 'action=query&list=usercontribs&ucuserprefix=192.0.2.'
  528. => 'apihelp-query+usercontribs-example-ipprefix',
  529. ];
  530. }
  531. public function getHelpUrls() {
  532. return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Usercontribs';
  533. }
  534. }