Skip to:
Content
Pages
Categories
Search
Top
Bottom

Error: A variable mismatch has been detected.


  • Chuckie
    Participant

    @ajtruckle

    I raised this before. But it is frustrating me today.

    I have a topic with a single reply. I wanted to split the reply into it’s own topic. Then I was going to move the new topic to another forum.

    I can start the split process but when I tell it to perform the split I get this error:

    “A variable mismatch has been detected.”

    I have absolutely no idea what to do to be able to split a topic.

Viewing 22 replies - 1 through 22 (of 22 total)

  • Robin W
    Moderator

    @robin-w

    when you last reported it, I said
    ‘ok, I can only suggest that you revert to the standard tests
    Themes
    As a test switch to a default theme such as twentyfifteen, and see if this fixes.
    Plugins
    If that doesnโ€™t work, also deactivate all plugins apart from bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.
    Then come back@

    you did not respond to that, so can’t really help further if you don’t do the tests ๐Ÿ™‚


    Chuckie
    Participant

    @ajtruckle

    Hi @robin-w

    The offending plugin is “Theme My Login”.


    Robin W
    Moderator

    @robin-w

    ok, so you’ll contact them next I guess ๐Ÿ™‚


    Chuckie
    Participant

    @ajtruckle


    Chuckie
    Participant

    @ajtruckle

    At least I was able to do the split and then move the topic by temporarily deactivating the plugin.

    Side note @robin-w – I raised a issue on your forum about a bbp style pack critical error I received today.


    Robin W
    Moderator

    @robin-w

    bug found and fixed in 4.4.5


    Chuckie
    Participant

    @ajtruckle

    Thanks!


    Chuckie
    Participant

    @ajtruckle

    I had this reply @robin-w:

    I’d suggest filing a bug report with bbPress.

    The issue is that TML registers ‘action’ as a public query variable with WP. WP has a check in WP::parse_request(), which ensures that all GET and POST values of public query variables match. If they don’t, it dies with the error message you are seeing.

    For whatever reason, bbPress uses a different action key depending on GET/POST context. In this specific instance, the GET value of ‘action’ is ‘split’. However, the POST value (set via hidden field in the form) is ‘bbp-split-topic’. This difference is causing the condition described above.

    In code:

    $_GET['action'] = 'split';
    $_POST['action'] = 'bbp-split-topic';
    
    if ( isset( $_GET[ 'action' ] ) && isset( $_POST[ 'action' ] ) && $_GET[ 'action' ] !== $_POST[ 'action ] ) {
    	wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 ); }

    Robin W
    Moderator

    @robin-w

    that’s a great response, let me look at it later


    Chuckie
    Participant

    @ajtruckle

    Thank you.


    Robin W
    Moderator

    @robin-w

    can you try this in your child theme function file or snippets

    function rew_get_topic_split_link( $retval, $r, $args ) {
    
    		// Parse arguments against default values
    		$r = bbp_parse_args( $args, array(
    			'id'          => 0,
    			'link_before' => '',
    			'link_after'  => '',
    			'split_text'  => esc_html__( 'Split',                           'bbpress' ),
    			'split_title' => esc_attr__( 'Split the topic from this reply', 'bbpress' )
    		), 'get_topic_split_link' );
    
    		// Get IDs
    		$reply_id = bbp_get_reply_id( $r['id'] );
    		$topic_id = bbp_get_reply_topic_id( $reply_id );
    
    		// Bail if no reply/topic ID, or user cannot moderate
    		if ( empty( $reply_id ) || empty( $topic_id ) || ! current_user_can( 'moderate', $topic_id ) ) {
    			return;
    		}
    
    		$uri = add_query_arg( array(
    			'action'   => 'bbp-split-topic',
    			'reply_id' => $reply_id
    		), bbp_get_topic_edit_url( $topic_id ) );
    
    		$retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" title="' . $r['split_title'] . '" class="bbp-topic-split-link">' . $r['split_text'] . '</a>' . $r['link_after'];
    
    		// Filter & return
    		return apply_filters( 'rew_get_topic_split_link', $retval, $r, $args );
    	}
    
    add_filter ('bbp_get_topic_split_link', 'rew_get_topic_split_link' , 10 , 3) ;
    
    function rew_is_topic_split() {
    
    	// Assume false
    	$retval = false;
    
    	// Check topic edit and GET params
    	if ( bbp_is_topic_edit() && ! empty( $_GET['action'] ) && ( 'bbp-split-topic' === $_GET['action'] ) ) {
    		$retval = true;
    	}
    
    	// Filter & return
    	return (bool) apply_filters( 'rew_is_topic_split', $retval );
    }
    
    add_filter ('bbp_is_topic_split' , 'rew_is_topic_split' ) ;

    Chuckie
    Participant

    @ajtruckle

    That works great!

    Thank you.


    Robin W
    Moderator

    @robin-w

    Took a while to work out where the chnages were needed ๐Ÿ™‚

    I’ve raised a ticket – and I’ll add it to style pack bugs shortly – thanks for testing that it worked for you also !!


    Chuckie
    Participant

    @ajtruckle

    I appreciate you taking the time with that.


    Chuckie
    Participant

    @ajtruckle

    Hi @robin-w

    RThanks for your latest bbp updates. I have activated your new bug fix check box and removed my code from functions.php and I can still split topics. Woo hoo!


    Robin W
    Moderator

    @robin-w

    great – glad it is all working !!


    zactix
    Participant

    @zactix

    Hi there

    I’m still having this issue unfortunately.

    I contacted ThemeMyLogin support and they sent me to this link:
    https://wordpress.org/support/topic/error-a-variable-mismatch-has-been-detected-2/#new-topic-0

    Adding the code snippet above isn’t resolving the issue.

    Can you please advise.

    Thanks

    Thanks


    Robin W
    Moderator

    @robin-w

    can you confirm that the issue you are having is this exactly

    I have a topic with a reply. I wanted to split the reply into itโ€™s own topic. Then I was going to move the new topic to another forum.

    I can start the split process but when I tell it to perform the split I get this error:

    โ€œA variable mismatch has been detected.โ€


    zactix
    Participant

    @zactix

    Apologies for the delayed response.

    Yes that is the exact issue I’m having.


    Robin W
    Moderator

    @robin-w

    ok, can you remove that code, and install this plugin :

    bbp style pack

    once activated go to

    dashboard>settings>bbp style pack>bug fixes and you’ll see a tick box

    Fix ‘A variable Mismatch has been detected’ click and save


    zactix
    Participant

    @zactix

    Thank you – that did the trick.


    Robin W
    Moderator

    @robin-w

    great – glad you are fixed

Viewing 22 replies - 1 through 22 (of 22 total)
  • You must be logged in to reply to this topic.
Skip to toolbar