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

Undefined property: stdClass::$image in 1.8.2 #1454

Closed
superDuperCyberTechno opened this issue May 28, 2018 · 8 comments
Closed

Undefined property: stdClass::$image in 1.8.2 #1454

superDuperCyberTechno opened this issue May 28, 2018 · 8 comments
Assignees
Labels

Comments

@superDuperCyberTechno
Copy link

superDuperCyberTechno commented May 28, 2018

I get the error Undefined property: stdClass::$image when uploading an image to a page template. The error handler specifically references line 722 in adminbasecontroller.php. The image specific blueprint is here:

            header.image:
                type: file
                label: Screenshot
                limit: 1
                destination: 'self@'
                multiple: false
                style: vertical
                accept:
                  - image/*

The image gets uploaded regardless of error, but the header is not updated...

Rolling back to 1.8.1 fixed it for now.

@rhukster
Copy link
Member

Don't do this, pagemedia field already uploads to the page folder. File field is intended to be used in other non-page blueprints.

@superDuperCyberTechno
Copy link
Author

So, what would the correct way be to achieve this, blueprint wise?

@herrbischoff
Copy link
Contributor

herrbischoff commented May 29, 2018

Same here. Since the update to Grav 1.4.5 and Admin 1.8.2, I cannot upload images, resulting in the same error @superDuperCyberTechno reported.

My blueprint excerpt is as follows:

[...]
header.images:
  type: file
  label: Images
  random_name: true
  multiple: true
  limit: 2
  destination: 'assets'
  filesize: 10
  accept:
    - image/*
[...]

This has worked thus far without issue. The update broke it.

If there are breaking changes, it would be advantageous to know about them before the update. If there are best practices, it would be great to know about them at all instead of just getting a response like

Don't do this, pagemedia field already uploads to the page folder. File field is intended to be used in other non-page blueprints.

without any pointers as to why. I created the blueprint according to the documentation at the time and it worked. Either this is a bug or a breaking, non-documented change.

Update: Downgrading to Admin 1.8.1 resolved this for me as well. This reinforces my impression that this is most likely a bug introduced in 1.8.2.

Additionally, I have found out that when deleting one post with this setup, all images in the assets folder get deleted. This appears to be a rather large bug in the admin interface inner workings and has caused me tons of frustration today.

@rhukster
Copy link
Member

rhukster commented May 29, 2018

We didn’t realize this was a breaking change because this field really is not intended to replace pagemedia picker. Now we have a couple of reports of people using file field in conjunction with pagemedia picker, we’ll investigate and find a solution. Sorry about this!

@rhukster
Copy link
Member

FYI the recommended approach is to use the standard pagemedia field to upload images into a page and a filepicker to select them for specific header variables

@herrbischoff
Copy link
Contributor

herrbischoff commented May 29, 2018

FYI the recommended approach is to use the standard pagemedia field to upload images into a page and a filepicker to select them for specific header variables

This recommended approach strikes me as counter-intuitive. Uploading and assigning a file/image to a field should be one action, not two. Teaching users to do it in two steps would be frustrating and should not be necessary.

In any case, thanks for looking into it.

@mahagr
Copy link
Member

mahagr commented May 31, 2018

Issue can be fixed by changing line 722 in adminbasecontroller.php to have isset():

if (isset($obj->header()->{$init_key})) {

@mahagr
Copy link
Member

mahagr commented Jun 14, 2018

This issue has been fixed in Admin 1.8.3

@mahagr mahagr closed this as completed Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants