Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F436759
ConduitSSHWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ConduitSSHWorkflow.php
View Options
<?php
final
class
ConduitSSHWorkflow
extends
PhabricatorSSHWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'conduit'
);
$this
->
setArguments
(
array
(
array
(
'name'
=>
'method'
,
'wildcard'
=>
true
,
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$time_start
=
microtime
(
true
);
$methodv
=
$args
->
getArg
(
'method'
);
if
(!
$methodv
)
{
throw
new
Exception
(
pht
(
'No Conduit method provided.'
));
}
else
if
(
count
(
$methodv
)
>
1
)
{
throw
new
Exception
(
pht
(
'Too many Conduit methods provided.'
));
}
$method
=
head
(
$methodv
);
$json
=
$this
->
readAllInput
();
$raw_params
=
null
;
try
{
$raw_params
=
phutil_json_decode
(
$json
);
}
catch
(
PhutilJSONParserException
$ex
)
{
throw
new
PhutilProxyException
(
pht
(
'Invalid JSON input.'
),
$ex
);
}
$params
=
idx
(
$raw_params
,
'params'
,
'[]'
);
$params
=
phutil_json_decode
(
$params
);
$metadata
=
idx
(
$params
,
'__conduit__'
,
array
());
unset
(
$params
[
'__conduit__'
]);
$call
=
null
;
$error_code
=
null
;
$error_info
=
null
;
try
{
$call
=
new
ConduitCall
(
$method
,
$params
);
$call
->
setUser
(
$this
->
getUser
());
$result
=
$call
->
execute
();
}
catch
(
ConduitException
$ex
)
{
$result
=
null
;
$error_code
=
$ex
->
getMessage
();
if
(
$ex
->
getErrorDescription
())
{
$error_info
=
$ex
->
getErrorDescription
();
}
else
if
(
$call
)
{
$error_info
=
$call
->
getErrorDescription
(
$error_code
);
}
}
$response
=
id
(
new
ConduitAPIResponse
())
->
setResult
(
$result
)
->
setErrorCode
(
$error_code
)
->
setErrorInfo
(
$error_info
);
$json_out
=
json_encode
(
$response
->
toDictionary
());
$json_out
=
$json_out
.
"
\n
"
;
$this
->
getIOChannel
()->
write
(
$json_out
);
// NOTE: Flush here so we can get an accurate result for the duration,
// if the response is large and the receiver is slow to read it.
$this
->
getIOChannel
()->
flush
();
$time_end
=
microtime
(
true
);
$connection_id
=
idx
(
$metadata
,
'connectionID'
);
$log
=
id
(
new
PhabricatorConduitMethodCallLog
())
->
setCallerPHID
(
$this
->
getUser
()->
getPHID
())
->
setConnectionID
(
$connection_id
)
->
setMethod
(
$method
)
->
setError
((
string
)
$error_code
)
->
setDuration
(
1000000
*
(
$time_end
-
$time_start
))
->
save
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, May 4, 12:14 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
62663
Default Alt Text
ConduitSSHWorkflow.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment