8000 [Bug]: getId() on null when no default layout is available · Issue #14144 · pimcore/pimcore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[Bug]: getId() on null when no default layout is available #14144
Closed
@jensschaerer

Description

@jensschaerer

Expected behavior

Open dataobject and show data in (first) Custom Layout available to user

Actual behavior

Uncaught Error: Call to a member function getId() on null {"exception":"[object] (Error(code: 0): Call to a member function getId() on null at /var/www/html/vendor/pimcore/pimcore/bundles/AdminBundle/Controller/Admin/DataObject/DataObjectController.php:516

Steps to reproduce

I added a user with no rights defined to the user. Instead, the user has two roles: "readOnly" and "Product management". In the roles, the data object "Product" has a custom layout defined (Custom layout "readOnly" for role readOnly and "Product view" for role "Product management").

When I login as this user, I can't open data objects of type "Product". Instead I get an error 500, "Call to a member function getId() on null"

I investigated the error and it seems, that the default layout is not selected, because neither the Master layout (ID 0) exists for the user nor is any of the two assigned layouts defined as default layout:

 //master layout has id 0 so we check for is_null()
            if ($currentLayoutId === null && !empty($validLayouts)) {
                if (count($validLayouts) === 1) {
                    $firstLayout = reset($validLayouts);
                    $currentLayoutId = $firstLayout->getId();
                } else {
                    foreach ($validLayouts as $checkDefaultLayout) {
                        if ($checkDefaultLayout->getDefault()) {
                            $currentLayoutId = $checkDefaultLayout->getId();
                        }
                    }
                }
            }

            if ($currentLayoutId === null && count($validLayouts) > 0) {
                $currentLayoutId = $validLayouts[0]->getId(); //<-- this is line 516 where the error occurs
            }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0