Magento 2.1.0
Call addAttributeToSelect('*') on collection
A valid collection (as worked in 2.0.7)
main.CRITICAL: Exception: Serialization of 'Magento\Framework\View\Layout\Element' is not allowed in .../vendor/magento/module-eav/Model/Entity/AttributeCache.php:116
Stack trace:
Debugging in the attribute cache, it appears that serialisation of the static attributes is failing, although it's fine for the non-static attributes.
I've seen a suggestion that this is not an issue if I specify exactly which attributes I want, which is true, but the point of using EAV is that at compile time I will not always know the complete set of attributes I need.
As a temporary measure I've had to exclude my EAV entity from attribute caching via di.xml:
  <type name="Magento\Eav\Model\Entity\AttributeCache">
        <arguments>
            <argument name="unsupportedTypes" xsi:type="array">
                <item name="0" xsi:type="string">my_eav_attr</item>
            </argument>
        </arguments>
    </type>
                    I experience the same issue after upgrading to M2.1
edit:
My temp fix is to just disable the EAV caching type
I'm running Community Edition
I'm running Magento EE 2.1.0 and I have the same issue since the upgrade with addAttributeToSelect('*') on custom entity collections.
This also has something to do with the mode in which Magento is running.
I'm having the same issue when running in developer mode, but in production mode this is not an issue
Hi,
We have the same problem after upgrading to magento CE 2.1.1
Same issue for me. Magento CE 2.1.1 and Magento EE 2.1.1
@maderlock I managed to get it working on custom entity attributes by reporting this line : https://github.com/magento/magento2/blob/develop/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php#L827
to my attributes.
I think the "raw" EAV attributes are not usable "as is", because when looking at catalog eav attributes, they add a lot of code to get them working. There is this one regarding the __sleep() method but also custom methods to have a working scoping for attribute values.
Regards
I have the same issue after upgrading to CE 2.1.1. @jessetaverne temporary fix worked for me, thanks.
Yes I also fixed this by creating my own attribute model and adding the unsetData at __sleep():
<?php
namespace Example\Module\Model\Entity;
/**
 * Class Attribute
 * @package Example\Module\Model\Entity
 */
class Attribute extends \Magento\Eav\Model\Entity\Attribute
{
    /**
     * This fixes https://github.com/magento/magento2/issues/5339
     *
     * @inheritdoc
     */
    public function __sleep()
    {
        $this->unsetData('entity_type');
        return parent::__sleep();
    }
}
And after that putting this model in the eav_entity_type table (attribute model = "Example\Module\Model\Entity\Attribute" with my custom entity. This solves the issue like @romainruaud said.
I'm having this same problem in CE 2.1.7 when I extend \Magento\Catalog\Model\ResourceModel\Eav\Attribute and add an extra dependency to the constructor. The __sleep()-fix doesn't work, since it's parent class is already doing the same.
Buggy EAV Attribute Cache mechanism was removed on Magento 2.2.0 branch: https://github.com/magento/magento2/commit/3ae7c1909daad96d5a0ad6ab7048455448ba7480
This is not something that could be backported due to BC constraints, as a workaround you can try just to disable this cache type.
Most helpful comment
This also has something to do with the mode in which Magento is running.
I'm having the same issue when running in developer mode, but in production mode this is not an issue