Page MenuHomePhabricator

D16887.id40656.diff
No OneTemporary

D16887.id40656.diff

diff --git a/src/applications/harbormaster/artifact/HarbormasterArtifact.php b/src/applications/harbormaster/artifact/HarbormasterArtifact.php
--- a/src/applications/harbormaster/artifact/HarbormasterArtifact.php
+++ b/src/applications/harbormaster/artifact/HarbormasterArtifact.php
@@ -16,6 +16,10 @@
abstract public function getArtifactParameterDescriptions();
abstract public function willCreateArtifact(PhabricatorUser $actor);
+ public function readArtifactHTTPParameter($key, $value) {
+ return $value;
+ }
+
public function validateArtifactData(array $artifact_data) {
$artifact_spec = $this->getArtifactParameterSpecification();
PhutilTypeSpec::checkMap($artifact_data, $artifact_spec);
diff --git a/src/applications/harbormaster/artifact/HarbormasterURIArtifact.php b/src/applications/harbormaster/artifact/HarbormasterURIArtifact.php
--- a/src/applications/harbormaster/artifact/HarbormasterURIArtifact.php
+++ b/src/applications/harbormaster/artifact/HarbormasterURIArtifact.php
@@ -27,6 +27,16 @@
);
}
+ public function readArtifactHTTPParameter($key, $value) {
+ // TODO: This is hacky and artifact parameters should be replaced more
+ // broadly, likely with EditFields. See T11887.
+ switch ($key) {
+ case 'ui.external':
+ return (bool)$value;
+ }
+ return $value;
+ }
+
public function getArtifactParameterDescriptions() {
return array(
'uri' => pht('The URI to store.'),
diff --git a/src/applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php b/src/applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php
--- a/src/applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php
+++ b/src/applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php
@@ -115,11 +115,28 @@
$build_target_phid));
}
+ $artifact_type = $request->getValue('artifactType');
+
+ // Cast "artifactData" parameters to acceptable types if this request
+ // is submitting raw HTTP parameters. This is not ideal. See T11887 for
+ // discussion.
+ $artifact_data = $request->getValue('artifactData');
+ if (!$request->getIsStrictlyTyped()) {
+ $impl = HarbormasterArtifact::getArtifactType($artifact_type);
+ if ($impl) {
+ foreach ($artifact_data as $key => $value) {
+ $artifact_data[$key] = $impl->readArtifactHTTPParameter(
+ $key,
+ $value);
+ }
+ }
+ }
+
$artifact = $build_target->createArtifact(
$viewer,
$request->getValue('artifactKey'),
- $request->getValue('artifactType'),
- $request->getValue('artifactData'));
+ $artifact_type,
+ $artifact_data);
return array(
'data' => $this->returnArtifactList(array($artifact)),

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 10:44 AM (21 h, 59 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6909302
Default Alt Text
D16887.id40656.diff (2 KB)

Event Timeline