Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8254673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:16:22+00:00 2026-06-08T01:16:22+00:00

I have a method within my controller that takes a deserialized object from JMSSerializerBundle

  • 0

I have a method within my controller that takes a deserialized object from JMSSerializerBundle and returns the full object, ready to be persisted. The reason I’m doing this is to return the updated object so, when it’s persisted, it doesn’t reset everything to the default.

When ran, this method ends up throwing an ErrorException on the indicated line and puts this in my log: Warning: ReflectionProperty::setValue() expects parameter 1 to be object, null given in C:\DevelopmentProjects\keobi-web\vendor\doctrine\lib\Doctrine\ORM\Mapping\ClassMetadata.php line 177 (uncaught exception) at C:\DevelopmentProjects\keobi-web\vendor\symfony\src\Symfony\Component\HttpKernel\Debug\ErrorHandler.php line 65

For some reason, the EntityManager method find is returning (according to get_class) DefaultController, the controller class for this method. And the setFieldValue says it’s NULL.

One thing that’s confusing me is the Doctrine\ORM\EntityNotFoundException should be thrown if the entity isn’t found. It’s not being thrown. So, it’s obviously finding the entity, not not returning it properly…

Incoming parameter $data is the object deserialized by JSMSerializerBundle. $em is definitely EntityManager and $metadata is definitely ClassMetadata.

I’m at a loss here. No idea how to proceed.

protected function processEntity($data)
{
$em = $this->getDoctrine()->getEntityManager();
$metadata = $em->getClassMetadata(get_class($data));
$fqcn = $metadata->getName();
$blankEntity = new $fqcn();
$id = array();

$this->get('logger')->debug('Incoming object type: ' . get_class($data)); # Keobi\ModelBundle\Entity\User
$this->get('logger')->debug('Blank entity type: ' . get_class($blankEntity)); # Keobi\ModelBundle\Entity\User
$this->get('logger')->debug('FQCN: ' . $fqcn); # Keobi\ModelBundle\Entity\User

foreach ($metadata->getIdentifierFieldNames() as $identifier)
{
  $id[$identifier] = $metadata->getFieldValue($data, $identifier);

  if (!$id[$identifier])
  {
    $this->get('logger')->debug(sprintf("Identifer '%s' missing. Assuming the object is new.", $identifier));
    return $data;
  }
}

$entity = $em->find($metadata->getName(), $id);

$this->get('logger')->debug(get_class($entity)); # Keobi\RestAPIBundle\DefaultController

foreach ($metadata->getFieldNames() as $field)
{
  $value = $metadata->getFieldValue($data, $field);
  $default = $metadata->getFieldValue($blankEntity, $field);

  if ($value <> $default)
  {
    $metadata->setFieldValue($entity, $field, $value); # <- throws ErrorException
    $this->get('logger')->debug(sprintf("Updated field '%s' in %s", $field, get_class($entity)));
  }
}

return $entity;  

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:16:24+00:00Added an answer on June 8, 2026 at 1:16 am

    Looks like there was an issue with Doctrine2. I updated it to the latest HEAD commit of the Github repo. What puzzles me is that this method actually worked not too long ago.

    Couldn’t find the exact commit that fixed the issue, but, as of this writing, the commit is 93cef612701b9e8caaf43c745978cd4fbd9d4e4e.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a destroy method within a notecards controller that I am calling from
I have method that returns Drawable , and if its Bitmap object is recycled
How can I call a controller method from within a Play! template? I have
Say I have a method, and within that method it instantiates a Person class:
i have a method as follows. test(Object obj){ } now within this method i
I have a method running on the EDT and within that I want to
I have a spring bean that I get like this within a method- repAppCaller
I have the following situation: From within a view controller, I go about creating
I'm fairly new to RoR I have a controller and within that controller I
I have a view controller that has a button that triggers a method to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.