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

Defining WP_ROCKET_PLUGIN_NAME in wp-config.php causes PHP Warning #7183

Open
joejoe04 opened this issue Dec 12, 2024 · 4 comments
Open

Defining WP_ROCKET_PLUGIN_NAME in wp-config.php causes PHP Warning #7183

joejoe04 opened this issue Dec 12, 2024 · 4 comments

Comments

@joejoe04
Copy link

Describe the bug
When defining WP_ROCKET_PLUGIN_NAME in wp-config.php to change the WP Rocket name to something else in the WP Admin, the following error is logged:

[12-Dec-2024 04:03:30 UTC] PHP Warning: Constant WP_ROCKET_PLUGIN_NAME already defined in /home/user/example.com/wp-content/plugins/wp-rocket/inc/main.php on line 40

To Reproduce

  1. Add define( 'WP_ROCKET_PLUGIN_NAME', 'Site Cache' ); to wp-config.php
  2. Clear cache and view some pages
  3. Check error log

Expected behavior
Here, we should check if WP_ROCKET_PLUGIN_NAME is already defined and only define it if not. Something like the following:

if ( ! defined( 'WP_ROCKET_PLUGIN_NAME' ) ) {
  define( 'WP_ROCKET_PLUGIN_NAME', 'WP Rocket' );
}

Additional context
Ticket: https://secure.helpscout.net/conversation/2789608151/530064

@wordpressfan
Copy link
Contributor

Thanks @joejoe04

May I ask, what is the reason behind having our constant inside wp-config.php?

From my point of view, I think those constants are forming the base functionality of the plugin so changing them will change the core functionality, and showing a warning is a good thing :)

It's a @wp-media/product call but I can't think of this one as an issue.

@joejoe04
Copy link
Author

@wordpressfan

I'm not sure what decisions were made about it previously, but it's currently in our documentation for white labeling WP Rocket in the WP Admin.

You're right, product can make the call.

If we're not going to support doing this, then we would need to also remove it from the doc.

@wordpressfan
Copy link
Contributor

Thanks @joejoe04
I wasn't aware that we have something like that in our docs :)
In this case, you are correct.

@joejoe04
Copy link
Author

Well, maybe not. You would know better than I if allowing that constant to be changed might lead to unexpected bad outcomes. If so, then maybe we shouldn't allow it to be changed or have it in the doc. What do you think?

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