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

GH-333: Fatal Error on Empty Redis Port Setting in Nginx Helper Plugin [Master] #335

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions admin/partials/nginx-helper-general-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,24 @@
$nginx_helper_admin->nginx_helper_default_settings()
);

$site_options = get_site_option( 'rt_wp_nginx_helper_options', array() );
$site_options = get_site_option( 'rt_wp_nginx_helper_options', array() );

// Uncheck checkbox fields whose default value is `1` but user has unchecked.
foreach ( $nginx_helper_admin->nginx_helper_default_settings() as $default_setting_field => $default_setting_value ) {
foreach ( $nginx_helper_admin->nginx_helper_default_settings() as $default_setting_field => $default_setting_value ) {

if ( 1 === $default_setting_value && isset( $site_options[ $default_setting_field ] ) && empty( $all_inputs[ $default_setting_field ] ) ) {
// Uncheck checkbox fields whose default value is `1` but user has unchecked.
if ( 1 === $default_setting_value && isset( $site_options[ $default_setting_field ] ) && empty( $all_inputs[ $default_setting_field ] ) ) {

$nginx_settings[ $default_setting_field ] = 0;
$nginx_settings[ $default_setting_field ] = 0;

}
}
}

// Populate the setting field with default value when it is empty.
if ( '' === $nginx_settings[ $default_setting_field ] ) {

$nginx_settings[ $default_setting_field ] = $default_setting_value;

}
}

if ( ( ! is_numeric( $nginx_settings['log_filesize'] ) ) || ( empty( $nginx_settings['log_filesize'] ) ) ) {
$error_log_filesize = __( 'Log file size must be a number.', 'nginx-helper' );
Expand Down
Loading