@@ -797,16 +797,16 @@ public function destroy($useMasterKey = false)
797
797
*
798
798
* @param array $objects Objects to destroy.
799
799
* @param bool $useMasterKey Whether to use the master key or not.
800
+ * @param int $batchSize Number of objects to process per request
800
801
*
801
802
* @throws ParseAggregateException
802
803
*/
803
- public static function destroyAll(array $objects, $useMasterKey = false)
804
+ public static function destroyAll(array $objects, $useMasterKey = false, $batchSize = 40 )
804
805
{
805
806
$errors = [];
806
807
$objects = array_values($objects); // To support non-ordered arrays
807
808
$count = count($objects);
808
809
if ($count) {
809
- $batchSize = 40;
810
810
$processed = 0;
811
811
$currentBatch = [];
812
812
$currentcount = 0;
@@ -1153,23 +1153,25 @@ public function save($useMasterKey = false)
1153
1153
*
1154
1154
* @param array $list
1155
1155
* @param bool $useMasterKey Whether to use the Master Key.
1156
+ * @param int $batchSize Number of objects to process per request
1156
1157
*/
1157
- public static function saveAll($list, $useMasterKey = false)
1158
+ public static function saveAll($list, $useMasterKey = false, $batchSize = 40 )
1158
1159
{
1159
- static::deepSave($list, $useMasterKey);
1160
+ static::deepSave($list, $useMasterKey, $batchSize );
1160
1161
}
1161
1162
1162
1163
/**
1163
1164
* Save object and unsaved children within.
1164
1165
*
1165
1166
* @param ParseObject|array $target
1166
1167
* @param bool $useMasterKey Whether to use the Master Key.
1168
+ * @param int $batchSize Number of objects to process per request
1167
1169
*
1168
1170
* @throws Exception
1169
1171
* @throws ParseAggregateException
1170
1172
* @throws ParseException
1171
1173
*/
1172
- private static function deepSave($target, $useMasterKey = false)
1174
+ private static function deepSave($target, $useMasterKey = false, $batchSize = 40 )
1173
1175
{
1174
1176
$unsavedChildren = [];
1175
1177
$unsavedFiles = [];
@@ -1197,7 +1199,7 @@ private static function deepSave($target, $useMasterKey = false)
1197
1199
$newRemaining = [];
1198
1200
1199
1201
foreach ($remaining as $key => &$object) {
1200
- if (count($batch) > 40 ) {
1202
+ if (count($batch) > $batchSize ) {
1201
1203
$newRemaining[] = $object;
1202
1204
continue;
1203
1205
}
0 commit comments