@@ 416-432 (lines=17) @@ | ||
413 | } |
|
414 | if ($field instanceof EE_Model_Field_Base) { |
|
415 | if (! $writing && is_array($query_param_value)) { |
|
416 | if (! \EEH_Array::is_array_numerically_and_sequentially_indexed($query_param_value)) { |
|
417 | if (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE) { |
|
418 | throw new RestException( |
|
419 | 'numerically_indexed_array_of_values_only', |
|
420 | sprintf( |
|
421 | esc_html__( |
|
422 | 'The array provided for the parameter "%1$s" should be numerically indexed.', |
|
423 | 'event_espresso' |
|
424 | ), |
|
425 | $query_param_key |
|
426 | ), |
|
427 | array( |
|
428 | 'status' => 400, |
|
429 | ) |
|
430 | ); |
|
431 | } |
|
432 | } |
|
433 | //did they specify an operator? |
|
434 | if (isset($query_param_value[0]) |
|
435 | && isset($valid_operators[$query_param_value[0]]) |
|
@@ 496-514 (lines=19) @@ | ||
493 | $requested_version, |
|
494 | $timezone |
|
495 | ); |
|
496 | } else { |
|
497 | //so they provided a valid operator, but wrong number of arguments |
|
498 | if (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE) { |
|
499 | throw new RestException( |
|
500 | 'wrong_number_of_arguments', |
|
501 | sprintf( |
|
502 | esc_html__( |
|
503 | 'The operator you provided, "%1$s" had the wrong number of arguments', |
|
504 | 'event_espresso' |
|
505 | ), |
|
506 | $op |
|
507 | ), |
|
508 | array( |
|
509 | 'status' => 400, |
|
510 | ) |
|
511 | ); |
|
512 | } |
|
513 | $translated_value = null; |
|
514 | } |
|
515 | } else { |
|
516 | //so they didn't provide a valid operator |
|
517 | if (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE) { |
|
@@ 515-535 (lines=21) @@ | ||
512 | } |
|
513 | $translated_value = null; |
|
514 | } |
|
515 | } else { |
|
516 | //so they didn't provide a valid operator |
|
517 | if (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE) { |
|
518 | throw new RestException( |
|
519 | 'invalid_operator', |
|
520 | sprintf( |
|
521 | esc_html__( |
|
522 | 'You provided an invalid parameter, with key "%1$s" and value "%2$s"', |
|
523 | 'event_espresso' |
|
524 | ), |
|
525 | $query_param_key, |
|
526 | $query_param_value |
|
527 | ), |
|
528 | array( |
|
529 | 'status' => 400, |
|
530 | ) |
|
531 | ); |
|
532 | } |
|
533 | //if we aren't in debug mode, then just try our best to fulfill the user's request |
|
534 | $translated_value = null; |
|
535 | } |
|
536 | } else { |
|
537 | $translated_value = ModelDataTranslator::prepareFieldValueFromJson( |
|
538 | $field, |
|
@@ 578-594 (lines=17) @@ | ||
575 | $model, |
|
576 | $requested_version |
|
577 | ); |
|
578 | } elseif (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE) { |
|
579 | //only tell API clients they got it wrong if we're in debug mode |
|
580 | //otherwise try our best ot fulfill their request by ignoring this invalid data |
|
581 | throw new RestException( |
|
582 | 'invalid_parameter', |
|
583 | sprintf( |
|
584 | esc_html__( |
|
585 | 'You provided an invalid parameter, with key "%1$s"', |
|
586 | 'event_espresso' |
|
587 | ), |
|
588 | $query_param_sans_stars |
|
589 | ), |
|
590 | array( |
|
591 | 'status' => 400, |
|
592 | ) |
|
593 | ); |
|
594 | } |
|
595 | } |
|
596 | } |
|
597 | } |