PHP deprecation warning due wrong order of function parameters

With PHP 8.0 I got the following PHP Deprecation message

```
PHP Deprecated:  Required parameter $limit follows optional parameter $ids in src/Worker/UpdateContacts.php on line 104
```

this PR fixes the wrong order of the parameters.
This commit is contained in:
Tobias Diekershoff 2022-03-15 08:44:17 +01:00
parent e252b5972e
commit 12038d45d0
Signed by: tobias
GPG key ID: 25FE376FF17694A1

View file

@ -52,7 +52,7 @@ class UpdateContacts
$condition = DBA::mergeConditions($base_condition, $condition = DBA::mergeConditions($base_condition,
["`uid` != ? AND (`last-update` < ? OR (NOT `failed` AND `last-update` < ?))", ["`uid` != ? AND (`last-update` < ? OR (NOT `failed` AND `last-update` < ?))",
0, DateTimeFormat::utc('now - 1 month'), DateTimeFormat::utc('now - 1 week')]); 0, DateTimeFormat::utc('now - 1 month'), DateTimeFormat::utc('now - 1 week')]);
$ids = self::getContactsToUpdate($condition, [], $limit); $ids = self::getContactsToUpdate($condition, $limit, []);
Logger::info('Fetched federated user contacts', ['count' => count($ids)]); Logger::info('Fetched federated user contacts', ['count' => count($ids)]);
$conditions = ["`id` IN (SELECT `author-id` FROM `post` WHERE `author-id` = `contact`.`id`)", $conditions = ["`id` IN (SELECT `author-id` FROM `post` WHERE `author-id` = `contact`.`id`)",
@ -65,7 +65,7 @@ class UpdateContacts
$condition = DBA::mergeConditions($base_condition, $condition = DBA::mergeConditions($base_condition,
[$contact_condition . " AND (`last-update` < ? OR (NOT `failed` AND `last-update` < ?))", [$contact_condition . " AND (`last-update` < ? OR (NOT `failed` AND `last-update` < ?))",
DateTimeFormat::utc('now - 1 month'), DateTimeFormat::utc('now - 1 week')]); DateTimeFormat::utc('now - 1 month'), DateTimeFormat::utc('now - 1 week')]);
$ids = self::getContactsToUpdate($condition, $ids, $limit); $ids = self::getContactsToUpdate($condition, $limit, $ids);
Logger::info('Fetched interacting federated contacts', ['count' => count($ids), 'condition' => $contact_condition]); Logger::info('Fetched interacting federated contacts', ['count' => count($ids), 'condition' => $contact_condition]);
} }
@ -80,7 +80,7 @@ class UpdateContacts
["(`last-update` < ? OR (NOT `failed` AND `last-update` < ?))", ["(`last-update` < ? OR (NOT `failed` AND `last-update` < ?))",
DateTimeFormat::utc('now - 6 month'), DateTimeFormat::utc('now - 1 month')]); DateTimeFormat::utc('now - 6 month'), DateTimeFormat::utc('now - 1 month')]);
$previous = count($ids); $previous = count($ids);
$ids = self::getContactsToUpdate($condition, $ids, $limit - $previous); $ids = self::getContactsToUpdate($condition, $limit - $previous, $ids);
Logger::info('Fetched federated contacts', ['count' => count($ids) - $previous]); Logger::info('Fetched federated contacts', ['count' => count($ids) - $previous]);
} }
@ -101,7 +101,7 @@ class UpdateContacts
* @param array $ids * @param array $ids
* @return array contact ids * @return array contact ids
*/ */
private static function getContactsToUpdate(array $condition, array $ids = [], int $limit) private static function getContactsToUpdate(array $condition, int $limit, array $ids = [])
{ {
$contacts = DBA::select('contact', ['id'], $condition, ['limit' => $limit]); $contacts = DBA::select('contact', ['id'], $condition, ['limit' => $limit]);
while ($contact = DBA::fetch($contacts)) { while ($contact = DBA::fetch($contacts)) {