18 files changed +58
-13
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,9 @@ protected function defineReturnType() {
55
55
protected function execute (ConduitAPIRequest $ request ) {
56
56
$ viewer = $ request ->getUser ();
57
57
$ change_data = $ request ->getValue ('changes ' );
58
+ if ($ change_data === null ) {
59
+ throw new Exception (pht ('Field "changes" must be non-empty. ' ));
60
+ }
58
61
59
62
$ changes = array ();
60
63
foreach ($ change_data as $ dict ) {
Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ protected function defineReturnType() {
26
26
protected function execute (ConduitAPIRequest $ request ) {
27
27
$ viewer = $ request ->getUser ();
28
28
$ raw_diff = $ request ->getValue ('diff ' );
29
+ if ($ raw_diff === null || !strlen ($ raw_diff )) {
30
+ throw new Exception (pht ('Field "raw_diff" must be non-empty. ' ));
31
+ }
29
32
30
33
$ repository_phid = $ request ->getValue ('repositoryPHID ' );
31
34
if ($ repository_phid ) {
Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ protected function execute(ConduitAPIRequest $request) {
33
33
}
34
34
35
35
$ corpus = $ request ->getValue ('corpus ' );
36
+ if ($ corpus === null || !strlen ($ corpus )) {
37
+ throw new Exception (pht ('Field "corpus" must be non-empty. ' ));
38
+ }
36
39
$ field_map = $ parser ->parseFields ($ corpus );
37
40
38
41
$ errors = $ parser ->getErrors ();
Original file line number Diff line number Diff line change @@ -30,9 +30,22 @@ protected function defineErrorTypes() {
30
30
}
31
31
32
32
protected function execute (ConduitAPIRequest $ request ) {
33
+ $ data = $ request ->getValue ('data ' );
34
+ if ($ data === null || !strlen ($ data )) {
35
+ throw new Exception (pht ('Field "data" must be non-empty. ' ));
36
+ }
37
+
33
38
$ diff_id = $ request ->getValue ('diff_id ' );
39
+ if ($ diff_id === null ) {
40
+ throw new Exception (pht ('Field "diff_id" must be non-null. ' ));
41
+ }
42
+
34
43
$ name = $ request ->getValue ('name ' );
35
- $ data = json_decode ($ request ->getValue ('data ' ), true );
44
+ if ($ name === null || !strlen ($ name )) {
45
+ throw new Exception (pht ('Field "name" must be non-empty. ' ));
46
+ }
47
+
48
+ $ data = json_decode ($ data , true );
36
49
37
50
self ::updateDiffProperty ($ diff_id , $ name , $ data );
38
51
}
Original file line number Diff line number Diff line change @@ -218,7 +218,7 @@ protected function expandTransaction(
218
218
219
219
// No "$", to allow for branches like T123_demo.
220
220
$ match = null ;
221
- if (preg_match ('/^T(\d+)/i ' , $ branch , $ match )) {
221
+ if ($ branch !== null && preg_match ('/^T(\d+)/i ' , $ branch , $ match )) {
222
222
$ task_id = $ match [1 ];
223
223
$ tasks = id (new ManiphestTaskQuery ())
224
224
->setViewer ($ this ->getActor ())
Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ protected function execute(ConduitAPIRequest $request) {
31
31
$ view_policy = $ request ->getValue ('viewPolicy ' );
32
32
33
33
$ data = $ request ->getValue ('data_base64 ' );
34
+ if ($ data === null ) {
35
+ throw new Exception (pht ('Field "data_base64" must be non-empty. ' ));
36
+ }
34
37
$ data = $ this ->decodeBase64 ($ data );
35
38
36
39
$ params = array (
Original file line number Diff line number Diff line change @@ -515,15 +515,15 @@ protected function execute(ConduitAPIRequest $request) {
515
515
}
516
516
}
517
517
518
- if (!strlen ($ receiver_name )) {
518
+ if ($ receiver_name === null || !strlen ($ receiver_name )) {
519
519
throw new Exception (
520
520
pht (
521
521
'Call omits required "receiver" parameter. Specify the PHID ' .
522
522
'of the object you want to send a message to. ' ));
523
523
}
524
524
525
525
$ message_type = $ request ->getValue ('type ' );
526
- if (!strlen ($ message_type )) {
526
+ if ($ message_type === null || !strlen ($ message_type )) {
527
527
throw new Exception (
528
528
pht (
529
529
'Call omits required "type" parameter. Specify the type of ' .
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ protected function buildCustomEditFields($object) {
103
103
$ key );
104
104
$ behavior_option = $ object ->getPlanProperty ($ storage_key );
105
105
106
- if (!strlen ($ behavior_option )) {
106
+ if ($ behavior_option === null || !strlen ($ behavior_option )) {
107
107
$ behavior_option = $ behavior ->getPlanOption ($ object )->getKey ();
108
108
}
109
109
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ protected function execute(ConduitAPIRequest $request) {
43
43
$ title = $ request ->getValue ('title ' );
44
44
$ language = $ request ->getValue ('language ' );
45
45
46
- if (!strlen ($ content )) {
46
+ if ($ content === null || !strlen ($ content )) {
47
47
throw new ConduitException ('ERR-NO-PASTE ' );
48
48
}
49
49
Original file line number Diff line number Diff line change @@ -25,9 +25,10 @@ protected function defineReturnType() {
25
25
26
26
protected function execute (ConduitAPIRequest $ request ) {
27
27
$ slug = $ request ->getValue ('slug ' );
28
- if (!strlen ($ slug )) {
29
- throw new Exception (pht ('No such document . ' ));
28
+ if ($ slug === null || !strlen ($ slug )) {
29
+ throw new Exception (pht ('Field "slug" must be non-empty . ' ));
30
30
}
31
+
31
32
$ doc = id (new PhrictionDocumentQuery ())
32
33
->setViewer ($ request ->getUser ())
33
34
->withSlugs (array (PhabricatorSlug::normalize ($ slug )))
Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ protected function defineReturnType() {
25
25
26
26
protected function execute (ConduitAPIRequest $ request ) {
27
27
$ slug = $ request ->getValue ('slug ' );
28
+ if ($ slug === null || !strlen ($ slug )) {
29
+ throw new Exception (pht ('Field "slug" must be non-empty. ' ));
30
+ }
28
31
29
32
$ doc = id (new PhrictionDocumentQuery ())
30
33
->setViewer ($ request ->getUser ())
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ protected function defineErrorTypes() {
38
38
39
39
protected function execute (ConduitAPIRequest $ request ) {
40
40
$ slug = $ request ->getValue ('slug ' );
41
+ if ($ slug === null || !strlen ($ slug )) {
42
+ throw new Exception (pht ('Field "slug" must be non-empty. ' ));
43
+ }
44
+
41
45
$ doc = id (new PhrictionDocumentQuery ())
42
46
->setViewer ($ request ->getUser ())
43
47
->withSlugs (array (PhabricatorSlug::normalize ($ slug )))
Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ protected function defineErrorTypes() {
38
38
39
39
protected function execute (ConduitAPIRequest $ request ) {
40
40
$ slug = $ request ->getValue ('slug ' );
41
+ if ($ slug === null || !strlen ($ slug )) {
42
+ throw new Exception (pht ('Field "slug" must be non-empty. ' ));
43
+ }
41
44
42
45
$ document = id (new PhrictionDocumentQuery ())
43
46
->setViewer ($ request ->getUser ())
Original file line number Diff line number Diff line change @@ -43,12 +43,21 @@ protected function execute(ConduitAPIRequest $request) {
43
43
44
44
$ project = PhabricatorProject::initializeNewProject ($ user );
45
45
$ type_name = PhabricatorProjectNameTransaction::TRANSACTIONTYPE ;
46
+
47
+ $ name = $ request ->getValue ('name ' );
48
+ if ($ name === null || !strlen (name)) {
49
+ throw new Exception (pht ('Field "name" must be non-empty. ' ));
50
+ }
51
+
46
52
$ members = $ request ->getValue ('members ' );
53
+ if ($ members === null ) {
54
+ $ members = array ();
55
+ }
47
56
$ xactions = array ();
48
57
49
58
$ xactions [] = id (new PhabricatorProjectTransaction ())
50
59
->setTransactionType ($ type_name )
51
- ->setNewValue ($ request -> getValue ( ' name ' ) );
60
+ ->setNewValue ($ name );
52
61
53
62
if ($ request ->getValue ('icon ' )) {
54
63
$ xactions [] = id (new PhabricatorProjectTransaction ())
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ protected function execute(ConduitAPIRequest $request) {
41
41
42
42
$ engine_class = idx ($ this ->getEngineContexts (), $ context );
43
43
if (!$ engine_class ) {
44
- throw new ConduitException ('ERR-INVALID_ENGINE ' );
44
+ throw new ConduitException ('ERR-INVALID-ENGINE ' );
45
45
}
46
46
47
47
$ engine = PhabricatorMarkupEngine::$ engine_class ();
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ private function buildEditTypesDocumentationPages(
95
95
$ section [] = $ type ->getConduitDescription ();
96
96
97
97
$ type_documentation = $ type ->getConduitDocumentation ();
98
- if (strlen ($ type_documentation )) {
98
+ if ($ type_documentation !== null && strlen ($ type_documentation )) {
99
99
$ section [] = $ type_documentation ;
100
100
}
101
101
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public function buildOrderIndex() {
24
24
25
25
public function getValueForStorage () {
26
26
$ value = $ this ->getFieldValue ();
27
- if (strlen ($ value )) {
27
+ if ($ value !== null && strlen ($ value )) {
28
28
return $ value ;
29
29
} else {
30
30
return null ;
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ private function newTable(PhutilDOMNode $table) {
114
114
if ($ cell ->isContentNode ()) {
115
115
$ content = $ node ->getContent ();
116
116
117
- if (!strlen (trim ($ content ))) {
117
+ if ($ content === null || !strlen (trim ($ content ))) {
118
118
continue ;
119
119
}
120
120
0 commit comments