Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notice: Accessing static property Proxies\__CG__\examplemodel\inherit\Customers::$lazyPropertiesNames as non static #1209

Closed
jannmylj opened this issue May 28, 2020 · 10 comments · Fixed by #1210

Comments

@jannmylj
Copy link

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

Since orm/doctrine update to 2.7.3 I've got this error (issue title) when I try to serialize an collection of entities "products" get with Doctrine.

Steps required to reproduce the problem

  1. findAll products with Doctrine EntityManager in Products table to get $product
  2. build serializer : $serializer = JMS\Serializer\SerializerBuilder::create()->build();
  3. serialize : $product = $serializer->serialize($product, 'json');
  4. var_dump serialization : var_dump($product);

Expected Result (get with orm/doctrine 2.7.2)

  • string(461) "[{"id":1,"price":"100.00","customer":{"id":1,"name":"Customer 1","address":"Address 1","address_extra":"Address extra 1","city":"City 1","postal_code":"75001"},"type_product":{"id":1,"code":"typeProducts1","lib":"Type product 1"}},{"id":2,"price":"200.00","customer":{"id":2,"name":"Customer 2","address":"Address 2","address_extra":"Address extra 2","city":"City 2","postal_code":"75002"},"type_product":{"id":2,"code":"typeProducts2","lib":"Type product 2"}}]"

In attachment

  • mysql model
  • entities
  • proxys

Actual Result

  • PHP notice "throw" in step 3

Archive.zip

@goetas
Copy link
Collaborator

goetas commented May 31, 2020

Hi, thanks for your report, but how am I supposed to reproduce the issue?

@jannmylj
Copy link
Author

jannmylj commented Jun 2, 2020

Hi, I'm gonna to try to be more explicit

Composer dependencies

"require": {
        "doctrine/orm"                 : "2.7.*",
        "jms/serializer"                : "3.7.*",
    }

Dump SQL importation

The previous file .sql was imported in my MySQL local server

Test.php

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Configuration;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Proxy\AbstractProxyFactory;

require __DIR__ . '/Customers.php';
require __DIR__ . '/CustomersRepo.php';
require __DIR__ . '/Products.php';
require __DIR__ . '/ProductsRepo.php';
require __DIR__ . '/TypeProducts.php';
require __DIR__ . '/TypeProductsRepo.php';

$config = new Configuration;
$driver = $config->newDefaultAnnotationDriver(__DIR__,false);
$config->setMetadataDriverImpl($driver);
$config->setProxyDir(__DIR__);
$config->setProxyNamespace('Proxies');

$proxy = AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS;
$config->setAutoGenerateProxyClasses($proxy);

$config->setMetadataCacheImpl(new ArrayCache());
$config->setQueryCacheImpl(new ArrayCache());

$em = EntityManager::create([
    "driver"    => "pdo_mysql",
    "host"      => "127.0.0.1",
    "user"      => "root",
    "password"  => "root",
    "dbname"    => "examplemodel",
    "charset"   => "utf8",
    "driverOptions" => [
        "1002"  => "SET NAMES utf8"
    ]
], $config);

$product = $em->getRepository("examplemodel\\Products")->findAll();
$serializer = JMS\Serializer\SerializerBuilder::create()->build();
var_dump($serializer->serialize($product, 'json'));

Entities and repositories

Customers Entity

namespace examplemodel;

use Doctrine\ORM\Mapping as ORM;

/**
 * Customers
 *
 * @ORM\Table(name="customers")
 * @ORM\Entity(repositoryClass="examplemodel\CustomersRepo")
 */
class Customers
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string|null
     *
     * @ORM\Column(name="name", type="string", length=100, nullable=true)
     */
    private $name;

    /**
     * @var string|null
     *
     * @ORM\Column(name="address", type="string", length=100, nullable=true)
     */
    private $address;

    /**
     * @var string|null
     *
     * @ORM\Column(name="address_extra", type="string", length=100, nullable=true)
     */
    private $addressExtra;

    /**
     * @var string|null
     *
     * @ORM\Column(name="city", type="string", length=100, nullable=true)
     */
    private $city;

    /**
     * @var string|null
     *
     * @ORM\Column(name="postal_code", type="string", length=45, nullable=true)
     */
    private $postalCode;


    /**
     * Get id.
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name.
     *
     * @param string|null $name
     *
     * @return Customers
     */
    public function setName($name = null)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name.
     *
     * @return string|null
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set address.
     *
     * @param string|null $address
     *
     * @return Customers
     */
    public function setAddress($address = null)
    {
        $this->address = $address;

        return $this;
    }

    /**
     * Get address.
     *
     * @return string|null
     */
    public function getAddress()
    {
        return $this->address;
    }

    /**
     * Set addressExtra.
     *
     * @param string|null $addressExtra
     *
     * @return Customers
     */
    public function setAddressExtra($addressExtra = null)
    {
        $this->addressExtra = $addressExtra;

        return $this;
    }

    /**
     * Get addressExtra.
     *
     * @return string|null
     */
    public function getAddressExtra()
    {
        return $this->addressExtra;
    }

    /**
     * Set city.
     *
     * @param string|null $city
     *
     * @return Customers
     */
    public function setCity($city = null)
    {
        $this->city = $city;

        return $this;
    }

    /**
     * Get city.
     *
     * @return string|null
     */
    public function getCity()
    {
        return $this->city;
    }

    /**
     * Set postalCode.
     *
     * @param string|null $postalCode
     *
     * @return Customers
     */
    public function setPostalCode($postalCode = null)
    {
        $this->postalCode = $postalCode;

        return $this;
    }

    /**
     * Get postalCode.
     *
     * @return string|null
     */
    public function getPostalCode()
    {
        return $this->postalCode;
    }
}

Customers Repository

<?php

namespace examplemodel;
use Doctrine\ORM\EntityRepository;

class CustomersRepo extends EntityRepository {}

Products Entity

<?php

namespace examplemodel;

use Doctrine\ORM\Mapping as ORM;

/**
 * Products
 *
 * @ORM\Table(name="products", indexes={@ORM\Index(name="FK_type_products_id_23021641451650_idx", columns={"type_product_id"}), @ORM\Index(name="FK_customers_id_651016516100456_idx", columns={"customer_id"})})
 * @ORM\Entity(repositoryClass="examplemodel\ProductsRepo")
 */
class Products
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="price", type="decimal", precision=10, scale=2, nullable=false)
     */
    private $price;

    /**
     * @var \examplemodel\Customers
     *
     * @ORM\ManyToOne(targetEntity="examplemodel\Customers")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
     * })
     */
    private $customer;

    /**
     * @var \examplemodel\TypeProducts
     *
     * @ORM\ManyToOne(targetEntity="examplemodel\TypeProducts")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="type_product_id", referencedColumnName="id")
     * })
     */
    private $typeProduct;


    /**
     * Get id.
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set price.
     *
     * @param string $price
     *
     * @return Products
     */
    public function setPrice($price)
    {
        $this->price = $price;

        return $this;
    }

    /**
     * Get price.
     *
     * @return string
     */
    public function getPrice()
    {
        return $this->price;
    }

    /**
     * Set customer.
     *
     * @param \examplemodel\Customers|null $customer
     *
     * @return Products
     */
    public function setCustomer(\examplemodel\Customers $customer = null)
    {
        $this->customer = $customer;

        return $this;
    }

    /**
     * Get customer.
     *
     * @return \examplemodel\Customers|null
     */
    public function getCustomer()
    {
        return $this->customer;
    }

    /**
     * Set typeProduct.
     *
     * @param \examplemodel\TypeProducts|null $typeProduct
     *
     * @return Products
     */
    public function setTypeProduct(\examplemodel\TypeProducts $typeProduct = null)
    {
        $this->typeProduct = $typeProduct;

        return $this;
    }

    /**
     * Get typeProduct.
     *
     * @return \examplemodel\TypeProducts|null
     */
    public function getTypeProduct()
    {
        return $this->typeProduct;
    }
}

Products Repository

<?php

namespace examplemodel;
use Doctrine\ORM\EntityRepository;

class ProductsRepo extends EntityRepository {}

TypeProducts Entity

<?php

namespace examplemodel;

use Doctrine\ORM\Mapping as ORM;

/**
 * TypeProducts
 *
 * @ORM\Table(name="type_products")
 * @ORM\Entity(repositoryClass="examplemodel\TypeProductsRepo")
 */
class TypeProducts
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="code", type="string", length=20, nullable=false)
     */
    private $code;

    /**
     * @var string
     *
     * @ORM\Column(name="lib", type="string", length=100, nullable=false)
     */
    private $lib;


    /**
     * Get id.
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set code.
     *
     * @param string $code
     *
     * @return TypeProducts
     */
    public function setCode($code)
    {
        $this->code = $code;

        return $this;
    }

    /**
     * Get code.
     *
     * @return string
     */
    public function getCode()
    {
        return $this->code;
    }

    /**
     * Set lib.
     *
     * @param string $lib
     *
     * @return TypeProducts
     */
    public function setLib($lib)
    {
        $this->lib = $lib;

        return $this;
    }

    /**
     * Get lib.
     *
     * @return string
     */
    public function getLib()
    {
        return $this->lib;
    }
}

TypeProducts Repository

<?php

namespace examplemodel;
use Doctrine\ORM\EntityRepository;

class TypeProductsRepo extends EntityRepository {}

Generated proxys

Customers Proxy

<?php

namespace Proxies\__CG__\examplemodel;

/**
 * DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
 */
class Customers extends \examplemodel\Customers implements \Doctrine\ORM\Proxy\Proxy
{
    /**
     * @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with
     *      three parameters, being respectively the proxy object to be initialized, the method that triggered the
     *      initialization process and an array of ordered parameters that were passed to that method.
     *
     * @see \Doctrine\Common\Proxy\Proxy::__setInitializer
     */
    public $__initializer__;

    /**
     * @var \Closure the callback responsible of loading properties that need to be copied in the cloned object
     *
     * @see \Doctrine\Common\Proxy\Proxy::__setCloner
     */
    public $__cloner__;

    /**
     * @var boolean flag indicating if this object was already initialized
     *
     * @see \Doctrine\Persistence\Proxy::__isInitialized
     */
    public $__isInitialized__ = false;

    /**
     * @var array<string, null> properties to be lazy loaded, indexed by property name
     */
    public static $lazyPropertiesNames = array (
);

    /**
     * @var array<string, mixed> default values of properties to be lazy loaded, with keys being the property names
     *
     * @see \Doctrine\Common\Proxy\Proxy::__getLazyProperties
     */
    public static $lazyPropertiesDefaults = array (
);



    public function __construct(?\Closure $initializer = null, ?\Closure $cloner = null)
    {

        $this->__initializer__ = $initializer;
        $this->__cloner__      = $cloner;
    }







    /**
     * 
     * @return array
     */
    public function __sleep()
    {
        if ($this->__isInitialized__) {
            return ['__isInitialized__', '' . "\0" . 'examplemodel\\Customers' . "\0" . 'id', '' . "\0" . 'examplemodel\\Customers' . "\0" . 'name', '' . "\0" . 'examplemodel\\Customers' . "\0" . 'address', '' . "\0" . 'examplemodel\\Customers' . "\0" . 'addressExtra', '' . "\0" . 'examplemodel\\Customers' . "\0" . 'city', '' . "\0" . 'examplemodel\\Customers' . "\0" . 'postalCode'];
        }

        return ['__isInitialized__', '' . "\0" . 'examplemodel\\Customers' . "\0" . 'id', '' . "\0" . 'examplemodel\\Customers' . "\0" . 'name', '' . "\0" . 'examplemodel\\Customers' . "\0" . 'address', '' . "\0" . 'examplemodel\\Customers' . "\0" . 'addressExtra', '' . "\0" . 'examplemodel\\Customers' . "\0" . 'city', '' . "\0" . 'examplemodel\\Customers' . "\0" . 'postalCode'];
    }

    /**
     * 
     */
    public function __wakeup()
    {
        if ( ! $this->__isInitialized__) {
            $this->__initializer__ = function (Customers $proxy) {
                $proxy->__setInitializer(null);
                $proxy->__setCloner(null);

                $existingProperties = get_object_vars($proxy);

                foreach ($proxy::$lazyPropertiesDefaults as $property => $defaultValue) {
                    if ( ! array_key_exists($property, $existingProperties)) {
                        $proxy->$property = $defaultValue;
                    }
                }
            };

        }
    }

    /**
     * 
     */
    public function __clone()
    {
        $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', []);
    }

    /**
     * Forces initialization of the proxy
     */
    public function __load()
    {
        $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', []);
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific loading logic
     */
    public function __isInitialized()
    {
        return $this->__isInitialized__;
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific loading logic
     */
    public function __setInitialized($initialized)
    {
        $this->__isInitialized__ = $initialized;
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific loading logic
     */
    public function __setInitializer(\Closure $initializer = null)
    {
        $this->__initializer__ = $initializer;
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific loading logic
     */
    public function __getInitializer()
    {
        return $this->__initializer__;
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific loading logic
     */
    public function __setCloner(\Closure $cloner = null)
    {
        $this->__cloner__ = $cloner;
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific cloning logic
     */
    public function __getCloner()
    {
        return $this->__cloner__;
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific loading logic
     * @deprecated no longer in use - generated code now relies on internal components rather than generated public API
     * @static
     */
    public function __getLazyProperties()
    {
        return self::$lazyPropertiesDefaults;
    }

    
    /**
     * {@inheritDoc}
     */
    public function getId()
    {
        if ($this->__isInitialized__ === false) {
            return (int)  parent::getId();
        }


        $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', []);

        return parent::getId();
    }

    /**
     * {@inheritDoc}
     */
    public function setName($name = NULL)
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'setName', [$name]);

        return parent::setName($name);
    }

    /**
     * {@inheritDoc}
     */
    public function getName()
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'getName', []);

        return parent::getName();
    }

    /**
     * {@inheritDoc}
     */
    public function setAddress($address = NULL)
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAddress', [$address]);

        return parent::setAddress($address);
    }

    /**
     * {@inheritDoc}
     */
    public function getAddress()
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAddress', []);

        return parent::getAddress();
    }

    /**
     * {@inheritDoc}
     */
    public function setAddressExtra($addressExtra = NULL)
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAddressExtra', [$addressExtra]);

        return parent::setAddressExtra($addressExtra);
    }

    /**
     * {@inheritDoc}
     */
    public function getAddressExtra()
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAddressExtra', []);

        return parent::getAddressExtra();
    }

    /**
     * {@inheritDoc}
     */
    public function setCity($city = NULL)
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCity', [$city]);

        return parent::setCity($city);
    }

    /**
     * {@inheritDoc}
     */
    public function getCity()
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCity', []);

        return parent::getCity();
    }

    /**
     * {@inheritDoc}
     */
    public function setPostalCode($postalCode = NULL)
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPostalCode', [$postalCode]);

        return parent::setPostalCode($postalCode);
    }

    /**
     * {@inheritDoc}
     */
    public function getPostalCode()
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPostalCode', []);

        return parent::getPostalCode();
    }

}

TypeProducts Proxy

<?php

namespace Proxies\__CG__\examplemodel;

/**
 * DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
 */
class TypeProducts extends \examplemodel\TypeProducts implements \Doctrine\ORM\Proxy\Proxy
{
    /**
     * @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with
     *      three parameters, being respectively the proxy object to be initialized, the method that triggered the
     *      initialization process and an array of ordered parameters that were passed to that method.
     *
     * @see \Doctrine\Common\Proxy\Proxy::__setInitializer
     */
    public $__initializer__;

    /**
     * @var \Closure the callback responsible of loading properties that need to be copied in the cloned object
     *
     * @see \Doctrine\Common\Proxy\Proxy::__setCloner
     */
    public $__cloner__;

    /**
     * @var boolean flag indicating if this object was already initialized
     *
     * @see \Doctrine\Persistence\Proxy::__isInitialized
     */
    public $__isInitialized__ = false;

    /**
     * @var array<string, null> properties to be lazy loaded, indexed by property name
     */
    public static $lazyPropertiesNames = array (
);

    /**
     * @var array<string, mixed> default values of properties to be lazy loaded, with keys being the property names
     *
     * @see \Doctrine\Common\Proxy\Proxy::__getLazyProperties
     */
    public static $lazyPropertiesDefaults = array (
);



    public function __construct(?\Closure $initializer = null, ?\Closure $cloner = null)
    {

        $this->__initializer__ = $initializer;
        $this->__cloner__      = $cloner;
    }







    /**
     * 
     * @return array
     */
    public function __sleep()
    {
        if ($this->__isInitialized__) {
            return ['__isInitialized__', '' . "\0" . 'examplemodel\\TypeProducts' . "\0" . 'id', '' . "\0" . 'examplemodel\\TypeProducts' . "\0" . 'code', '' . "\0" . 'examplemodel\\TypeProducts' . "\0" . 'lib'];
        }

        return ['__isInitialized__', '' . "\0" . 'examplemodel\\TypeProducts' . "\0" . 'id', '' . "\0" . 'examplemodel\\TypeProducts' . "\0" . 'code', '' . "\0" . 'examplemodel\\TypeProducts' . "\0" . 'lib'];
    }

    /**
     * 
     */
    public function __wakeup()
    {
        if ( ! $this->__isInitialized__) {
            $this->__initializer__ = function (TypeProducts $proxy) {
                $proxy->__setInitializer(null);
                $proxy->__setCloner(null);

                $existingProperties = get_object_vars($proxy);

                foreach ($proxy::$lazyPropertiesDefaults as $property => $defaultValue) {
                    if ( ! array_key_exists($property, $existingProperties)) {
                        $proxy->$property = $defaultValue;
                    }
                }
            };

        }
    }

    /**
     * 
     */
    public function __clone()
    {
        $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', []);
    }

    /**
     * Forces initialization of the proxy
     */
    public function __load()
    {
        $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', []);
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific loading logic
     */
    public function __isInitialized()
    {
        return $this->__isInitialized__;
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific loading logic
     */
    public function __setInitialized($initialized)
    {
        $this->__isInitialized__ = $initialized;
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific loading logic
     */
    public function __setInitializer(\Closure $initializer = null)
    {
        $this->__initializer__ = $initializer;
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific loading logic
     */
    public function __getInitializer()
    {
        return $this->__initializer__;
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific loading logic
     */
    public function __setCloner(\Closure $cloner = null)
    {
        $this->__cloner__ = $cloner;
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific cloning logic
     */
    public function __getCloner()
    {
        return $this->__cloner__;
    }

    /**
     * {@inheritDoc}
     * @internal generated method: use only when explicitly handling proxy specific loading logic
     * @deprecated no longer in use - generated code now relies on internal components rather than generated public API
     * @static
     */
    public function __getLazyProperties()
    {
        return self::$lazyPropertiesDefaults;
    }

    
    /**
     * {@inheritDoc}
     */
    public function getId()
    {
        if ($this->__isInitialized__ === false) {
            return (int)  parent::getId();
        }


        $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', []);

        return parent::getId();
    }

    /**
     * {@inheritDoc}
     */
    public function setCode($code)
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCode', [$code]);

        return parent::setCode($code);
    }

    /**
     * {@inheritDoc}
     */
    public function getCode()
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCode', []);

        return parent::getCode();
    }

    /**
     * {@inheritDoc}
     */
    public function setLib($lib)
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'setLib', [$lib]);

        return parent::setLib($lib);
    }

    /**
     * {@inheritDoc}
     */
    public function getLib()
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'getLib', []);

        return parent::getLib();
    }

}

Error

The error

Notice: Accessing static property Proxies_CG_\examplemodel\Customers::$lazyPropertiesNames as non static

occured when I try to serialize the entities collection in Test.php

@KevinMarques
Copy link

KevinMarques commented Jun 2, 2020

Same issue here after updating doctrine/orm from 2.7.2 to 2.7.3.

@renatko
Copy link

renatko commented Jun 2, 2020

Same issue here. Downgrade to "doctrine/common": "2.13.*" fixed it

@jannmylj
Copy link
Author

jannmylj commented Jun 3, 2020

I have no urgency on my side for the moment.
I prefer not to set the doctrine/common version and let the dependency manager choose the best / latest version.
Is it a mistake ?

@thepercival
Copy link

yes, downgrading is the solution for now:
"doctrine/persistence": "^1.3"
or as renatko said : "doctrine/common": "2.13.*"

@waresz
Copy link

waresz commented Jun 3, 2020

Same error after updating to doctrine 2.7.3.

-> Downgrade to 2.7.2.

@goetas goetas linked a pull request Jun 4, 2020 that will close this issue
@goetas
Copy link
Collaborator

goetas commented Jun 4, 2020

can you please try #1210 ?

@jannmylj
Copy link
Author

jannmylj commented Jun 4, 2020

I've got expected result

string(461) "[{"id":1,"price":"100.00","customer":{"id":1,"name":"Customer 1","address":"Address 1","address_extra":"Address extra 1","city":"City 1","postal_code":"75001"},"type_product":{"id":1,"code":"typeProducts1","lib":"Type product 1"}},{"id":2,"price":"200.00","customer":{"id":2,"name":"Customer 2","address":"Address 2","address_extra":"Address extra 2","city":"City 2","postal_code":"75002"},"type_product":{"id":2,"code":"typeProducts2","lib":"Type product 2"}}]"

Good news!

@nikserg
Copy link

nikserg commented Apr 16, 2021

Same issue with Doctrine 2.8.4. All models serialize normally, except one. If I ignore this notice, serialized model will look like this

{
            "id": 2,
            "person": {
                "__initializer__": [],
                "__cloner__": [],
                "__isInitialized__": false,
                "lazyPropertiesNames": null,
                "lazyPropertiesDefaults": null,
                "createdAt": "2021-04-15T11:19:23+00:00",
                "id": 1,
                "firstName": "123",
                "lastName": "21312",
                "middleName": "34234234",
                "abc": "33344434",
                "updatedAt": "2021-04-15T11:19:23+00:00"
            },
            "createdAt": "2021-04-15T14:30:21+00:00",
            "certificateTemplate": {
                "__initializer__": [],
                "__cloner__": [],
                "__isInitialized__": false,
                "lazyPropertiesNames": null,
                "lazyPropertiesDefaults": null,
                "id": 1,
                "name": "ЕПГУ",
                "oids": [
                    {
                        "id": 1,
                        "name": "Abc 1",
                        "value": "1.2.3.4"
                    },
                    {
                        "id": 2,
                        "name": "Abc 2",
                        "value": "1.2.3.5"
                    }
                ]
            },
            "updatedAt": "2021-04-15T14:30:21+00:00"
        }

Model looks like this:

/**
 * @ORM\Entity(repositoryClass=CertificateRepository::class)
 */
class Certificate implements OwnedEntityInterface
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity=CertificateTemplate::class)
     * @ORM\JoinColumn(nullable=false)
     * @Ignore
     */
    private $certificate_template;

    /**
     * @ORM\ManyToOne(targetEntity=Organization::class)
     * @ORM\JoinColumn(nullable=false)
     * @Ignore
     */
    private $organization;


    /**
     * @ORM\Column(type="datetime")
     * @Ignore
     */
    private $created_at;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     * @Ignore
     */
    private $updated_at;

    /**
     * @ORM\ManyToOne(targetEntity=User::class)
     * @Ignore()
     */
    private $user;

    /**
     * @ORM\ManyToOne(targetEntity=Person::class, cascade={"persist"})
     */
    private $person;
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants