@@ 681-697 (lines=17) @@ | ||
678 | * @param IJobSpecification $job |
|
679 | * @return array |
|
680 | */ |
|
681 | protected function getNewJobFields( IJobSpecification $job ) { |
|
682 | return [ |
|
683 | // Fields that describe the nature of the job |
|
684 | 'type' => $job->getType(), |
|
685 | 'namespace' => $job->getTitle()->getNamespace(), |
|
686 | 'title' => $job->getTitle()->getDBkey(), |
|
687 | 'params' => $job->getParams(), |
|
688 | // Some jobs cannot run until a "release timestamp" |
|
689 | 'rtimestamp' => $job->getReleaseTimestamp() ?: 0, |
|
690 | // Additional job metadata |
|
691 | 'uuid' => UIDGenerator::newRawUUIDv4( UIDGenerator::QUICK_RAND ), |
|
692 | 'sha1' => $job->ignoreDuplicates() |
|
693 | ? Wikimedia\base_convert( sha1( serialize( $job->getDeduplicationInfo() ) ), 16, 36, 31 ) |
|
694 | : '', |
|
695 | 'timestamp' => time() // UNIX timestamp |
|
696 | ]; |
|
697 | } |
|
698 | ||
699 | /** |
|
700 | * @param array $fields |
@@ 716-734 (lines=19) @@ | ||
713 | * @param IJobSpecification $job |
|
714 | * @return array |
|
715 | */ |
|
716 | protected function insertFields( IJobSpecification $job ) { |
|
717 | $dbw = $this->getMasterDB(); |
|
718 | ||
719 | return [ |
|
720 | // Fields that describe the nature of the job |
|
721 | 'job_cmd' => $job->getType(), |
|
722 | 'job_namespace' => $job->getTitle()->getNamespace(), |
|
723 | 'job_title' => $job->getTitle()->getDBkey(), |
|
724 | 'job_params' => self::makeBlob( $job->getParams() ), |
|
725 | // Additional job metadata |
|
726 | 'job_id' => $dbw->nextSequenceValue( 'job_job_id_seq' ), |
|
727 | 'job_timestamp' => $dbw->timestamp(), |
|
728 | 'job_sha1' => Wikimedia\base_convert( |
|
729 | sha1( serialize( $job->getDeduplicationInfo() ) ), |
|
730 | 16, 36, 31 |
|
731 | ), |
|
732 | 'job_random' => mt_rand( 0, self::MAX_JOB_RANDOM ) |
|
733 | ]; |
|
734 | } |
|
735 | ||
736 | /** |
|
737 | * @throws JobQueueConnectionError |