udx / wp-stateless

WP-Stateless is a WordPress plugin that uploads and serves your WordPress media from Google Cloud Storage.
https://stateless.udx.io
MIT License
260 stars 62 forks source link

Sync function and compatibility with Elementor plugin is not working #724

Closed basinghse closed 5 months ago

basinghse commented 6 months ago

When attempting to offload media to GCP storage:

  1. Images are only being redirected when using the Stateless mode. All other modes do not direct my images to GCP. If we can resolve the below issues, I am happy to continue with Stateless mode though.
  2. The sync feature queues all of the images/files but never processes
    • In the debug log I can only see that the Background Sync has started and nothing else: Background Sync - Media Library Images: Started
  3. The Elementor Page Builder compatibility setting does not seem to be working as expected.
    • Firstly, Elementor CSS files are expected in bucket > 2024 > 03 (current month) > elementor > css. I believe this is because of the folder setting of /$date_year/date_month&/ in Stateless settings - but in the regular structure, elementor files are placed in the main directory wp_content > uploads. Wouldn't this cause issues when we move into the next month (04) and we would have to manually move the Elementor folder each time? I think it would make sense for the elementor files to be uploaded to the root directory of the bucket when the Elementor Page Builder compatibility is enabled - regardless of the folder structure (year/month/) currently set.
    • There also seems to be an issue with custom CSS files. We have a few custom files uploaded in the Elementor CSS folder - and if we are to run Regenerate Files & Data in the Elementor tool section, when Stateless is enabled the custom CSS files do not seem to apply and the layout breaks. This is the case even when we manually add the custom css files to the elementor > css file in GCP - the webpage will not load the custom layout. The following error is received repeatedly in debug when trying to load the webpage:
    • PHP Warning: Undefined array key "file" in /var/www/html/wp-content/plugins/wp-stateless/lib/classes/class-bootstrap.php on line 1510
    • Running Regenerate Files & Data loads everything correctly when WP-Stateless is disabled in comparison

I have attempted to use both uniform and fine-grained access controls in the GCP bucket. Storage admin is set for the service account in the bucket.

Diagnostics:

WordPress: 6.4.3
Web Server: Apache/2.4.57 (Debian)
PHP: 8.2.16
MySQL: 8.0.31
WP_DEBUG: Yes
WP_DEBUG_LOG: Yes
WP_DEBUG_DISPLAY: No
Elementor: Version 3.19.4 
Elementor Pro: Version 3.19.2

Thanks in advance.

ewsopp commented 6 months ago

Thank you for reporting. We'll take a look!

balexey88 commented 6 months ago

Hello @basinghse ,

Thank you for using our product.

I checked with the following environment:

WordPress: 6.4.3
PHP: 8.0.28 and 8.3.4
Elementor: Version 3.20.3
Elementor Pro: Version 3.20.2
  1. If I got you right, file upload to GCS is only working in Stateless mode. Not sure what can be the issue here. If upload in Stateless mode works then there is no reason why other modes does not work. Please try to disable all other plugins except WP-Stateless, try to upload, for example, in CDN mode and check the logs. Maybe this will give more details to resolve the issue.

  2. Sync feature uses AJAX requests to handle the processing queue. If the access to /wp-admin/admin-ajax.php is restricted then it may not work. Also one of the reasons why it is not able to process the queue is when your site is behind BasicAuth. If this is the case please try this solution.

  3. In general, the Folder setting applies to normal WP attachments. Files generated by Elementor upload to [bucket_root]/elementor/.... So the full URL of post-123.css will be https://storage.googleapis.com/bucket-name/elementor/css/post-123.css.

Regarding CSS files I'm not sure I fully understand your use case. You uploaded custom css files into uploads/elementor/css folder and load files using wp_enqueue_style? Is this correct? If so, try to use different folder name, other than elementor/ for your custom files. This is because our Elementor Compatibility applies special handling for the files in elementor/ folder and its logic is not handling files that were not generated by Elementor itself.

Please let us know if this helps you in any way or you have more questions.

Also please consider that starting from our next release Elementor Compatibility will be removed from WP-Stateless and we encourage you to use WP-Stateless – Elementor Website Builder Addon instead. Currently its functionality is equivalent to Elementor Compatibility but all the future updates will be added to "WP-Stateless – Elementor Website Builder Addon" plugin only.

Best regards and have a nice day!

ewsopp commented 5 months ago

@basinghse, any feedback here? We will close this issue if no response is received within the next 7 to 10 days.