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

WPR Settings page fatal error when debug file is so large even though debug mode is disabled #6581

Open
wordpressfan opened this issue Apr 23, 2024 · 0 comments
Labels
priority: medium Issues which are important, but no one will go out of business. severity: moderate Feature isn't working as expected but has work around to get same value type: bug Indicates an unexpected problem or unintended behavior

Comments

@wordpressfan
Copy link
Contributor

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version Yes
  • Used the search feature to ensure that the bug hasn’t been reported before Yes

Describe the bug
When we leave our debug mode enabled for some time, we find that the file grows rapidly and in some cases it exceeds 500MB without a limit.
We expect when we disable this debug mode, that this large size of the log file won't affect the site at all, but I found that we load the file in our Settings page (exactly in tools section) and this is loaded even when we disable the debug mode.

In a customer's site, this led to full memory consumption.

The code is here:

if ( rocket_direct_filesystem()->exists( Logger::get_log_file_path() ) ) {
$rocket_stats = Logger::get_log_file_stats();
if ( ! is_wp_error( $rocket_stats ) ) {
// translators: %1$s = formatted file size, %2$s = formatted number of entries (don't use %2$d).
$rocket_log_description .= sprintf( esc_html__( 'Files size: %1$s. Number of entries: %2$s.', 'rocket' ), '<strong>' . esc_html( $rocket_stats['bytes'] ) . '</strong>', '<strong>' . esc_html( $rocket_stats['entries'] ) . '</strong>' );
// translators: %1$s = opening <a> tag, %2$s = closing </a> tag.
$rocket_log_description .= '<br/>' . sprintf( esc_html__( '%1$sDownload the file%2$s.', 'rocket' ), '<a href="' . esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=rocket_download_debug_file' ), 'download_debug_file' ) ) . '">', '</a>' );
// translators: %1$s = opening <a> tag, %2$s = closing </a> tag.
$rocket_log_description .= ' - ' . sprintf( esc_html__( '%1$sDelete the file%2$s.', 'rocket' ), '<a href="' . esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=rocket_delete_debug_file' ), 'delete_debug_file' ) ) . '">', '</a>' );
}
}

and this code is only used in a commented area here:

<!-- Temporary hide the option. The logger can still be activated by adding the following to the wp-config.php file: define( 'WP_ROCKET_DEBUG', true );
<div class="wpr-tools">
<div class="wpr-tools-col wpr-radio">
<div class="wpr-title3 wpr-tools-label">
<input id="debug_enabled" name="wp_rocket_settings[debug_enabled]" value="1"<?php checked( true, Logger::debug_enabled() ); ?> type="checkbox">
<label for="debug_enabled">
<span data-l10n-active="On" data-l10n-inactive="Off" class="wpr-radio-ui"></span>
<?php esc_html_e( 'Debug mode', 'rocket' ); ?>
</label>
</div>
<div class="wpr-field-description">
<?php esc_html_e( 'Create a debug log file.', 'rocket' ); ?>
</div>
</div>
<div class="wpr-tools-col">
<?php echo $rocket_log_description; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Dynamic content is properly escaped in the view. ?>
</div>
</div>
-->

To Reproduce
Steps to reproduce the behavior:

  1. Enable our debug mode by setting the constant WP_ROCKET_DEBUG to true in wp-config.php
  2. Enable the preload and wait some time till preload finishes and the log file is large.
  3. Keep doing point 2 till the log file exceeds the memory limit in WP (or u can fill the file manually if u don't want to wait)
  4. Visit the settings page
  5. You will see a fatal error because of full memory consumption.

Expected behavior
We should remove this code completely because it's not used anymore and is affecting the memory consumption.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Acceptance Criteria (for WP Media team use only)
Clear instructions for developers, to be added before the grooming

@wordpressfan wordpressfan added the type: bug Indicates an unexpected problem or unintended behavior label Apr 23, 2024
@piotrbak piotrbak added priority: medium Issues which are important, but no one will go out of business. severity: moderate Feature isn't working as expected but has work around to get same value labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium Issues which are important, but no one will go out of business. severity: moderate Feature isn't working as expected but has work around to get same value type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants