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

PHP notice: Undefined index: file in ..\tiny-compress-images\src\class-tiny-image.php on line 48 #12

Closed
jerturowetz opened this issue Apr 11, 2017 · 4 comments

Comments

@jerturowetz
Copy link

In the plugin-created Compression column of my media library I'm getting the following notice for PDFs and some other custom file types:

Undefined index: file in ..\tiny-compress-images\src\class-tiny-image.php on line 48

I assumed that this issue occurs because parse_wp_metadata() isn't checking if this is of the allowed file types before moving forward (assuming of course the allowed file types will have 'file' set), it seems only to check that $this->wp_metadata be an array.

I thought of adding isset($this->wp_metadata['file']) to line 45 but I end up breaking has_been_compressed() among other things...

@tinify-support
Copy link

tinify-support commented Apr 13, 2017 via email

@jerturowetz
Copy link
Author

Version 2.2.2

I don't think it's necessary to send you the file as I did a bit of digging since last we spoke and I think I found the issue. It occured when PDF auto-gen thumbnails were forcibly removed and the plugin tried to optimize them (due to my implementation of an S3 bucket for migrating static files).

I gather the PDF thumbnails being images trigger the the plugins is-it-an-image test. Regardless of this assumption, should attachment information be stored as metadata, but not have a 'file' key & info, parse_wp_metadata() in src\class-tiny-image.php will cause this error.

While probably not an issue for many, I think it would still be better practice to explicitly check for the file key rather than assuming it exists when the attachment's meta is an array. To this end I've gone ahead and added the check to parse_wp_metadata and detect_duplicates and will issue a pull request for your review.

@tinify-support
Copy link

tinify-support commented Apr 18, 2017 via email

@jerturowetz
Copy link
Author

Killer, let me know if there's any where I could improve it too (it didn't pass the Travis build and I'm wondering why as I didn't really do much :P )

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

No branches or pull requests

2 participants