Error: A variable mismatch has been detected.
-
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.
-
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 ๐
Hi @robin-w
The offending plugin is “Theme My Login”.
ok, so you’ll contact them next I guess ๐
I have put an issue here:
https://wordpress.org/support/topic/error-a-variable-mismatch-has-been-detected-2/#new-topic-0
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.
bug found and fixed in 4.4.5
Thanks!
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 ); }
that’s a great response, let me look at it later
Thank you.
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' ) ;
That works great!
Thank you.
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 !!
I appreciate you taking the time with that.
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!
great – glad it is all working !!
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-0Adding the code snippet above isn’t resolving the issue.
Can you please advise.
Thanks
Thanks
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.โ
Apologies for the delayed response.
Yes that is the exact issue I’m having.
ok, can you remove that code, and install this plugin :
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
Thank you – that did the trick.
great – glad you are fixed
- You must be logged in to reply to this topic.