Skip to content

Commit 6857ae8

Browse files
committed
refs #42591, allow adjust limit row by global constant
1 parent 773d526 commit 6857ae8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

CRM/Utils/REST.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ class CRM_Utils_REST {
3636
const LAST_HIT = 'rest_lasthit';
3737
const RATE_LIMIT = 0.2;
3838

39+
/**
40+
* Response row limit per request
41+
*/
42+
static $limitRows = 100;
43+
3944
/**
4045
* Number of seconds we should let a REST process idle
4146
* @static
@@ -395,8 +400,11 @@ static function process(&$args, $params = array()) {
395400
if (isset($options['limit']) && !CRM_Utils_Rule::integer($options['limit'])) {
396401
return self::error('limit in options should be integer.');
397402
}
398-
if (isset($options['limit']) && $options['limit'] > 100) {
399-
return self::error('limit in options can\'t not larger than 100.');
403+
if (defined('CIVICRM_REST_LIMIT_ROWS') && CRM_Utils_Rule::positiveInteger(CIVICRM_REST_LIMIT_ROWS) && CIVICRM_REST_LIMIT_ROWS > self::$limitRows) {
404+
self::$limitRows = CIVICRM_REST_LIMIT_ROWS;
405+
}
406+
if (isset($options['limit']) && $options['limit'] > self::$limitRows) {
407+
return self::error('limit in options can\'t not larger than '.self::$limitRows.'.');
400408
}
401409
if (isset($options['offset']) && !CRM_Utils_Rule::integer($options['offset'])) {
402410
return self::error('offset in options should be integer.');

0 commit comments

Comments
 (0)