Quantcast
Channel: BulletProof Security Forum » All Posts
Viewing all articles
Browse latest Browse all 12461

Reply To: Error while sending QUERY packet. wp-db.php on line 1803

$
0
0

I posted this testing code here:  https://wordpress.org/support/topic/warning-error-while-sending-query-packet-pid82827?replies=13#post-8457498 because Mika is updating that particular thread.

/*
Notes:
execute the function twice to see if the variable values are changed or not. 
I did not bother with creating additional foreach queries for before and after.
If you exceed either the minimum or maximum values the Min|Max value will be used instead of your value.

integer is in bytes: 1024 = 1KB | 1073741824 = 1GB

max_allowed_packet
Permitted Values Type integer
Default	4194304
Min Value 1024
Max Value 1073741824

integer is in seconds: 28800 = 480 minutes | 31536000 = 525600 minutes = 8760 hours
wait_timeout
Permitted Values (Windows) Type integer
Default	28800
Min Value 1
Max Value 2147483

Permitted Values (Other) Type integer
Default	28800
Min Value 1
Max Value 31536000
*/

function buckwheat_says_make_mo_bigger_max_allowed_packet_n_wait_timeout() {
global $wpdb; 
 
	$max_allowed_packet = 'max_allowed_packet';
	$wait_timeout = 'wait_timeout';
	$result = $wpdb->get_results( $wpdb->prepare( "SHOW SESSION VARIABLES WHERE (Variable_name = %s) OR (Variable_name = %s)", $max_allowed_packet, $wait_timeout ) );

	echo '<div class="update-nag">'; 
	echo '<strong>Execute the function twice to see if the values change or not</strong><br>'; 
 
	foreach ( $result as $data ) {

		echo '<strong>'.$data->Variable_name.': </strong>'. $data->Value.'</strong><br>'; 
 
		if ( $data->Variable_name == 'max_allowed_packet' ) {

		//$map_value = '4194304'; // default value
		$map_value = '1073741824'; // max value
		$map_results = $wpdb->query( $wpdb->prepare( "SET GLOBAL max_allowed_packet = %d;", $map_value ) );
		} 
 
		if ( $data->Variable_name == 'wait_timeout' ) {

		//$wt_value = '28800'; // default value
		//$wt_value = '2147483'; // max value Windows 
		$wt_value = '31536000'; // max value other
		$wpdb->query( $wpdb->prepare( "SET GLOBAL wait_timeout = %d;", $wt_value ) );
		} 
	}
 
	echo '</div>';
}

buckwheat_says_make_mo_bigger_max_allowed_packet_n_wait_timeout();

Viewing all articles
Browse latest Browse all 12461

Trending Articles