massiveart / MassiveSearchBundle

MIT License
67 stars 24 forks source link

Fix compatibility to jms metadata 2-5-2 #162

Closed alexander-schranz closed 2 years ago

alexander-schranz commented 2 years ago

The changes from 2.5.1...2.5.2 from jms metadata did cause a segmentation fault when serializing the metadata. To avoid this we need to change how we serialize the data.

goetas commented 2 years ago

\serialize($this->indexMetadatas) is the problem in your current serialize code.

$this->indexMetadatas contains a reference to the current class metadata...

see

 $indexMetadata->setName($this->name);
$indexMetadata->setClassMetadata($this);

since that is done in a different serialization round, the ciricular reference detection does not work.... TBH i wonder why it was working before.

you have two options imo:

1) make the serialize method as follows

    public function serialize()
    {
        $data = parent::serialize();

        return \serialize([$data, $this->indexMetadatas, $this->repositoryMethod]);
    }

2) implement the serialization interface in \Massive\Bundle\SearchBundle\Search\Metadata\IndexMetadata and make sure to not serialize the class $classMetadata prop

alexander-schranz commented 2 years ago

@goetas Thanks for your support and help here, really appricate that 🙏 . Will give it a try here :) and check it tomorrow. Wish you a good weekend!

alexander-schranz commented 2 years ago

@goetas I copied now the implementation of the parent method directly to our methods. This seems to work now. Could not find another solution. Do you now if there are any planes that the current ClassMetadata will get additional properties?

goetas commented 2 years ago

TBH i do not understand what did you do with those __serialize and __unserialize methods. I've published https://github.com/massiveart/MassiveSearchBundle/pull/163 . it should do what had to be done

alexander-schranz commented 2 years ago

replaced by #163 @goetas Thank you for your help with this issue!