Sylius: A circular reference problem?

Created on 28 Dec 2018  ·  3Comments  ·  Source: Sylius/Sylius

Sylius version affected: 1.3

Description
I executed php bin/console sylius:install and threw the following error

1

The problem appeared in SyliusLabs\AssociationHydrator\AssociationHydrator line 77:

array_unique($subjects, \SORT_REGULAR)

The $subjects is array of Sylius\Component\Core\Model\Promotion:

2

However, other properties associated with Promotion such as PromotionCouponInterface, PromotionRuleInterface, and PromotionActionInterface cause circular reference problems when using array_unique.

Steps to reproduce

$ composer create-project sylius/sylius-standard acme
$ cd acme
$ php bin/console sylius:install

Possible Solution
Use other methods to detect if $subjects is unique?

My php version: php7.3.0
Related links: https://bugs.php.net/bug.php?id=39356

update!

I reproduced this situation:

<?php

class A
{
    private $b;

    public function setB(B $b)
    {
        $this->b = $b;
    }
}

class B
{
    private $a = [];

    public function addA(A $a)
    {
        $a->setB($this);
        $this->a[] = $a;
    }
}

$b1 = new B();
$b1->addA(new A());

$b2 = new B();
$b2->addA(new A());

$collection = [$b1, $b2];

$result = array_unique($collection, \SORT_REGULAR);
var_dump($result);

in php 7.3.0, the Fatal error has been throw!

Fatal error: Nesting level too deep - recursive dependency?

Most helpful comment

AssociationHydrator v1.1.1 has just been released.

All 3 comments

Reproduced on a clean install under PHP 7.3. After resolving the "continue" warning in Gaufrette, the Circular reference appears.

vendor/sylius-labs/association-hydrator/src/AssociationHydrator.php:77

It was fixed here, we will release a new version of this library asap and it should not be a problem anymore :)

AssociationHydrator v1.1.1 has just been released.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stefandoorn picture stefandoorn  ·  3Comments

igormukhingmailcom picture igormukhingmailcom  ·  3Comments

javiereguiluz picture javiereguiluz  ·  3Comments

bnd170 picture bnd170  ·  3Comments

loic425 picture loic425  ·  3Comments