symfony: Call to undefined method Symfony\Component\VarDumper\Caster\CutStub::clear()

Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? no
Symfony version 3.3.2

I just upgraded from 3.2.x to 3.3.2, ran my test suite, and got this:

PHPUnit 6.2.1 by Sebastian Bergmann and contributors.

......................E

Time: 17.47 seconds, Memory: 153.28MB

There was 1 error:

1) Tests\My\Project\MyTestCase::myTest
Error: Call to undefined method Symfony\Component\VarDumper\Caster\CutStub::clear()

my-project/var/cache/test/appTestDebugProjectContainer.php:8865
my-project/vendor/doctrine/doctrine-bundle/DoctrineBundle.php:123
my-project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:155
my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:193
my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:205
my-project/tests/My/Project/ApiTestCase.php:112

Inspecting the CutStub class reveals that, indeed, it does not have a clear() method.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 36 (30 by maintainers)

Commits related to this issue

Most upvoted comments

This is the minimum version to reproduce that I was able to achieve: https://github.com/ossinkine/symfony-standard/tree/issue-23110 This is Symfony Standard edition with installed Sonata admin and Vich uploader bundles and Doctrine migrations package. I ran test in a container based on php:alpine with installed opache (docker-php-ext-install opcache). If disable one of Vich uploader, Migrations or Opcache, all work.

@stof Yes! The profiler was enabled, and disabling it solves the problem!

@nicodemuz I got the same issue like you after upgrading symfony 6.1 to 6.2 (on PHP 8.1). Got it solved by upgrading to PHP 8.2 … so I didn’t investigate further.

I’m facing the same issue on my CI machine when upgrading from Symfony 5.4 to Symfony 6.2.

My test also uses $client->enableProfiler();. My application code also uses EntityType::class.

1) App\Tests\Controller\WorkshopShowControllerTest::testUpcomingWorkshopRegistrationForUnregisteredWorkshopUser

Error: Call to undefined method Symfony\Component\VarDumper\Caster\CutStub::clear()



/var/lib/jenkins/workspace/PR-3803/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:624

/var/lib/jenkins/workspace/PR-3803/symfony/vendor/doctrine/doctrine-bundle/Registry.php:80

/var/lib/jenkins/workspace/PR-3803/symfony/vendor/doctrine/doctrine-bundle/Registry.php:65

/var/lib/jenkins/workspace/PR-3803/symfony/vendor/symfony/http-kernel/DependencyInjection/ServicesResetter.php:47

/var/lib/jenkins/workspace/PR-3803/symfony/vendor/symfony/http-kernel/Kernel.php:110

/var/lib/jenkins/workspace/PR-3803/symfony/vendor/bref/symfony-bridge/src/BrefKernel.php:62

/var/lib/jenkins/workspace/PR-3803/symfony/vendor/symfony/framework-bundle/KernelBrowser.php:154

/var/lib/jenkins/workspace/PR-3803/symfony/vendor/symfony/browser-kit/AbstractBrowser.php:370

/var/lib/jenkins/workspace/PR-3803/symfony/vendor/symfony/browser-kit/AbstractBrowser.php:568

/var/lib/jenkins/workspace/PR-3803/symfony/tests/Controller/WorkshopShowControllerTest.php:292

Here is the relevant code from my test case:

$client = $this->createWebClientByUsername('test');

// Enable profiler so we get sent email
$client->enableProfiler();

$client->request('POST', '/workshop/1', array(
    'workshop_signup' => array(
        'firstName' => 'Testing',
        'lastName' => 'User',
        'email' => 'test@testing.com',
        'phone' => '12345678',
        'userType' => WorkshopSignup::USER_TYPE_TEACHER,
        'school' => null,
        'georegion' => '7',
    ),
));

$this->assertResponseRedirects();

// Ensure one workshop registration email is sent
$mailCollector = $this->getMailCollector($client);
$this->assertEquals(1, sizeof($mailCollector->getEvents()->getEvents()));

// Ensure workshop Zoom URL is in the email message
/** @var Email $email */
$email = $mailCollector->getEvents()->getEvents()[0]->getMessage();
/** @var TextPart $textPart */
$textPart = $email->getBody();
$emailBody = $textPart->getBody();
$this->assertStringContainsString('https://us02web.zoom.us/j/1234567890?pwd=abcdefg', $emailBody);

$client->followRedirect(); // Line WorkshopShowControllerTest.php:292 in above stack trace

@nicolas-grekas any idea?

@Invis1ble of course: it has been fixed in v3.3.11.

Should be fixed by #23465

WTF. How are we ending up with a CutStub in a property of the proxy class. @nicolas-grekas could it be that the class property is accessed by reference when building the dumping info, and then the dumping info is modified to add a CutStub ? I don’t see another way here (but I may miss something due to the magic happening in ProxyManager)

Likewise, my application is large and proprietary. I’ll try to find some time to dig deeper so I can provide more helpful information.