X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjobqueue%2FJob.php;h=f814ceeb1b8b7440d1ae6437a10a96fb0da37eab;hb=22806b0a4509e97b56fb52b387e17e3c80fb7eb2;hp=9ccf6f84657c3ec4c386323b2c304e7477fa8ec5;hpb=f2b09f04f22a64e3f65bd6728902736434f71f00;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/jobqueue/Job.php b/includes/jobqueue/Job.php index 9ccf6f8465..f814ceeb1b 100644 --- a/includes/jobqueue/Job.php +++ b/includes/jobqueue/Job.php @@ -92,6 +92,10 @@ abstract class Job implements IJobSpecification { // expensive jobs may set this to true $this->removeDuplicates = false; + + if ( !isset( $this->params['requestId'] ) ) { + $this->params['requestId'] = WebRequest::getRequestId(); + } } /** @@ -152,6 +156,18 @@ abstract class Job implements IJobSpecification { : null; } + /** + * @return string|null Id of the request that created this job. Follows + * jobs recursively, allowing to track the id of the request that started a + * job when jobs insert jobs which insert other jobs. + * @since 1.27 + */ + public function getRequestId() { + return isset( $this->params['requestId'] ) + ? $this->params['requestId'] + : null; + } + /** * @return int|null UNIX timestamp of when the job was runnable, or null * @since 1.26 @@ -214,6 +230,8 @@ abstract class Job implements IJobSpecification { unset( $info['params']['rootJobTimestamp'] ); // Likewise for jobs with different delay times unset( $info['params']['jobReleaseTimestamp'] ); + // Identical jobs from different requests should count as duplicates + unset( $info['params']['requestId'] ); // Queues pack and hash this array, so normalize the order ksort( $info['params'] ); } @@ -283,7 +301,9 @@ abstract class Job implements IJobSpecification { } /** - * @param callable $callback + * @param callable $callback A function with one parameter, the success status, which will be + * false if the job failed or it succeeded but the DB changes could not be committed or + * any deferred updates threw an exception. (This parameter was added in 1.28.) * @since 1.27 */ protected function addTeardownCallback( $callback ) { @@ -292,12 +312,12 @@ abstract class Job implements IJobSpecification { /** * Do any final cleanup after run(), deferred updates, and all DB commits happen - * + * @param bool $status Whether the job, its deferred updates, and DB commit all succeeded * @since 1.27 */ - public function teardown() { + public function teardown( $status ) { foreach ( $this->teardownCallbacks as $callback ) { - call_user_func( $callback ); + call_user_func( $callback, $status ); } }