Addressing PHP8 incompatibilities - Conduit
Summary: Navigate through all the conduit pages and address PHP8 incompatibilities. Additionally test out empty form submissions on many of the "create" or "update" APIs and return more contextual errors rather than PHP8 errors. Refs T13588 Test Plan: - Clicked through all the conduit APIs. - Clicked submit on empty forms, or minimally filled-in forms. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley, PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13588 Differential Revision: https://secure.phabricator.com/D21872
This commit is contained in:
parent
60158470d0
commit
dd94e2efcf
|
@ -55,6 +55,9 @@ final class DifferentialCreateDiffConduitAPIMethod
|
|||
protected function execute(ConduitAPIRequest $request) {
|
||||
$viewer = $request->getUser();
|
||||
$change_data = $request->getValue('changes');
|
||||
if ($change_data === null) {
|
||||
throw new Exception(pht('Field "changes" must be non-empty.'));
|
||||
}
|
||||
|
||||
$changes = array();
|
||||
foreach ($change_data as $dict) {
|
||||
|
|
|
@ -26,6 +26,9 @@ final class DifferentialCreateRawDiffConduitAPIMethod
|
|||
protected function execute(ConduitAPIRequest $request) {
|
||||
$viewer = $request->getUser();
|
||||
$raw_diff = $request->getValue('diff');
|
||||
if ($raw_diff === null || !strlen($raw_diff)) {
|
||||
throw new Exception(pht('Field "raw_diff" must be non-empty.'));
|
||||
}
|
||||
|
||||
$repository_phid = $request->getValue('repositoryPHID');
|
||||
if ($repository_phid) {
|
||||
|
|
|
@ -33,6 +33,9 @@ final class DifferentialParseCommitMessageConduitAPIMethod
|
|||
}
|
||||
|
||||
$corpus = $request->getValue('corpus');
|
||||
if ($corpus === null || !strlen($corpus)) {
|
||||
throw new Exception(pht('Field "corpus" must be non-empty.'));
|
||||
}
|
||||
$field_map = $parser->parseFields($corpus);
|
||||
|
||||
$errors = $parser->getErrors();
|
||||
|
|
|
@ -30,9 +30,22 @@ final class DifferentialSetDiffPropertyConduitAPIMethod
|
|||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$data = $request->getValue('data');
|
||||
if ($data === null || !strlen($data)) {
|
||||
throw new Exception(pht('Field "data" must be non-empty.'));
|
||||
}
|
||||
|
||||
$diff_id = $request->getValue('diff_id');
|
||||
if ($diff_id === null) {
|
||||
throw new Exception(pht('Field "diff_id" must be non-null.'));
|
||||
}
|
||||
|
||||
$name = $request->getValue('name');
|
||||
$data = json_decode($request->getValue('data'), true);
|
||||
if ($name === null || !strlen($name)) {
|
||||
throw new Exception(pht('Field "name" must be non-empty.'));
|
||||
}
|
||||
|
||||
$data = json_decode($data, true);
|
||||
|
||||
self::updateDiffProperty($diff_id, $name, $data);
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ final class DifferentialTransactionEditor
|
|||
|
||||
// No "$", to allow for branches like T123_demo.
|
||||
$match = null;
|
||||
if (preg_match('/^T(\d+)/i', $branch, $match)) {
|
||||
if ($branch !== null && preg_match('/^T(\d+)/i', $branch, $match)) {
|
||||
$task_id = $match[1];
|
||||
$tasks = id(new ManiphestTaskQuery())
|
||||
->setViewer($this->getActor())
|
||||
|
|
|
@ -31,6 +31,9 @@ final class FileUploadConduitAPIMethod extends FileConduitAPIMethod {
|
|||
$view_policy = $request->getValue('viewPolicy');
|
||||
|
||||
$data = $request->getValue('data_base64');
|
||||
if ($data === null) {
|
||||
throw new Exception(pht('Field "data_base64" must be non-empty.'));
|
||||
}
|
||||
$data = $this->decodeBase64($data);
|
||||
|
||||
$params = array(
|
||||
|
|
|
@ -515,7 +515,7 @@ EOREMARKUP
|
|||
}
|
||||
}
|
||||
|
||||
if (!strlen($receiver_name)) {
|
||||
if ($receiver_name === null || !strlen($receiver_name)) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Call omits required "receiver" parameter. Specify the PHID '.
|
||||
|
@ -523,7 +523,7 @@ EOREMARKUP
|
|||
}
|
||||
|
||||
$message_type = $request->getValue('type');
|
||||
if (!strlen($message_type)) {
|
||||
if ($message_type === null || !strlen($message_type)) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Call omits required "type" parameter. Specify the type of '.
|
||||
|
|
|
@ -103,7 +103,7 @@ final class HarbormasterBuildPlanEditEngine
|
|||
$key);
|
||||
$behavior_option = $object->getPlanProperty($storage_key);
|
||||
|
||||
if (!strlen($behavior_option)) {
|
||||
if ($behavior_option === null || !strlen($behavior_option)) {
|
||||
$behavior_option = $behavior->getPlanOption($object)->getKey();
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ final class PasteCreateConduitAPIMethod extends PasteConduitAPIMethod {
|
|||
$title = $request->getValue('title');
|
||||
$language = $request->getValue('language');
|
||||
|
||||
if (!strlen($content)) {
|
||||
if ($content === null || !strlen($content)) {
|
||||
throw new ConduitException('ERR-NO-PASTE');
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,10 @@ final class PhrictionCreateConduitAPIMethod extends PhrictionConduitAPIMethod {
|
|||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$slug = $request->getValue('slug');
|
||||
if (!strlen($slug)) {
|
||||
throw new Exception(pht('No such document.'));
|
||||
if ($slug === null || !strlen($slug)) {
|
||||
throw new Exception(pht('Field "slug" must be non-empty.'));
|
||||
}
|
||||
|
||||
$doc = id(new PhrictionDocumentQuery())
|
||||
->setViewer($request->getUser())
|
||||
->withSlugs(array(PhabricatorSlug::normalize($slug)))
|
||||
|
|
|
@ -25,6 +25,9 @@ final class PhrictionEditConduitAPIMethod extends PhrictionConduitAPIMethod {
|
|||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$slug = $request->getValue('slug');
|
||||
if ($slug === null || !strlen($slug)) {
|
||||
throw new Exception(pht('Field "slug" must be non-empty.'));
|
||||
}
|
||||
|
||||
$doc = id(new PhrictionDocumentQuery())
|
||||
->setViewer($request->getUser())
|
||||
|
|
|
@ -38,6 +38,10 @@ final class PhrictionHistoryConduitAPIMethod extends PhrictionConduitAPIMethod {
|
|||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$slug = $request->getValue('slug');
|
||||
if ($slug === null || !strlen($slug)) {
|
||||
throw new Exception(pht('Field "slug" must be non-empty.'));
|
||||
}
|
||||
|
||||
$doc = id(new PhrictionDocumentQuery())
|
||||
->setViewer($request->getUser())
|
||||
->withSlugs(array(PhabricatorSlug::normalize($slug)))
|
||||
|
|
|
@ -38,6 +38,9 @@ final class PhrictionInfoConduitAPIMethod extends PhrictionConduitAPIMethod {
|
|||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$slug = $request->getValue('slug');
|
||||
if ($slug === null || !strlen($slug)) {
|
||||
throw new Exception(pht('Field "slug" must be non-empty.'));
|
||||
}
|
||||
|
||||
$document = id(new PhrictionDocumentQuery())
|
||||
->setViewer($request->getUser())
|
||||
|
|
|
@ -43,12 +43,21 @@ final class ProjectCreateConduitAPIMethod extends ProjectConduitAPIMethod {
|
|||
|
||||
$project = PhabricatorProject::initializeNewProject($user);
|
||||
$type_name = PhabricatorProjectNameTransaction::TRANSACTIONTYPE;
|
||||
|
||||
$name = $request->getValue('name');
|
||||
if ($name === null || !strlen(name)) {
|
||||
throw new Exception(pht('Field "name" must be non-empty.'));
|
||||
}
|
||||
|
||||
$members = $request->getValue('members');
|
||||
if ($members === null) {
|
||||
$members = array();
|
||||
}
|
||||
$xactions = array();
|
||||
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
->setTransactionType($type_name)
|
||||
->setNewValue($request->getValue('name'));
|
||||
->setNewValue($name);
|
||||
|
||||
if ($request->getValue('icon')) {
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
|
|
|
@ -41,7 +41,7 @@ final class RemarkupProcessConduitAPIMethod extends ConduitAPIMethod {
|
|||
|
||||
$engine_class = idx($this->getEngineContexts(), $context);
|
||||
if (!$engine_class) {
|
||||
throw new ConduitException('ERR-INVALID_ENGINE');
|
||||
throw new ConduitException('ERR-INVALID-ENGINE');
|
||||
}
|
||||
|
||||
$engine = PhabricatorMarkupEngine::$engine_class();
|
||||
|
|
|
@ -95,7 +95,7 @@ abstract class PhabricatorEditEngineAPIMethod
|
|||
$section[] = $type->getConduitDescription();
|
||||
|
||||
$type_documentation = $type->getConduitDocumentation();
|
||||
if (strlen($type_documentation)) {
|
||||
if ($type_documentation !== null && strlen($type_documentation)) {
|
||||
$section[] = $type_documentation;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ final class PhabricatorStandardCustomFieldInt
|
|||
|
||||
public function getValueForStorage() {
|
||||
$value = $this->getFieldValue();
|
||||
if (strlen($value)) {
|
||||
if ($value !== null && strlen($value)) {
|
||||
return $value;
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
@ -114,7 +114,7 @@ final class PhutilRemarkupTableBlockRule extends PhutilRemarkupBlockRule {
|
|||
if ($cell->isContentNode()) {
|
||||
$content = $node->getContent();
|
||||
|
||||
if (!strlen(trim($content))) {
|
||||
if ($content === null || !strlen(trim($content))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue