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
261 stars 63 forks source link

Constants are working in theory, but ignored in real life #783

Open i2dcarrasco opened 2 days ago

i2dcarrasco commented 2 days ago

Hello,

I am using this module from a time ago in some Wordpress installations. For now was working because the settings were set directly on the plugin configuration page but now by requirements of our environments I need to set it using constants. The reason is mainly because the DB of the environment will be replaced by the DB in another environment from time to time, so the configuration params will come with that dump (that's a problem).

The problem is that in theory the constants are working because the configuration page shows the settings greyed out and with the correct configurations that I set via those constants, but in real life the settings seems to be ignored and instead is using the database settings.

My constants:

define('WP_STATELESS_MEDIA_BUCKET', getenv('WP_STATELESS_MEDIA_BUCKET'));
define('WP_STATELESS_MEDIA_KEY_FILE_PATH', getenv('WP_STATELESS_MEDIA_KEY_FILE_PATH'));
define('WP_STATELESS_MEDIA_CUSTOM_DOMAIN', getenv('WP_STATELESS_MEDIA_CUSTOM_DOMAIN') ? getenv('WP_STATELESS_MEDIA_CUSTOM_DOMAIN') : null);

Steps I have follow to trigger the issue:

A summary can be the title: The settings provided by the constans are readed and considered in the settings page but not in the rest of the plugin, so it's not working as expected.

Best regards.

planv commented 2 days ago

Hello, @i2dcarrasco

Could you please copy the info from the Media / Stateless Setting / Status page and post it here?

Thanks!

i2dcarrasco commented 6 hours ago

Hello,

The status right now without constants is:

### Server

Server architecture: Linux 6.1.85+ x86_64
Web server: nginx/1.24.0
MySQL version: 8.0.31-google
PHP Version: 8.1.29
PHP Memory Limit: 2G
PHP Max Input Vars: 1000
PHP Max Post Size: 32M
PHP Time Limit: 600
Max Upload Size: 8M
Allow URL-aware fopen Wrappers: Yes
Loaded Extensions: Core, date, libxml, pcre, zlib, filter, hash, json, readline, Reflection, SPL, session, cgi-fcgi, bcmath, ctype, curl, dom, fileinfo, gd, iconv, intl, mbstring, openssl, standard, soap, sockets, tokenizer, xml, xmlwriter, zip, exif, mysqlnd, xmlreader, mysqli, apcu, msgpack, igbinary, brotli, ddtrace, ddappsec, redis, Zend OPcache

### WordPress

Version: 6.5.4
Multisite: Yes
Memory Limit: 64M

### WP-Stateless

Version: 4.0.4
Database Version: 1.1
Mode: CDN
File URL Replacement: Disabled
Supported File Types: jpg jpeg png gif pdf
Bucket: Not set
Bucket Accessible: Yes
Service Account JSON: Not set
Cache-Control: Default: public, max-age=36000, must-revalidate
Delete GCS File: Enable
Folder: sites/%site_id%/%date_year/date_month%
Domain: Not set
Cache-Busting: Disable
Dynamic Image Support: Disable
Use Post Meta: Don't override

After enabling the constants:

### Server

Server architecture: Linux 6.1.85+ x86_64
Web server: nginx/1.24.0
MySQL version: 8.0.31-google
PHP Version: 8.1.29
PHP Memory Limit: 2G
PHP Max Input Vars: 1000
PHP Max Post Size: 32M
PHP Time Limit: 600
Max Upload Size: 8M
Allow URL-aware fopen Wrappers: Yes
Loaded Extensions: Core, date, libxml, pcre, zlib, filter, hash, json, readline, Reflection, SPL, session, cgi-fcgi, bcmath, ctype, curl, dom, fileinfo, gd, iconv, intl, mbstring, openssl, standard, soap, sockets, tokenizer, xml, xmlwriter, zip, exif, mysqlnd, xmlreader, mysqli, apcu, msgpack, igbinary, brotli, ddtrace, ddappsec, redis, Zend OPcache

### WordPress

Version: 6.5.4
Multisite: Yes
Memory Limit: 64M

### WP-Stateless

Version: 4.0.4
Database Version: 1.1
Mode: CDN (Constant)
File URL Replacement: Disabled
Supported File Types: jpg jpeg png gif pdf
Bucket: Set (Constant)
Bucket Accessible: Yes
Service Account JSON: Set (Constant)
Cache-Control: Default: public, max-age=36000, must-revalidate
Delete GCS File: Enable
Folder: sites/%site_id%/%date_year/date_month%
Domain: Set (Constant)
Cache-Busting: Disable
Dynamic Image Support: Disable
Use Post Meta: Don't override

It says "bucket accesible" and "set by constants", but when I go to a site to upload any file, I can see this: Captura-desde-2024-11-27-13-16-00.png

If I upload any file the upload is done locally instead to the storage.

My Wordpress is multisite, I don't know if that can be the problem.

The above error is now that I have emptied all the configurations, but after emtying it I was able to see how it was trying to use the stored settings instead the constant provided settings (just like now that is using the empty stored settings). If I go to the settings page in the site were I am trying to upload the files, I can see how the settings are also filled with the correct data like in the network settings page.

Best regards.