Skip to content

Fix wrong identifier #679

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

Merged
merged 1 commit into from
Dec 20, 2018
Merged

Fix wrong identifier #679

merged 1 commit into from
Dec 20, 2018

Conversation

tienvx
Copy link
Contributor

@tienvx tienvx commented Dec 8, 2018

Error: Warning: Illegal string offset id
Full response:

{
  "@context": "/api/contexts/Error",
  "@type": "hydra:Error",
  "hydra:title": "An error occurred",
  "hydra:description": "Warning: Illegal string offset 'id'",
  "trace": [
    {
      "namespace": "",
      "short_class": "",
      "class": "",
      "type": "",
      "function": "",
      "file": "/usr/local/src/app/vendor/tienvx/mbt-api-bundle/src/DataProvider/ModelDataProvider.php",
      "line": 53,
      "args": []
    },
    {
      "namespace": "Tienvx\\Bundle\\MbtApiBundle\\DataProvider",
      "short_class": "ModelDataProvider",
      "class": "Tienvx\\Bundle\\MbtApiBundle\\DataProvider\\ModelDataProvider",
      "type": "->",
      "function": "getItem",
      "file": "/usr/local/src/app/vendor/api-platform/core/src/DataProvider/ChainItemDataProvider.php",
      "line": 57,
      "args": [
        [
          "string",
          "Tienvx\\Bundle\\MbtApiBundle\\Entity\\Model"
        ],
        [
          "string",
          "shopping_cart"
        ],
        [
          "string",
          "get"
        ],
        [
          "array",
          {
            "item_operation_name": [
              "string",
              "get"
            ],
            "operation_type": [
              "string",
              "item"
            ],
            "resource_class": [
              "string",
              "Tienvx\\Bundle\\MbtApiBundle\\Entity\\Model"
            ],
            "request_uri": [
              "string",
              "/api/models/shopping_cart"
            ],
            "uri": [
              "string",
              "http://localhost/api/models/shopping_cart"
            ],
            "has_identifier_converter": [
              "boolean",
              true
            ]
          }
        ]
      ]
    },
    {
      "namespace": "ApiPlatform\\Core\\DataProvider",
      "short_class": "ChainItemDataProvider",
      "class": "ApiPlatform\\Core\\DataProvider\\ChainItemDataProvider",
      "type": "->",
      "function": "getItem",
      "file": "/usr/local/src/app/vendor/api-platform/core/src/DataProvider/OperationDataProviderTrait.php",
      "line": 62,
      "args": [
        [
          "string",
          "Tienvx\\Bundle\\MbtApiBundle\\Entity\\Model"
        ],
        [
          "array",
          {
            "name": [
              "string",
              "shopping_cart"
            ]
          }
        ],
        [
          "string",
          "get"
        ],
        [
          "array",
          {
            "item_operation_name": [
              "string",
              "get"
            ],
            "operation_type": [
              "string",
              "item"
            ],
            "resource_class": [
              "string",
              "Tienvx\\Bundle\\MbtApiBundle\\Entity\\Model"
            ],
            "request_uri": [
              "string",
              "/api/models/shopping_cart"
            ],
            "uri": [
              "string",
              "http://localhost/api/models/shopping_cart"
            ],
            "has_identifier_converter": [
              "boolean",
              true
            ]
          }
        ]
      ]
    },
    {
      "namespace": "ApiPlatform\\Core\\EventListener",
      "short_class": "ReadListener",
      "class": "ApiPlatform\\Core\\EventListener\\ReadListener",
      "type": "->",
      "function": "getItemData",
      "file": "/usr/local/src/app/vendor/api-platform/core/src/EventListener/ReadListener.php",
      "line": 94,
      "args": [
        [
          "array",
          {
            "name": [
              "string",
              "shopping_cart"
            ]
          }
        ],
        [
          "array",
          {
            "resource_class": [
              "string",
              "Tienvx\\Bundle\\MbtApiBundle\\Entity\\Model"
            ],
            "item_operation_name": [
              "string",
              "get"
            ],
            "receive": [
              "boolean",
              true
            ]
          }
        ],
        [
          "array",
          {
            "item_operation_name": [
              "string",
              "get"
            ],
            "operation_type": [
              "string",
              "item"
            ],
            "resource_class": [
              "string",
              "Tienvx\\Bundle\\MbtApiBundle\\Entity\\Model"
            ],
            "request_uri": [
              "string",
              "/api/models/shopping_cart"
            ],
            "uri": [
              "string",
              "http://localhost/api/models/shopping_cart"
            ],
            "has_identifier_converter": [
              "boolean",
              true
            ]
          }
        ]
      ]
    },
    {
      "namespace": "ApiPlatform\\Core\\EventListener",
      "short_class": "ReadListener",
      "class": "ApiPlatform\\Core\\EventListener\\ReadListener",
      "type": "->",
      "function": "onKernelRequest",
      "file": "/usr/local/src/app/vendor/symfony/event-dispatcher/EventDispatcher.php",
      "line": 212,
      "args": [
        [
          "object",
          "Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent"
        ],
        [
          "string",
          "kernel.request"
        ],
        [
          "object",
          "Symfony\\Component\\EventDispatcher\\EventDispatcher"
        ]
      ]
    },
    {
      "namespace": "Symfony\\Component\\EventDispatcher",
      "short_class": "EventDispatcher",
      "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
      "type": "->",
      "function": "doDispatch",
      "file": "/usr/local/src/app/vendor/symfony/event-dispatcher/EventDispatcher.php",
      "line": 44,
      "args": [
        [
          "array",
          [
            [
              "array",
              [
                [
                  "object",
                  "Symfony\\Component\\HttpKernel\\EventListener\\DebugHandlersListener"
                ],
                [
                  "string",
                  "configure"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "Symfony\\Component\\HttpKernel\\EventListener\\ValidateRequestListener"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "Nelmio\\CorsBundle\\EventListener\\CorsListener"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "Symfony\\Component\\HttpKernel\\EventListener\\SessionListener"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "Symfony\\Component\\HttpKernel\\EventListener\\RouterListener"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "Symfony\\Bundle\\FrameworkBundle\\EventListener\\ResolveControllerNameSubscriber"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "ApiPlatform\\Core\\Filter\\QueryParameterValidateListener"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "Symfony\\Component\\HttpKernel\\EventListener\\LocaleListener"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "Symfony\\Bundle\\SecurityBundle\\Debug\\TraceableFirewallListener"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "ApiPlatform\\Core\\EventListener\\AddFormatListener"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "ApiPlatform\\Core\\EventListener\\ReadListener"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "ApiPlatform\\Core\\EventListener\\DeserializeListener"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "ApiPlatform\\Core\\Security\\EventListener\\DenyAccessListener"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ],
            [
              "array",
              [
                [
                  "object",
                  "ApiPlatform\\Core\\Bridge\\Symfony\\Bundle\\EventListener\\SwaggerUiListener"
                ],
                [
                  "string",
                  "onKernelRequest"
                ]
              ]
            ]
          ]
        ],
        [
          "string",
          "kernel.request"
        ],
        [
          "object",
          "Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent"
        ]
      ]
    },
    {
      "namespace": "Symfony\\Component\\EventDispatcher",
      "short_class": "EventDispatcher",
      "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
      "type": "->",
      "function": "dispatch",
      "file": "/usr/local/src/app/vendor/symfony/http-kernel/HttpKernel.php",
      "line": 126,
      "args": [
        [
          "string",
          "kernel.request"
        ],
        [
          "object",
          "Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent"
        ]
      ]
    },
    {
      "namespace": "Symfony\\Component\\HttpKernel",
      "short_class": "HttpKernel",
      "class": "Symfony\\Component\\HttpKernel\\HttpKernel",
      "type": "->",
      "function": "handleRaw",
      "file": "/usr/local/src/app/vendor/symfony/http-kernel/HttpKernel.php",
      "line": 67,
      "args": [
        [
          "object",
          "Symfony\\Component\\HttpFoundation\\Request"
        ],
        [
          "integer",
          1
        ]
      ]
    },
    {
      "namespace": "Symfony\\Component\\HttpKernel",
      "short_class": "HttpKernel",
      "class": "Symfony\\Component\\HttpKernel\\HttpKernel",
      "type": "->",
      "function": "handle",
      "file": "/usr/local/src/app/vendor/symfony/http-kernel/Kernel.php",
      "line": 198,
      "args": [
        [
          "object",
          "Symfony\\Component\\HttpFoundation\\Request"
        ],
        [
          "integer",
          1
        ],
        [
          "boolean",
          true
        ]
      ]
    },
    {
      "namespace": "Symfony\\Component\\HttpKernel",
      "short_class": "Kernel",
      "class": "Symfony\\Component\\HttpKernel\\Kernel",
      "type": "->",
      "function": "handle",
      "file": "/usr/local/src/app/public/index.php",
      "line": 25,
      "args": [
        [
          "object",
          "Symfony\\Component\\HttpFoundation\\Request"
        ]
      ]
    }
  ]
}

Copy link
Contributor

@antograssiot antograssiot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the correct fix would be to extend DenormalizedIdentifiersAwareItemDataProviderInterface instead of ItemDataProviderInterface. It is expected to get identifiers as an array in 2.3

@dunglas
Copy link
Member

dunglas commented Dec 20, 2018

But this change is in sync with the current implementation @antograssiot right? If true we should merge it as is, and add a new example for DenormalizedIdentifiersAwareItemDataProviderInterface.

@dunglas dunglas merged commit 063814a into api-platform:2.3 Dec 20, 2018
@dunglas
Copy link
Member

dunglas commented Dec 20, 2018

Thanks @tienvx

@tienvx tienvx deleted the fix-identifier branch December 20, 2018 15:05
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

Successfully merging this pull request may close these issues.

3 participants