PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.10.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.10.0
4.10.0 4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Framework / Traits / JobResponseTrait.php
wp-staging / Framework / Traits Last commit date
ApplyFiltersTrait.php 3 months ago ArrayableTrait.php 8 months ago BatchSizeCalculateTrait.php 8 months ago BearerTokenTrait.php 6 months ago BenchmarkTrait.php 3 years ago BooleanTransientTrait.php 5 years ago DatabaseSearchReplaceTrait.php 1 month ago DbRowsGeneratorTrait.php 4 years ago DebugLogTrait.php 1 year ago DeveloperTimerTrait.php 10 months ago EndOfLinePlaceholderTrait.php 1 year ago EventLoggerTrait.php 2 months ago FileScanToCacheTrait.php 2 weeks ago FormatTrait.php 1 year ago HttpRequestTrait.php 10 months ago HydrateTrait.php 1 year ago I18nTrait.php 1 year ago IpResolverTrait.php 11 months ago JobResponseTrait.php 4 days ago MaintenanceTrait.php 6 months ago MemoryExhaustTrait.php 2 years ago MySQLRowsGeneratorTrait.php 8 months ago NoticesTrait.php 2 weeks ago PropertyConstructor.php 5 years ago RenameTmpDirectoryTrait.php 6 months ago ResourceTrait.php 6 months ago RestRequestTrait.php 5 months ago RestoreFileExclusionTrait.php 1 year ago SafeFileInfoTrait.php 2 weeks ago SerializeTrait.php 4 days ago SetTimeLimitTrait.php 2 months ago SlashTrait.php 1 year ago SqlCommentTrait.php 5 months ago TablePrefixValidator.php 5 months ago UrlTrait.php 1 year ago ValueGetterTrait.php 2 years ago WindowsOsTrait.php 1 year ago
JobResponseTrait.php
37 lines
1 <?php
2
3 namespace WPStaging\Framework\Traits;
4
5 use WPStaging\Framework\Job\AbstractJob;
6 use WPStaging\Framework\Job\Exception\ProcessLockedException;
7
8 /**
9 * Answers an HTTP request with the outcome of one job step, including the case where another
10 * request already owns the job.
11 */
12 trait JobResponseTrait
13 {
14 /**
15 * Run one step of a job for the current HTTP request and answer it with JSON.
16 *
17 * Turning process lock contention into an HTTP status belongs at the HTTP boundary and nowhere
18 * else: a background worker has no client to answer and must see the ProcessLockedException
19 * itself, so it can re-queue its action and let the worker that won the lock carry the job on.
20 *
21 * @param AbstractJob $job
22 * @return void
23 */
24 protected function sendJobResponse(AbstractJob $job)
25 {
26 try {
27 $response = $job->prepareAndExecute();
28 } catch (ProcessLockedException $e) {
29 wp_send_json_error($e->getMessage(), $e->getCode());
30
31 return;
32 }
33
34 wp_send_json($response);
35 }
36 }
37