Skip to content

Commit 63fdefb

Browse files
Merge branch '8.x'
2 parents 1afc725 + 09bd795 commit 63fdefb

File tree

8 files changed

+99
-51
lines changed

8 files changed

+99
-51
lines changed

src/Illuminate/Console/Scheduling/ManagesFrequencies.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,7 @@ public function twiceMonthly($first = 1, $second = 16, $time = '0:0')
425425

426426
$this->dailyAt($time);
427427

428-
return $this->spliceIntoPosition(1, 0)
429-
->spliceIntoPosition(2, 0)
430-
->spliceIntoPosition(3, $daysOfMonth);
428+
return $this->spliceIntoPosition(3, $daysOfMonth);
431429
}
432430

433431
/**

src/Illuminate/Container/Container.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ public function factory($abstract)
626626
/**
627627
* An alias function name for make().
628628
*
629-
* @param string $abstract
629+
* @param string|callable $abstract
630630
* @param array $parameters
631631
* @return mixed
632632
*
@@ -640,7 +640,7 @@ public function makeWith($abstract, array $parameters = [])
640640
/**
641641
* Resolve the given type from the container.
642642
*
643-
* @param string $abstract
643+
* @param string|callable $abstract
644644
* @param array $parameters
645645
* @return mixed
646646
*
@@ -670,7 +670,7 @@ public function get($id)
670670
/**
671671
* Resolve the given type from the container.
672672
*
673-
* @param string $abstract
673+
* @param string|callable $abstract
674674
* @param array $parameters
675675
* @param bool $raiseEvents
676676
* @return mixed
@@ -745,7 +745,7 @@ protected function resolve($abstract, $parameters = [], $raiseEvents = true)
745745
/**
746746
* Get the concrete type for a given abstract.
747747
*
748-
* @param string $abstract
748+
* @param string|callable $abstract
749749
* @return mixed
750750
*/
751751
protected function getConcrete($abstract)
@@ -763,7 +763,7 @@ protected function getConcrete($abstract)
763763
/**
764764
* Get the contextual concrete binding for the given abstract.
765765
*
766-
* @param string $abstract
766+
* @param string|callable $abstract
767767
* @return \Closure|string|array|null
768768
*/
769769
protected function getContextualConcrete($abstract)
@@ -789,7 +789,7 @@ protected function getContextualConcrete($abstract)
789789
/**
790790
* Find the concrete binding for the given abstract in the contextual binding array.
791791
*
792-
* @param string $abstract
792+
* @param string|callable $abstract
793793
* @return \Closure|string|null
794794
*/
795795
protected function findInContextualBindings($abstract)

src/Illuminate/Queue/BeanstalkdQueue.php

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,15 @@ public function size($queue = null)
7777
*/
7878
public function push($job, $data = '', $queue = null)
7979
{
80-
return $this->enqueueUsing($job, function () use ($job, $data, $queue) {
81-
return $this->pushRaw($this->createPayload($job, $this->getQueue($queue), $data), $queue);
82-
});
80+
return $this->enqueueUsing(
81+
$job,
82+
$this->createPayload($job, $this->getQueue($queue), $data),
83+
$queue,
84+
null,
85+
function ($payload, $queue) {
86+
return $this->pushRaw($payload, $queue);
87+
}
88+
);
8389
}
8490

8591
/**
@@ -108,16 +114,20 @@ public function pushRaw($payload, $queue = null, array $options = [])
108114
*/
109115
public function later($delay, $job, $data = '', $queue = null)
110116
{
111-
$pheanstalk = $this->pheanstalk->useTube($this->getQueue($queue));
112-
113-
return $this->enqueueUsing($job, function () use ($delay, $pheanstalk, $job, $data, $queue) {
114-
return $pheanstalk->put(
115-
$this->createPayload($job, $this->getQueue($queue), $data),
116-
Pheanstalk::DEFAULT_PRIORITY,
117-
$this->secondsUntil($delay),
118-
$this->timeToRun
119-
);
120-
});
117+
return $this->enqueueUsing(
118+
$job,
119+
$this->createPayload($job, $this->getQueue($queue), $data),
120+
$queue,
121+
$delay,
122+
function ($payload, $queue, $delay) {
123+
return $this->pheanstalk->useTube($this->getQueue($queue))->put(
124+
$payload,
125+
Pheanstalk::DEFAULT_PRIORITY,
126+
$this->secondsUntil($delay),
127+
$this->timeToRun
128+
);
129+
}
130+
);
121131
}
122132

123133
/**

src/Illuminate/Queue/DatabaseQueue.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,15 @@ public function size($queue = null)
8080
*/
8181
public function push($job, $data = '', $queue = null)
8282
{
83-
return $this->enqueueUsing($job, function () use ($job, $data, $queue) {
84-
return $this->pushToDatabase($queue, $this->createPayload(
85-
$job, $this->getQueue($queue), $data
86-
));
87-
});
83+
return $this->enqueueUsing(
84+
$job,
85+
$this->createPayload($job, $this->getQueue($queue), $data),
86+
$queue,
87+
null,
88+
function ($payload, $queue) {
89+
return $this->pushToDatabase($queue, $payload);
90+
}
91+
);
8892
}
8993

9094
/**
@@ -111,11 +115,15 @@ public function pushRaw($payload, $queue = null, array $options = [])
111115
*/
112116
public function later($delay, $job, $data = '', $queue = null)
113117
{
114-
return $this->enqueueUsing($job, function () use ($delay, $job, $data, $queue) {
115-
return $this->pushToDatabase($queue, $this->createPayload(
116-
$job, $this->getQueue($queue), $data
117-
), $delay);
118-
});
118+
return $this->enqueueUsing(
119+
$job,
120+
$this->createPayload($job, $this->getQueue($queue), $data),
121+
$queue,
122+
null,
123+
function ($payload, $queue, $delay) {
124+
return $this->pushToDatabase($queue, $payload, $delay);
125+
}
126+
);
119127
}
120128

121129
/**

src/Illuminate/Queue/Queue.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,16 @@ protected function withCreatePayloadHooks($queue, array $payload)
259259
/**
260260
* Enqueue a job using the given callback.
261261
*
262-
* @param callable $callback
263262
* @param \Closure|string|object $job
263+
* @param string $payload
264+
* @param string $queue
265+
* @param \DateTimeInterface|\DateInterval|int|null $delay
266+
* @param callable $callback
264267
* @return mixed
265268
*/
266-
protected function enqueueUsing($job, $callback)
269+
protected function enqueueUsing($job, $payload, $queue, $delay, $callback)
267270
{
268-
return $callback();
271+
return $callback($payload, $queue, $delay);
269272
}
270273

271274
/**

src/Illuminate/Queue/RedisQueue.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,15 @@ public function bulk($jobs, $data = '', $queue = null)
108108
*/
109109
public function push($job, $data = '', $queue = null)
110110
{
111-
return $this->enqueueUsing($job, function () use ($job, $data, $queue) {
112-
return $this->pushRaw($this->createPayload($job, $this->getQueue($queue), $data), $queue);
113-
});
111+
return $this->enqueueUsing(
112+
$job,
113+
$this->createPayload($job, $this->getQueue($queue), $data),
114+
$queue,
115+
null,
116+
function ($payload, $queue) {
117+
return $this->pushRaw($payload, $queue);
118+
}
119+
);
114120
}
115121

116122
/**
@@ -142,9 +148,15 @@ public function pushRaw($payload, $queue = null, array $options = [])
142148
*/
143149
public function later($delay, $job, $data = '', $queue = null)
144150
{
145-
return $this->enqueueUsing($job, function () use ($delay, $job, $data, $queue) {
146-
return $this->laterRaw($delay, $this->createPayload($job, $this->getQueue($queue), $data), $queue);
147-
});
151+
return $this->enqueueUsing(
152+
$job,
153+
$this->createPayload($job, $this->getQueue($queue), $data),
154+
$queue,
155+
$delay,
156+
function ($payload, $queue, $delay) {
157+
return $this->laterRaw($delay, $payload, $queue);
158+
}
159+
);
148160
}
149161

150162
/**

src/Illuminate/Queue/SqsQueue.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,15 @@ public function size($queue = null)
8383
*/
8484
public function push($job, $data = '', $queue = null)
8585
{
86-
return $this->enqueueUsing($job, function () use ($job, $data, $queue) {
87-
return $this->pushRaw($this->createPayload($job, $queue ?: $this->default, $data), $queue);
88-
});
86+
return $this->enqueueUsing(
87+
$job,
88+
$this->createPayload($job, $queue ?: $this->default, $data),
89+
$queue,
90+
null,
91+
function ($payload, $queue) {
92+
return $this->pushRaw($payload, $queue);
93+
}
94+
);
8995
}
9096

9197
/**
@@ -114,13 +120,19 @@ public function pushRaw($payload, $queue = null, array $options = [])
114120
*/
115121
public function later($delay, $job, $data = '', $queue = null)
116122
{
117-
return $this->enqueueUsing($job, function () use ($delay, $job, $data, $queue) {
118-
return $this->sqs->sendMessage([
119-
'QueueUrl' => $this->getQueue($queue),
120-
'MessageBody' => $this->createPayload($job, $queue ?: $this->default, $data),
121-
'DelaySeconds' => $this->secondsUntil($delay),
122-
])->get('MessageId');
123-
});
123+
return $this->enqueueUsing(
124+
$job,
125+
$this->createPayload($job, $queue ?: $this->default, $data),
126+
$queue,
127+
$delay,
128+
function ($payload, $queue, $delay) {
129+
return $this->sqs->sendMessage([
130+
'QueueUrl' => $this->getQueue($queue),
131+
'MessageBody' => $payload,
132+
'DelaySeconds' => $this->secondsUntil($delay),
133+
])->get('MessageId');
134+
}
135+
);
124136
}
125137

126138
/**

tests/Console/Scheduling/FrequencyTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ public function testTwiceMonthly()
104104
$this->assertSame('0 0 1,16 * *', $this->event->twiceMonthly(1, 16)->getExpression());
105105
}
106106

107+
public function testTwiceMonthlyAtTime()
108+
{
109+
$this->assertSame('30 1 1,16 * *', $this->event->twiceMonthly(1, 16, '1:30')->getExpression());
110+
}
111+
107112
public function testMonthlyOnWithMinutes()
108113
{
109114
$this->assertSame('15 15 4 * *', $this->event->monthlyOn(4, '15:15')->getExpression());

0 commit comments

Comments
 (0)