From e1ca76e9772de25ca7f655c60630ea24905a26f6 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Tue, 12 Apr 2022 06:05:45 +0000 Subject: [PATCH] Options: Show error when updating all options exceeds `max_input_vars`. On sites with a large number of options, the number of inputs when saving all options via the /wp-admin/options.php page may exceed PHP's `max_input_vars` setting, this will prevent saving. An error is now shown if this is the case. Props ishitaka, jorbin, maguijo, pento, sergeybiryukov. Fixes #45438. git-svn-id: https://develop.svn.wordpress.org/trunk@53151 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/options.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/options.php b/src/wp-admin/options.php index 84ac775fd43d8..d63b10eb4fd52 100644 --- a/src/wp-admin/options.php +++ b/src/wp-admin/options.php @@ -255,7 +255,7 @@ if ( is_multisite() && ! current_user_can( 'manage_network_options' ) ) { wp_die( __( 'Sorry, you are not allowed to modify unregistered settings for this site.' ) ); } - $options = explode( ',', wp_unslash( $_POST['page_options'] ) ); + $options = isset( $_POST['page_options'] ) ? explode( ',', wp_unslash( $_POST['page_options'] ) ) : null; } else { $options = $allowed_options[ $option_page ]; } @@ -332,6 +332,8 @@ if ( $user_language_old !== $user_language_new ) { load_default_textdomain( $user_language_new ); } + } else { + add_settings_error( 'general', 'settings_updated', __( 'Settings save failed.' ), 'error' ); } /*