data-fixtures icon indicating copy to clipboard operation
data-fixtures copied to clipboard

Ordering fixtures: Undefined index: %loader class% in .../DataFixtures/Loader.php on line 330

Open ryabenko-pro opened this issue 10 years ago • 9 comments

When I add order to fixtures, I got notice:

PHP Notice:  Undefined index: Acme\DemoBundle\DataFixtures\ORM\LoadDemoData in /var/www/symfony/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Loader.php on line 330
PHP Stack trace:
PHP   1. {main}() /var/www/symfony/app/console:0
PHP   2. Symfony\Component\Console\Application->run() /var/www/symfony/app/console:27
PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/symfony/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:121
PHP   4. Symfony\Component\Console\Application->doRun() /var/www/symfony/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
PHP   5. Symfony\Component\Console\Application->doRunCommand() /var/www/symfony/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:191
PHP   6. Symfony\Component\Console\Command\Command->run() /var/www/symfony/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:902
PHP   7. Common\CommonBundle\Command\ClearDatabaseCommand->execute() /var/www/symfony/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:241
PHP   8. Symfony\Component\Console\Command\Command->run() /var/www/symfony/src/Common/CommonBundle/Command/ClearDatabaseCommand.php:55
PHP   9. Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand->execute() /var/www/symfony/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:241
PHP  10. Doctrine\Common\DataFixtures\Loader->getFixtures() /var/www/symfony/vendor/doctrine/doctrine-fixtures-bundle/Doctrine/Bundle/FixturesBundle/Command/LoadDataFixturesDoctrineCommand.php:94
PHP  11. Doctrine\Common\DataFixtures\Loader->orderFixturesByDependencies() /var/www/symfony/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Loader.php:164
PHP  12. Doctrine\Common\DataFixtures\Loader->getUnsequencedClasses() /var/www/symfony/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Loader.php:274
  > loading [0] Acme\DemoBundle\DataFixtures\ORM\LoadDemoData
  > loading [1] Acme\Demo2Bundle\DataFixtures\ORM\LoadDemo2Data

Class is:

class LoadDemoData extends AbstractFixture implements OrderedFixtureInterface
{
    /**
     * {@inheritDoc}
     */
    public function load(ObjectManager $manager)
    {
        $object = new Demo();
        // ....
        $manager->persist($object);
        $manager->flush();

        $this->addReference('object-1', $object);
    }

    public function getOrder()
    {
        return 0;
    }

}

Without order no notice.

ryabenko-pro avatar May 04 '14 16:05 ryabenko-pro

I'm having the same problem, seems to happen to DependantFixtures too.

bashilbers avatar Sep 03 '14 14:09 bashilbers

Any news on this ? It happens when there is dependency on OrderedFixture

alsma avatar Dec 21 '14 15:12 alsma

I can’t replicate this issue. There are also tests for mixed fixtures. Can you provide a test case with up-to-date data-fixtures? Use dev-master, not v1.0.0.

lavoiesl avatar Mar 23 '15 00:03 lavoiesl

This is still an issue. Please see #198

brabeji avatar Jul 08 '15 10:07 brabeji

@brabeji Thanks for pointing this in test, I did not have time to do that. Your test is correct as I mentioned It happens when there is dependant fixture that depends on OrderedFixture :+1:

alsma avatar Jul 08 '15 10:07 alsma

:+1:

nenadalm avatar Apr 06 '17 08:04 nenadalm

Have the same issue How to reproduce

FixtureA implement DependentFixtureInterface
FixtureB implement DependentFixtureInterface
FixtureC implement DependentFixtureInterface
FixtureD implement OrderedFixtureInterface
FixtureA depends on FixtureB
FixtureB depends on FixtureC && FixtureD

As result on php7 we recived the exception

[Symfony\Component\Debug\Exception\ContextErrorException]                                                       
  Notice: Undefined index: FixtureD

northdakota avatar Apr 14 '17 14:04 northdakota

Still actual in 2020

danaki avatar Jun 18 '20 15:06 danaki

Still actual in 2021

Sadbot avatar May 12 '21 07:05 Sadbot