PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.29
ووسلام – همگام سازی ووکامرس و باسلام v1.10.29
1.10.29 1.10.28 1.1.26 1.10.27 1.10.24 1.10.25 1.10.23 1.10.22 1.10.21 1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 All 62 releases
← All changes | JobManager.php +34 -0 1.10.20 → 1.10.29 View file →
@@ -65,8 +65,27 @@
65 65 {
66 66 return $this->getCountJobs(['status' => 'processing']) > 0;
67 67 }
68 68
69 + public function getProductUpdateStatus(): array
70 + {
71 + $quickJob = $this->getJob(['job_type' => 'sync_basalam_bulk_update_products', 'status' => 'processing'])
72 + ?: $this->getJob(['job_type' => 'sync_basalam_bulk_update_products', 'status' => 'pending']);
73 + $fullJob = $this->getJob(['job_type' => 'sync_basalam_update_all_products', 'status' => 'processing'])
74 + ?: $this->getJob(['job_type' => 'sync_basalam_update_all_products', 'status' => 'pending']);
75 + $singleCount = $this->getCountJobs([
76 + 'job_type' => 'sync_basalam_update_single_product',
77 + 'status' => ['pending', 'processing'],
78 + ]);
79 +
80 + return [
81 + 'active' => (bool) ($quickJob || $fullJob || $singleCount > 0),
82 + 'type' => $quickJob ? 'quick' : (($fullJob || $singleCount > 0) ? 'full' : ''),
83 + 'status' => $quickJob ? $quickJob->status : ($fullJob ? $fullJob->status : ''),
84 + 'count' => $singleCount,
85 + ];
86 + }
87 +
69 88 public function hasPendingOrStaleProcessingJobs(int $staleProcessingTimeoutSeconds = 120): bool
70 89 {
71 90 global $wpdb;
72 91
@@ -89,8 +108,23 @@
89 108 $staleBefore
90 109 ));
91 110
92 111 return (string) $result === '1';
112 + }
113 +
114 + public function getStaleProcessingJob(int $timeoutSeconds = 120): ?object
115 + {
116 + global $wpdb;
117 +
118 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Custom queue table; identifier from the WordPress prefix, values prepared.
119 + return $wpdb->get_row($wpdb->prepare(
120 + "SELECT id, started_at FROM {$this->jobManagerTableName}
121 + WHERE status = 'processing'
122 + AND started_at IS NOT NULL
123 + AND started_at < %d
124 + ORDER BY started_at ASC, id ASC LIMIT 1",
125 + time() - $timeoutSeconds
126 + ));
93 127 }
94 128
95 129 public function getJob($where = array())
96 130 {