Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F72362987
PhabricatorWorkerManagementExecuteWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jul 15, 09:38
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Jul 17, 09:38 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
19047128
Attached To
rPH Phabricator
PhabricatorWorkerManagementExecuteWorkflow.php
View Options
<?php
final
class
PhabricatorWorkerManagementExecuteWorkflow
extends
PhabricatorWorkerManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'execute'
)
->
setExamples
(
'**execute** --id __id__'
)
->
setSynopsis
(
pht
(
'Execute a task explicitly. This command ignores leases, is '
.
'dangerous, and may cause work to be performed twice.'
))
->
setArguments
(
$this
->
getTaskSelectionArguments
());
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$console
=
PhutilConsole
::
getConsole
();
$tasks
=
$this
->
loadTasks
(
$args
);
foreach
(
$tasks
as
$task
)
{
$can_execute
=
!
$task
->
isArchived
();
if
(!
$can_execute
)
{
$console
->
writeOut
(
"**<bg:yellow> %s </bg>** %s
\n
"
,
pht
(
'ARCHIVED'
),
pht
(
'%s is already archived, and can not be executed.'
,
$this
->
describeTask
(
$task
)));
continue
;
}
// NOTE: This ignores leases, maybe it should respect them without
// a parameter like --force?
$task
->
setLeaseOwner
(
null
);
$task
->
setLeaseExpires
(
PhabricatorTime
::
getNow
());
$task
->
save
();
$task_data
=
id
(
new
PhabricatorWorkerTaskData
())->
loadOneWhere
(
'id = %d'
,
$task
->
getDataID
());
$task
->
setData
(
$task_data
->
getData
());
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Executing task %d (%s)...'
,
$task
->
getID
(),
$task
->
getTaskClass
()));
$task
=
$task
->
executeTask
();
$ex
=
$task
->
getExecutionException
();
if
(
$ex
)
{
throw
$ex
;
}
}
return
0
;
}
}
Event Timeline
Log In to Comment