update
This commit is contained in:
@@ -130,10 +130,22 @@ class CronJobRepository
|
||||
*/
|
||||
public function markFailed($jobId, $error, $attempt = 1)
|
||||
{
|
||||
$job = $this->db->get('pp_cron_jobs', ['max_attempts', 'attempts'], ['id' => $jobId]);
|
||||
$job = $this->db->get('pp_cron_jobs', ['job_type', 'max_attempts', 'attempts'], ['id' => $jobId]);
|
||||
|
||||
$attempts = $job ? (int) $job['attempts'] : $attempt;
|
||||
$maxAttempts = $job ? (int) $job['max_attempts'] : 10;
|
||||
$jobType = $job ? $job['job_type'] : '';
|
||||
|
||||
// Order-related Apilo joby — infinite retry co 30 min
|
||||
if (CronJobType::isOrderRelatedApiloJob($jobType)) {
|
||||
$nextRun = date('Y-m-d H:i:s', time() + CronJobType::APILO_ORDER_BACKOFF_SECONDS);
|
||||
$this->db->update('pp_cron_jobs', [
|
||||
'status' => CronJobType::STATUS_PENDING,
|
||||
'last_error' => mb_substr($error, 0, 500),
|
||||
'scheduled_at' => $nextRun,
|
||||
], ['id' => $jobId]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($attempts >= $maxAttempts) {
|
||||
// Przekroczono limit prób — trwale failed
|
||||
|
||||
@@ -34,6 +34,7 @@ class CronJobType
|
||||
// Backoff
|
||||
const BASE_BACKOFF_SECONDS = 60;
|
||||
const MAX_BACKOFF_SECONDS = 3600;
|
||||
const APILO_ORDER_BACKOFF_SECONDS = 1800; // 30 min — stały interwał dla order jobów
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
@@ -69,6 +70,19 @@ class CronJobType
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $jobType
|
||||
* @return bool
|
||||
*/
|
||||
public static function isOrderRelatedApiloJob($jobType)
|
||||
{
|
||||
return in_array($jobType, [
|
||||
self::APILO_SEND_ORDER,
|
||||
self::APILO_SYNC_PAYMENT,
|
||||
self::APILO_SYNC_STATUS,
|
||||
], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $attempt
|
||||
* @return int
|
||||
|
||||
@@ -1751,8 +1751,10 @@ class ProductRepository
|
||||
if ( \Shared\Helpers\Helpers::is_array_fix( $customFields ) ) {
|
||||
foreach ( $customFields as $row ) {
|
||||
$this->db->insert( 'pp_shop_products_custom_fields', [
|
||||
'id_product' => $newProductId,
|
||||
'name' => $row['name'],
|
||||
'id_product' => $newProductId,
|
||||
'name' => $row['name'],
|
||||
'type' => $row['type'] ?? 'text',
|
||||
'is_required' => $row['is_required'] ?? 0,
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user