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

  • SEARCH
  • Home
  • 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 7860175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:11:04+00:00 2026-06-02T22:11:04+00:00

I’m deserializing an entity from an XML feed. The entity already has an ID

  • 0

I’m deserializing an entity from an XML feed. The entity already has an ID (Read from the XML).

I’m trying to merge the entity before persisting and flushing it (saving it into the database). I need to merge the entity because it may already exist in the database and if so I need it to update rather than fail validation.

Here’s my code:

<?php

// build the MgLeague from xml
$league = $this->serializer->deserialize(
    $xml, 
    'Acme\Website\Entity\MgLeague',
    'xml'
);

if ($league)
{
    // merge the league
    $league = $this->em->merge($league);

    // validate
    if (0 === count($this->validator->validate($league)))
    {
        $this->em->persist($league);
        $this->em->flush();
    }
}

And here’s the error I’m receiving:

PHP Fatal error:  Call to undefined method Doctrine\ORM\UnitOfWork::newInstance() in /Website/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php on line 1457
PHP Stack trace:
PHP   1. {main}() /Website/app/console:0
PHP   2. Symfony\Component\Console\Application->run() /Website/app/console:22
PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /Website/vendor/symfony/src/Symfony/Component/Console/Application.php:118
PHP   4. Symfony\Component\Console\Application->doRun() /Website/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:75
PHP   5. Symfony\Component\Console\Command\Command->run() /Website/vendor/symfony/src/Symfony/Component/Console/Application.php:194
PHP   6. Mahango\WebServiceBundle\Command\InsertLeaguesCommand->execute() /Website/vendor/symfony/src/Symfony/Component/Console/Command/Command.php:224
PHP   7. Doctrine\ORM\EntityManager->merge() /Website/src/Mahango/WebServiceBundle/Command/InsertLeaguesCommand.php:131
PHP   8. Doctrine\ORM\UnitOfWork->merge() /Website/vendor/doctrine/lib/Doctrine/ORM/EntityManager.php:531
PHP   9. Doctrine\ORM\UnitOfWork->doMerge() /Website/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php:1378

Fatal error: Call to undefined method Doctrine\ORM\UnitOfWork::newInstance() in /Website/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php on line 1457

Call Stack:
    0.0003     632280   1. {main}() /Website/app/console:0
    0.0133    2936544   2. Symfony\Component\Console\Application->run() /Website/app/console:22
    0.0151    3192136   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /Website/vendor/symfony/src/Symfony/Component/Console/Application.php:118
    0.0538    7941912   4. Symfony\Component\Console\Application->doRun() /Website/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:75
    0.0552    7941912   5. Symfony\Component\Console\Command\Command->run() /Website/vendor/symfony/src/Symfony/Component/Console/Application.php:194
    0.0816   13131288   6. Mahango\WebServiceBundle\Command\InsertLeaguesCommand->execute() /Website/vendor/symfony/src/Symfony/Component/Console/Command/Command.php:224
    0.4149   13519208   7. Doctrine\ORM\EntityManager->merge() /Website/src/Mahango/WebServiceBundle/Command/InsertLeaguesCommand.php:131
    0.4149   13519208   8. Doctrine\ORM\UnitOfWork->merge() /Website/vendor/doctrine/lib/Doctrine/ORM/EntityManager.php:531
    0.4149   13519424   9. Doctrine\ORM\UnitOfWork->doMerge() /Website/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php:1378

It looks to me like a Doctrine bug.

I’m using Symfony2 (version 2.0.12) with Doctrine (version 2.1.6).

  • 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-02T22:11:06+00:00Added an answer on June 2, 2026 at 10:11 pm

    Yes this is a doctrine bug. Here’s the bug report:

    http://www.doctrine-project.org/jira/browse/DDC-1638

    ..and here’s the fix:

    https://github.com/doctrine/doctrine2/commit/affa6feb8aa207bf74406a4dd20adad6978f0f1e#diff-0

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.