本文整理汇总了PHP中Job::getParams方法的典型用法代码示例。如果您正苦于以下问题:PHP Job::getParams方法的具体用法?PHP Job::getParams怎么用?PHP Job::getParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Job
的用法示例。
在下文中一共展示了Job::getParams方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newFromJob
/**
* Get a duplicate no-op version of a job
*
* @param Job $job
* @return Job
*/
public static function newFromJob(Job $job)
{
$djob = new self($job->getTitle(), $job->getParams());
$djob->command = $job->getType();
$djob->params = is_array($djob->params) ? $djob->params : array();
$djob->params = array('isDuplicate' => true) + $djob->params;
$djob->metadata = $job->metadata;
return $djob;
}
示例2: insertFields
/**
* @param $job Job
* @return array
*/
protected function insertFields(Job $job)
{
list($dbw, $scope) = $this->getMasterDB();
return array('job_cmd' => $job->getType(), 'job_namespace' => $job->getTitle()->getNamespace(), 'job_title' => $job->getTitle()->getDBkey(), 'job_params' => self::makeBlob($job->getParams()), 'job_id' => $dbw->nextSequenceValue('job_job_id_seq'), 'job_timestamp' => $dbw->timestamp(), 'job_sha1' => wfBaseConvert(sha1(serialize($job->getDeduplicationInfo())), 16, 36, 31), 'job_random' => mt_rand(0, self::MAX_JOB_RANDOM));
}
示例3: getNewJobFields
/**
* @param $job Job
* @return array
*/
protected function getNewJobFields(Job $job)
{
return array('type' => $job->getType(), 'namespace' => $job->getTitle()->getNamespace(), 'title' => $job->getTitle()->getDBkey(), 'params' => $job->getParams(), 'rtimestamp' => $job->getReleaseTimestamp() ?: 0, 'uuid' => UIDGenerator::newRawUUIDv4(UIDGenerator::QUICK_RAND), 'sha1' => $job->ignoreDuplicates() ? wfBaseConvert(sha1(serialize($job->getDeduplicationInfo())), 16, 36, 31) : '', 'timestamp' => time());
}
示例4: doDeduplicateRootJob
/**
* @see JobQueue::doDeduplicateRootJob()
* @param Job $job
* @throws MWException
* @return bool
*/
protected function doDeduplicateRootJob(Job $job)
{
$params = $job->getParams();
if (!isset($params['rootJobSignature'])) {
throw new MWException("Cannot register root job; missing 'rootJobSignature'.");
} elseif (!isset($params['rootJobTimestamp'])) {
throw new MWException("Cannot register root job; missing 'rootJobTimestamp'.");
}
$key = $this->getRootJobCacheKey($params['rootJobSignature']);
// Callers should call batchInsert() and then this function so that if the insert
// fails, the de-duplication registration will be aborted. Since the insert is
// deferred till "transaction idle", do the same here, so that the ordering is
// maintained. Having only the de-duplication registration succeed would cause
// jobs to become no-ops without any actual jobs that made them redundant.
$dbw = $this->getMasterDB();
$cache = $this->dupCache;
$dbw->onTransactionIdle(function () use($cache, $params, $key, $dbw) {
$timestamp = $cache->get($key);
// current last timestamp of this job
if ($timestamp && $timestamp >= $params['rootJobTimestamp']) {
return true;
// a newer version of this root job was enqueued
}
// Update the timestamp of the last root job started at the location...
return $cache->set($key, $params['rootJobTimestamp'], JobQueueDB::ROOTJOB_TTL);
});
return true;
}
示例5: getNewJobFields
/**
* @param $job Job
* @return array
*/
protected function getNewJobFields( Job $job ) {
return array(
// Fields that describe the nature of the job
'type' => $job->getType(),
'namespace' => $job->getTitle()->getNamespace(),
'title' => $job->getTitle()->getDBkey(),
'params' => $job->getParams(),
// Some jobs cannot run until a "release timestamp"
'rtimestamp' => $job->getReleaseTimestamp() ?: 0,
// Additional job metadata
'uuid' => UIDGenerator::newRawUUIDv4( UIDGenerator::QUICK_RAND ),
'sha1' => $job->ignoreDuplicates()
? wfBaseConvert( sha1( serialize( $job->getDeduplicationInfo() ) ), 16, 36, 31 )
: '',
'timestamp' => time() // UNIX timestamp
);
}
示例6: insertFields
/**
* @param $job Job
* @return array
*/
protected function insertFields( Job $job ) {
$dbw = $this->getMasterDB();
return array(
// Fields that describe the nature of the job
'job_cmd' => $job->getType(),
'job_namespace' => $job->getTitle()->getNamespace(),
'job_title' => $job->getTitle()->getDBkey(),
'job_params' => self::makeBlob( $job->getParams() ),
// Additional job metadata
'job_id' => $dbw->nextSequenceValue( 'job_job_id_seq' ),
'job_timestamp' => $dbw->timestamp(),
'job_sha1' => wfBaseConvert(
sha1( serialize( $job->getDeduplicationInfo() ) ),
16, 36, 31
),
'job_random' => mt_rand( 0, self::MAX_JOB_RANDOM )
);
}
示例7: insertFields
/**
* @param $job Job
* @return array
*/
protected function insertFields(Job $job)
{
// Rows that describe the nature of the job
$descFields = array('job_cmd' => $job->getType(), 'job_namespace' => $job->getTitle()->getNamespace(), 'job_title' => $job->getTitle()->getDBkey(), 'job_params' => self::makeBlob($job->getParams()));
// Additional job metadata
if ($this->order === 'timestamp') {
// oldest first
$random = time() - 1325376000;
// seconds since "January 1, 2012"
} else {
// random first
$random = mt_rand(0, self::MAX_JOB_RANDOM);
}
$dbw = $this->getMasterDB();
$metaFields = array('job_id' => $dbw->nextSequenceValue('job_job_id_seq'), 'job_timestamp' => $dbw->timestamp(), 'job_sha1' => wfBaseConvert(sha1(serialize($descFields)), 16, 36, 32), 'job_random' => $random);
return $descFields + $metaFields;
}