Support » Fixing WordPress » Customizer Changes get error: Looks like something’s gone wrong. Wait a couple..

  • ok so in the “additional CSS’ tab of the customer, every single time I press publish, the customizer DOES save my code, but it also gives an error:

    Looks like something’s gone wrong. Wait a couple seconds, and then try again.

    is there something wrong with my installation of WordPress or something? I am on 5.1.2 and it is installed on SiteGround.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Moderator bcworkz

    (@bcworkz)

    The message means that WP did not get the JSON response it was expecting, so it could not confirm the update was successful even if it was. I strongly suspect this is due to something on SiteGround’s end and that there is nothing wrong with your WP installation.

    You can do a test with your browser’s network developer tool. Edit some additional CSS, or add something meaningless. IOW, make any sort of change. Clear the network tool’s display, then click publish. A POST request should show up in the tool. Click the entry in the tool and see what the response is. If there is a JSON response including {"success": true, maybe there is a problem with your installation. If not, it’s on SiteGround’s end.

    hmm,
    the network pane shows 2 requests firing after I press ‘Publish’. Both requests are POST requests and both originate from admin-ajax.php. One has success:true in the JSON and the other has success:false.

    Moderator bcworkz

    (@bcworkz)

    That’s curious. I’m guessing your theme or a plugin is not interfacing with the customizer correctly, which results in a second invalid request. It sounds like the first request is proper. The improper second one is the cause of the gone wrong message. If not for that, you would have seen the Publish button change to grayed out Published as expected.

    Try installing and activating the health-check plugin. Enter troubleshooting mode. Saving CSS should work OK this way. Use the troubleshooting admin bar item to restore your theme, then your plugins, each one by one, testing after each. When you get the double POST again, the last activated module is the culprit. Don’t forget to cancel troubleshooting mode afterwards.

    You may see from time to time a heartbeat request that comes back in part {"wp-auth-check":true, you may ignore these.

    I installed that plugin, entered troubleshoot mode, disabled all plugins and changed themes to twentysixteen.

    When I tried to publish additional css with the customizer I got the error, “Unable to save due to 1 invalid setting.” but there was nothing to click or any way to see what that invalid setting is. How do I check what the invalid setting is?

    Moderator bcworkz

    (@bcworkz)

    It’s not very straight forward to find out. You would need to hack into the core method WP_Customize_Manager::validate_setting_values() and get it to error_log() settings whose $validity has been assigned a WP_Error object.

    Pertinent source code: https://developer.wordpress.org/reference/classes/wp_customize_manager/validate_setting_values/#source

    It’s normally ill advised to alter core code, but for temporary changes for investigative purposes it’s OK.

    The code on the page you linked to and the code in that file are very different.

    Below is what the current code looks like:

    	/**
    	 * Print JavaScript settings for preview frame.
    	 *
    	 * @since 3.4.0
    	 */
    	public function customize_preview_settings() {
    		$post_values                 = $this->unsanitized_post_values( array( 'exclude_changeset' => true ) );
    		$setting_validities          = $this->validate_setting_values( $post_values );
    		$exported_setting_validities = array_map( array( $this, 'prepare_setting_validity_for_js' ), $setting_validities );
    
    		// Note that the REQUEST_URI is not passed into home_url() since this breaks subdirectory installations.
    		$self_url           = empty( $_SERVER['REQUEST_URI'] ) ? home_url( '/' ) : esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) );
    		$state_query_params = array(
    			'customize_theme',
    			'customize_changeset_uuid',
    			'customize_messenger_channel',
    		);
    		$self_url           = remove_query_arg( $state_query_params, $self_url );
    
    		$allowed_urls  = $this->get_allowed_urls();
    		$allowed_hosts = array();
    		foreach ( $allowed_urls as $allowed_url ) {
    			$parsed = wp_parse_url( $allowed_url );
    			if ( empty( $parsed['host'] ) ) {
    				continue;
    			}
    			$host = $parsed['host'];
    			if ( ! empty( $parsed['port'] ) ) {
    				$host .= ':' . $parsed['port'];
    			}
    			$allowed_hosts[] = $host;
    		}
    
    		$switched_locale = switch_to_locale( get_user_locale() );
    		$l10n            = array(
    			'shiftClickToEdit'  => __( 'Shift-click to edit this element.' ),
    			'linkUnpreviewable' => __( 'This link is not live-previewable.' ),
    			'formUnpreviewable' => __( 'This form is not live-previewable.' ),
    		);
    		if ( $switched_locale ) {
    			restore_previous_locale();
    		}
    
    		$settings = array(
    			'changeset'         => array(
    				'uuid'      => $this->changeset_uuid(),
    				'autosaved' => $this->autosaved(),
    			),
    			'timeouts'          => array(
    				'selectiveRefresh' => 250,
    				'keepAliveSend'    => 1000,
    			),
    			'theme'             => array(
    				'stylesheet' => $this->get_stylesheet(),
    				'active'     => $this->is_theme_active(),
    			),
    			'url'               => array(
    				'self'          => $self_url,
    				'allowed'       => array_map( 'esc_url_raw', $this->get_allowed_urls() ),
    				'allowedHosts'  => array_unique( $allowed_hosts ),
    				'isCrossDomain' => $this->is_cross_domain(),
    			),
    			'channel'           => $this->messenger_channel,
    			'activePanels'      => array(),
    			'activeSections'    => array(),
    			'activeControls'    => array(),
    			'settingValidities' => $exported_setting_validities,
    			'nonce'             => current_user_can( 'customize' ) ? $this->get_nonces() : array(),
    			'l10n'              => $l10n,
    			'_dirty'            => array_keys( $post_values ),
    		);
    
    		foreach ( $this->panels as $panel_id => $panel ) {
    			if ( $panel->check_capabilities() ) {
    				$settings['activePanels'][ $panel_id ] = $panel->active();
    				foreach ( $panel->sections as $section_id => $section ) {
    					if ( $section->check_capabilities() ) {
    						$settings['activeSections'][ $section_id ] = $section->active();
    					}
    				}
    			}
    		}
    		foreach ( $this->sections as $id => $section ) {
    			if ( $section->check_capabilities() ) {
    				$settings['activeSections'][ $id ] = $section->active();
    			}
    		}
    		foreach ( $this->controls as $id => $control ) {
    			if ( $control->check_capabilities() ) {
    				$settings['activeControls'][ $id ] = $control->active();
    			}
    		}
    
    		?>
    		<script type="text/javascript">
    			var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>;
    			_wpCustomizeSettings.values = {};
    			(function( v ) {
    				<?php
    				/*
    				 * Serialize settings separately from the initial _wpCustomizeSettings
    				 * serialization in order to avoid a peak memory usage spike.
    				 * @todo We may not even need to export the values at all since the pane syncs them anyway.
    				 */
    				foreach ( $this->settings as $id => $setting ) {
    					if ( $setting->check_capabilities() ) {
    						printf(
    							"v[%s] = %s;\n",
    							wp_json_encode( $id ),
    							wp_json_encode( $setting->js_value() )
    						);
    					}
    				}
    				?>
    			})( _wpCustomizeSettings.values );
    		</script>
    		<?php
    	}

    where do I put a console.log statement? (if that is the right thing to add. I’m not sure what to do here)

    Moderator bcworkz

    (@bcworkz)

    Your code defines the settings, but is not responsible for saving the settings. The method source code I linked to validates the settings before they are saved and triggers the warning you are getting by assigning a WP_Error object to a $validity property.

    This all happens server side, so a console log in your browser will not do. I would insert the following between lines 2321 and 2322 of the linked code:

    if ( is_wp_error( $validity )) {
      $msg = $validity->get_error_messages();
      error_log("Validation error for setting $setting_id: {$msg[0]}");
    }

    Check the server’s error log file to learn what the error message and setting ID is.

    Oh, thanks! I did that and here is the error that prints when I save css:

    [21-Mar-2019 22:14:15 UTC] PHP Notice: Undefined index: purge-log-entries in /home/client7982/public_html/wp-content/plugins/better-wp-security/core/lib/class-itsec-scheduler-cron.php on line 54

    I see better-wp-security in there which is ithemes, and I am guessing disabling iThemes would “fix” this issue but I want to keep using the plugin. Could it be setting something to read-only that it shouldn’t be or some other setting?

    Moderator bcworkz

    (@bcworkz)

    The PHP notice you see is unrelated to validation errors. iThemes shouldn’t be active if you were still in troubleshooting mode. (It gets canceled when you close your browser.) Try invoking troubleshooting mode again, then save additional CSS and see what shows up in the error log.

    Exhibit #1: Error Log

    [22-Mar-2019 22:10:34 UTC] PHP Notice: Undefined index: deactivate in /home/client7982/public_html/wp-content/plugins/captcha-bank/captcha-bank.php on line 1507

    disabling the captcha plugin has no effect. As long as I switch themes away from Blank (I am not censoring the name, that is a custom theme I made) I get no customizer errors.

    Exhibit #2: Notices when Entering Troubleshooting Mode:

    When switching the active theme to Blank, a site failure occurred. Because of this we reverted the theme to the one you used previously.

    When enabling the plugin, wordpress-seo, a site failure occurred. Because of this the change was automatically reverted.

    When enabling the plugin, smart-slider-3, a site failure occurred. Because of this the change was automatically reverted.

    When enabling the plugin, smart-slider-3, a site failure occurred. Because of this the change was automatically reverted.

    When switching the active theme to twentynineteen, a site failure occurred. Because of this we reverted the theme to the one you used previously.

    troubleshooting mode activates the twentynineteen theme, idk why it says there was an error. Anyway, the evidence points to my theme interacting with the customizer as the problem. Since I made this theme to use for clients I want to know how I can fix this. Any ideas on what to fix and how?

    Btw, thanks so much for spending this much time with me, I think we are almost at the end!

    Moderator bcworkz

    (@bcworkz)

    Narrowing the problem source to your custom theme is significant progress. I suggest you review the customizer section of the Theme Handbook and compare its examples with your theme’s code. It’s just a hunch, but it sounds like you are trying to do something that the customizer api already does for you, hence the double save requests.

    hmm, I am not trying to do anything special or extra in the theme with the customizer. As the name suggests the theme is just a blank theme (similar to underscores or something) but with a few styles already added like menus and stuff.) Rather than try to rewrite the whole theme I’m hoping that I can just overwrite a file or two of the theme with those from an existing and working theme. How do I find out which file(s) are causing the issue?

    —-
    wow ok I installed the theme on a local installation and there are a ton of errors… lol maybe my host was suppressing the errors or something idk but I tried to weave together different technologies for this theme a few years ago and now all that technology is out of date and incompatible so I have my work cut out for me, thanks again! (unless you want to help with fixing this cool blank theme that is designed to be easily customizable for clients.. it’s a cool project: https://github.com/brothman01/blank

    whatever you want but I’d love your input!

    Moderator bcworkz

    (@bcworkz)

    It’s normal for hosts to suppress browser display of errors, but not the log file, even though even that is possible. I hope resolving the errors thrown also resolves the double posting, but I’m skeptical. Errors usually don’t cause extra things to happen.

    There’s no easy way to isolate problem code that does not throw errors or warnings. Either comment out blocks of code to see which causes the problem to stop, or methodically trace through the code, outputting debug data checking variable values until you find values or behavior that are not as expected.

    I don’t have time right now to look over your theme. Maybe when time becomes more available I’ll take a look. It’ll give you time to resolve the errors 😉

    oh hey that is completely fine, obviously you have a lot to do! I knew it was a long shot that you would have time to help but I thought it was worth an ask, lol

    thanks again for all your help! Ok, time to sift through all the theme code to find those errors, yay! 🙁

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Customizer Changes get error: Looks like something’s gone wrong. Wait a couple..’ is closed to new replies.