Skip to content

Cannot assign array to property verbb\vizy\models\BlockType::$layoutUid of type ?string #353

@laneigemud1990

Description

@laneigemud1990

Describe the bug

Hi there,
Since I have upgraded to vizy version 3.0.10, I am getting the bug mentioned in the title on pretty much
every page that uses vizy. Perhaps just a data type thing?

Steps to reproduce

  1. Try to access any page on the FE or within the craftcms admin with vizy blocks and it will throw this error.

Craft CMS version

Craft CMS Pro 5.8.15

Plugin version

3.0.10

Multi-site?

No

Additional context

What I thought is the relevant part of the stack trace below:

3. in /var/www/html/vendor/verbb/vizy/src/fields/VizyField.php at line 480– craft\base\Model::__construct()
474475476477478479480481482483484485486            return $this->_blockTypesById[$blockTypeId];
        }
 
        foreach ($this->fieldData as $group) {
            foreach ($group['blockTypes'] as $block) {
                if ($block['id'] === $blockTypeId || $block['handle'] === $blockTypeId) {
                    return $this->_blockTypesById[$blockTypeId] = new BlockType($block);
                }
            }
        }
 
        return null;
    }
4. in /var/www/html/vendor/verbb/vizy/src/nodes/VizyBlock.php at line 62– verbb\vizy\fields\VizyField::getBlockTypeByIdOrHandle()
56575859606162636465666768        parent::__construct($config);
 
        $blockTypeId = $this->attrs['values']['type'] ?? '';
 
        if ($blockTypeId) {
            // We might be trying to get the block type via ID or handle (GQL uses handles)
            $this->_blockType = $this->getField()->getBlockTypeByIdOrHandle($blockTypeId);
 
            if ($this->_blockType) {
                $this->_fieldLayout = $this->_blockType->getFieldLayout();
 
                // Save as shortcut to the blocktype handle, for templating ease
                $this->handle = $this->_blockType->handle;
5. verbb\vizy\nodes\VizyBlock::__construct()
6. in /var/www/html/vendor/yiisoft/yii2/di/Container.php at line 419– ReflectionClass::newInstanceArgs()
7. in /var/www/html/vendor/yiisoft/yii2/di/Container.php at line 170– [yii\di\Container::build](https://www.yiiframework.com/doc-2.0/yii-di-container.html#build()-detail)()
8. in /var/www/html/vendor/yiisoft/yii2/BaseYii.php at line 365– [yii\di\Container::get](https://www.yiiframework.com/doc-2.0/yii-di-container.html#get()-detail)()
9. in /var/www/html/vendor/craftcms/cms/src/Craft.php at line 70– [yii\BaseYii::createObject](https://www.yiiframework.com/doc-2.0/yii-baseyii.html#createObject()-detail)()
64656667686970717273747576    public static function createObject($type, array $params = [])
    {
        if (is_array($type) && isset($type['__class']) && isset($type['class'])) {
            throw new InvalidConfigException('`__class` and `class` cannot both be specified.');
        }
 
        return parent::createObject($type, $params);
    }
 
    /**
     * Checks if a string references an environment variable (`$VARIABLE_NAME`)
     * and/or an alias (`@aliasName`), and returns the referenced value.
     *
10. in /var/www/html/vendor/verbb/vizy/src/models/NodeCollection.php at line 320– Craft::createObject()
314315316317318319320321322323324325326                continue;
            }
 
            if ($class = ($this->_registeredNodesByType[$node['type']] ?? null)) {
                unset($node['type']);
 
                $nodeClass = Craft::createObject(array_merge($node, [
                    'class' => $class,
                    'field' => $this->field,
                    'element' => $this->element,
                    'rawNode' => $rawNode,
                ]));
 
11. in /var/www/html/vendor/verbb/vizy/src/models/NodeCollection.php at line 69– verbb\vizy\models\NodeCollection::_populateNodes()
63646566676869707172737475 
        // Save here as we're recursively populating nodes/marks
        $this->_registeredNodesByType = Vizy::$plugin->getNodes()->getRegisteredNodesByType();
        $this->_registeredMarksByType = Vizy::$plugin->getNodes()->getRegisteredMarksByType();
 
        // Prepare node/mark classes for the collection
        $this->nodes = $this->_populateNodes($this->rawNodes);
        $this->nodes = $this->_normalizeNodes($this->getNodes(), $this->element);
 
        parent::__construct(null, null);
    }
 
    public function __toString(): string
12. in /var/www/html/vendor/verbb/vizy/src/fields/VizyField.php at line 257– verbb\vizy\models\NodeCollection::__construct()
251252253254255256257258259260261262263        }
 
        if (!is_array($value)) {
            $value = [];
        }
 
        return new NodeCollection($this, $value, $element);
    }
 
    public function serializeValue(mixed $value, ElementInterface $element = null): mixed
    {
        if ($value instanceof NodeCollection) {
            $value = $value->serializeValues($element);
13. in /var/www/html/vendor/craftcms/cms/src/base/Element.php at line 6759– verbb\vizy\fields\VizyField::normalizeValue()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions