Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new field #json with parameters array #47857

Closed
Zdanc32 opened this issue Jul 27, 2023 · 1 comment
Closed

new field #json with parameters array #47857

Zdanc32 opened this issue Jul 27, 2023 · 1 comment

Comments

@Zdanc32
Copy link

Zdanc32 commented Jul 27, 2023

Laravel Version

10.16.1

PHP Version

8.2

Database Driver & Version

No response

Description

Hello,

when I dumping my request - dd($request) I found new field here:

  #json: Symfony\Component\HttpFoundation\ParameterBag {#42
    #parameters: array:14 [
      "declaredFirstLanguage" => "cd853b3b-18f7-4991-984f-ac2ecafe8c5c"
      "studyProgramId" => "3af5096a-7868-4bda-81a2-bc9a0f7b24ac"
      "facultyId" => "c47cdb20-2ac9-4775-b2ac-73c95a6c29ef"
      "facultyBranchId" => "91b980a5-6b89-4996-9764-36db596fec9a"
      "declaredSpeciality" => "28ddd306-8638-4a59-9eb5-1157761143f0"
      "enrollmentInStudiesDate" => "2019-03-10"
      "signingTheContractDate" => "2019-09-10"
      "isAuditor" => false
      "crmDidacticId" => "Jan Timetables"
      "originPlace" => "f1a0e490-87ad-43ec-ac5b-0e10a0f9d5fe"
      "selectedSpeciality" => null
      "selectedSpecialization" => null
      "personId" => "e8d9f7db-c07c-4021-8c2b-783279da3bbd"
      "completedSchoolId" => "e2e4235c-77d2-4694-bfdb-77e148d9713a"
    ]
  }

I have middleware where I transform all keys to snake case, and I always to used for that simple code

        if (!$request->isMethod('GET')) {
          $data = $request->request->all();
          $files = $request->files->all();
          if (ArrayKeyTransformer::hasSnake($data) || ArrayKeyTransformer::hasSnake($files)) {
              throw ResourceNotValid::withErrors(
                  [ApiErrorResponse::REQUEST_ERROR_KEY => 'Snake case request keys not allowed']
              );
          }
          $request->request->replace(ArrayKeyTransformer::toSnake($data));
          $request->files->replace(ArrayKeyTransformer::toSnake($files));
      }

As can You see I try to transform $request->all() where I expected to get all body parameters. My middleware working greate before 10.16.1. Now, when I try to get parameters with metod $request->all() I always recived parameters from field
JSON->parameters not from request where I transformed keys.

  +request: Symfony\Component\HttpFoundation\InputBag {#35
    #parameters: array:14 [
      "declared_first_language" => "cd853b3b-18f7-4991-984f-ac2ecafe8c5c"
      "study_program_id" => "3af5096a-7868-4bda-81a2-bc9a0f7b24ac"
      "faculty_id" => "c47cdb20-2ac9-4775-b2ac-73c95a6c29ef"
      "faculty_branch_id" => "91b980a5-6b89-4996-9764-36db596fec9a"
      "declared_speciality" => "28ddd306-8638-4a59-9eb5-1157761143f0"
      "enrollment_in_studies_date" => "2019-03-10"
      "signing_the_contract_date" => "2019-09-10"
      "is_auditor" => false
      "crm_didactic_id" => "Jan Timetables"
      "origin_place" => "f1a0e490-87ad-43ec-ac5b-0e10a0f9d5fe"
      "selected_speciality" => null
      "selected_specialization" => null
      "person_id" => "e8d9f7db-c07c-4021-8c2b-783279da3bbd"
      "completed_school_id" => "e2e4235c-77d2-4694-bfdb-77e148d9713a"
    ]
  }

I wonder this field -> JSON will stay with us or its simple mistake :)

Thanks
Gabriel

Steps To Reproduce

I used dd($request) in controller to see result of new state of request

 #json: Symfony\Component\HttpFoundation\ParameterBag {#42
    #parameters: array:14 [
@driesvints
Copy link
Member

Unfortunately there was a breaking change in Symfony which made us implement #47838. So this will probably stay, sorry.

Benjaminhu added a commit to Benjaminhu/laravel-framework that referenced this issue Aug 15, 2023
…optional parameter value (class resolved)

[error] Illuminate\Tests\Container\ContextualBindingTest::testContextualBindingWorksForNestedOptionalDependencies
Failed asserting that Illuminate\Tests\Container\ContainerTestContextInjectVariadicExtended Object laravel#47857 (
    'stubs' => Array &0 ()
) is null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants