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

Compatibility issue with WordPress 5.3 #406

Closed
alimuzzaman opened this issue Nov 7, 2019 · 7 comments
Closed

Compatibility issue with WordPress 5.3 #406

alimuzzaman opened this issue Nov 7, 2019 · 7 comments
Assignees
Milestone

Comments

@alimuzzaman
Copy link
Contributor

alimuzzaman commented Nov 7, 2019

The stateless mode has a problem with the new WordPress v 5.3.

The full-size image gets uploaded to GCS before generating the thumbnails.
So thumbnails don't get generated on Stateless mode.

@alimuzzaman
Copy link
Contributor Author

alimuzzaman commented Nov 7, 2019

wp_update_attachment_metadata is called here in wp_create_image_subsizes
wp-admin/includes/image.php#L324

Before generating thumbnails in _wp_make_subsizes wp-admin/includes/image.php#L341

In stateless mode, the full-size image is removed from the server in wp_create_image_subsizes function. So later in _wp_make_subsizes function can't find the full size image.

wp_update_attachment_metadata is called multiple times (once for each image size) in wp-admin/includes/image.php#L421

@antonkorotkov
Copy link
Contributor

@alimuzzaman Does it look possible to change the logic for the WordPress starting 5.3 and up? The only thing that comes on mind right now is to remove the original image later so that _wp_make_subsizes can get it.

I see that _wp_make_subsizes runs wp_update_attachment_metadata as well https://github.com/WordPress/WordPress/blob/5.3-branch/wp-admin/includes/image.php#L430 Maybe we can use this too somehow?

Basically, we need to rethink the Stateless Mode in WP 5.3. Don't be afraid to change the logic drastically if needed. This is the only way to keep things updated with the evolving WP.

@alimuzzaman
Copy link
Contributor Author

Possible way to handle:

  1. On the first call from wp_create_image_subsizes $metadata[ 'sizes' ] array is empty.
    What if we don't full size image if sizes array is empty!

  2. We can use "intermediate_image_sizes_advanced" filter to indicate that we can now delete image. We will only delete image from server after this filter is fired.

It may possible that some image/file could be left on server.

@antonkorotkov
Copy link
Contributor

Yeah, I meant something like this.

@alimuzzaman
Copy link
Contributor Author

alimuzzaman commented Nov 8, 2019

@alimuzzaman
Copy link
Contributor Author

We have performance issue because of:

wp_update_attachment_metadata is called multiple times (once for each image size) in wp-admin/includes/image.php#L421

[09-Nov-2019 18:54:26 UTC] Media Insert: rabbit.ci/2019/11/008dadf4-alim.jpg
[09-Nov-2019 18:54:30 UTC] Media Insert: rabbit.ci/2019/11/008dadf4-alim-300x225.jpg

[09-Nov-2019 18:54:31 UTC] Media Insert: rabbit.ci/2019/11/008dadf4-alim-300x225.jpg
[09-Nov-2019 18:54:32 UTC] Media Insert: rabbit.ci/2019/11/008dadf4-alim-150x150.jpg

[09-Nov-2019 18:54:34 UTC] Media Insert: rabbit.ci/2019/11/008dadf4-alim-300x225.jpg
[09-Nov-2019 18:54:35 UTC] Media Insert: rabbit.ci/2019/11/008dadf4-alim-150x150.jpg
[09-Nov-2019 18:54:36 UTC] Media Insert: rabbit.ci/2019/11/008dadf4-alim-768x576.jpg

[09-Nov-2019 18:54:38 UTC] Media Insert: rabbit.ci/2019/11/008dadf4-alim-300x225.jpg
[09-Nov-2019 18:54:39 UTC] Media Insert: rabbit.ci/2019/11/008dadf4-alim-150x150.jpg
[09-Nov-2019 18:54:40 UTC] Media Insert: rabbit.ci/2019/11/008dadf4-alim-768x576.jpg
[09-Nov-2019 18:54:43 UTC] Media Insert: rabbit.ci/2019/11/008dadf4-alim-825x510.jpg

alimuzzaman pushed a commit that referenced this issue Nov 10, 2019
Making sure we don't try to sync same size multiple times.
@alimuzzaman
Copy link
Contributor Author

WP Stateless is now compatible with WordPress 5.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants