ArgumentsResolver in RequestHandler causes warnings when using camelcased parameters in @RestResource methods

Created on 26 March 2018, over 6 years ago
Updated 26 May 2023, over 1 year ago

Specifically this part:

    // Parameters which are not defined on the route object, but still are
    // essential for access checking are passed as wildcards to the argument
    // resolver.
    $wildcard_arguments = [$route, $route_match];
    $wildcard_arguments[] = $request;
    if (isset($unserialized)) {
      $wildcard_arguments[] = $unserialized;
    }

$unserialized is not always an object. For normal custom rest resources with a POST that have nothing to do with entities, $unserialized can be an array. Passing a non-object to the ArgumentsResolver causes the following warning:

Warning: ReflectionClass::isInstance() expects parameter 1 to be object, array given in Drupal\Component\Utility\ArgumentsResolver->getArgument()

See related issue for when this new functionality was added.

Unless I missed an announcement or some new documentation somewhere which explains that arrays are no longer supported? I created a quick dirty workaround for my project* but some official word or documentation update or fix or proposed workaround or a swift kick in the right direction if these things already exist would be much appreciated.

*a custom Denormalizer which applies when the serialization class for the resource plugin is a class which implements DataBundleInterface. Which is a simple wrapper class with a $data property I can put $unserialized inside of.

🐛 Bug report
Status

Closed: won't fix

Version

8.7 ⚰️

Component
REST 

Last updated about 1 month ago

Created by

🇧🇪Belgium Grayle

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇹🇷Turkey durum

    @Wim hi.

    Sorry, if I am unnecessarily activating this dead issue.

    I think we are facing this while trying to expose a custom API to an ERP system integration where we undertake CRUD operations for our entities facilitating foreign id's. We are seeing some inconsistencies during this operations.

    I would be more than happy to dedicate quite good time and effort on this, if this is still doable and you can review and mentor the process.

    To be brief now, I am not going into detail, but willing to provide more details and get instructions on how to continue.

Production build 0.71.5 2024