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

Closes #5923: Prevent loading logger class without WP_ROCKET_DEBUG enabled #6028

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

jeawhanlee
Copy link
Contributor

Description

Load logger classes conditionally only when WP_ROCKET_DEBUG is set and true.

Fixes #5923

Type of change

  • Enhancement (non-breaking change which improves an existing functionality)

Is the solution different from the one proposed during the grooming?

Slightly

How Has This Been Tested?

Automated tests

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

@jeawhanlee jeawhanlee added type: enhancement Improvements that slightly enhance existing functionality and are fast to implement module: Logger labels Jul 5, 2023
@jeawhanlee jeawhanlee self-assigned this Jul 5, 2023
@jeawhanlee jeawhanlee requested a review from a team July 5, 2023 15:45
@jeawhanlee jeawhanlee marked this pull request as ready for review July 5, 2023 15:45
@vmanthos vmanthos self-requested a review July 6, 2023 10:20
@vmanthos vmanthos added this to the 3.14.2 milestone Jul 7, 2023
@vmanthos
Copy link
Contributor

vmanthos commented Jul 7, 2023

@jeawhanlee Thank you for the PR.

The following classes aren't loaded 👍 :

  • WP_Rocket\Logger\HTML_Formatter
  • WP_Rocket\Logger\Stream_Handler
  • Monolog\Logger

However, WP_Rocket\Logger\Logger is still loaded.

Checking the code, I see that it's used in the constructor and in other methods of the WP_Rocket\Buffer\Cache class - probably elsewhere as well, and therefore not loading it would cause fatal errors.

@piotrbak

  1. Should we load WP_Rocket\Logger\Logger? If not, further changes will be required to this PR.

  2. Also, the changes from this PR will not be added to the advanced-cache.php when updating to 3.14.2. They will when/if we regenerate the advanced-cache.php file, e.g. if "Separate cache files for mobile devices" is enabled/disabled.

Should we add the logic to regenerate the advanced-cache.php when updating to 3.14.2?

@piotrbak
Copy link
Contributor

piotrbak commented Jul 9, 2023

@Tabrisrp What's your opinion on that?

@Tabrisrp
Copy link
Contributor

  • Not loading the Logger class while require additional changes indeed, to remove the coupling between the logger and the buffer classes (cache and optimization)
  • Since we're doing changes to the advanced-cache file, we should regenerate it on update yes

@piotrbak piotrbak modified the milestones: 3.14.2, 3.15 Jul 13, 2023
@MathieuLamiot
Copy link
Contributor

Hi team,
I'm catching up on this topic, is it correct that:

  • All debug classes except one are not loaded anymore (according to @vmanthos)
  • For this to fully work, advanced-cache file must be updated. The logic has been added by @jeawhanlee but yet to be tested.
  • To tackle the missing class, the work is more complex than anticipated.

If I understood that correctly, then @piotrbak would you be OK with reducing the scope of the original task and accept it without the Logger/Logger class being handled? It would allow to move forward with the current implementation ot be tested by QA, and deliver value quickly.
A new task could be created (and added to an upcoming sprint if the value is interesting) to specifically handle the Logger/Logger class. With the acquired knowledge, a better grooming can be done.

What do you think?

@piotrbak
Copy link
Contributor

@MathieuLamiot Yes, that's acceptable while taking into the consideration complexity. Let's deliver this one and create a low priority issue after the release about the missing class.

@vmanthos
Copy link
Contributor

@piotrbak @MathieuLamiot

I found that even on trunk only the WP_Rocket\Logger\Logger class is loaded when WP_ROCKET_DEBUG is set to false.

When enabling debugging the following classes are additionally loaded:

  • WP_Rocket\Logger\HTML_Formatter
  • WP_Rocket\Logger\Stream_Handler
  • Monolog\Logger

@engahmeds3ed confirmed my findings. 🙏

So, this PR doesn't bring anything new, and the real issue to tackle is to avoid loading WP_Rocket\Logger\Logger unless WP_ROCKET_DEBUG is set to true.

@MathieuLamiot
Copy link
Contributor

Thanks for the deep-dive @vmanthos. Let's block the issue for now and have a talk about it.

@piotrbak piotrbak removed this from the 3.15 milestone Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: Logger type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent loading the Logger classes if WP_ROCKET_DEBUG is not enabled
7 participants