• I’m not sure if this is a kint problem or a Query Monitor problem so I’m submitting to both:

    For a test I have created a simple plugin that just stores an incrementing variable in $_SESSION and dumps the value before and after incrementing. Here’s the simple code:

    function myStartSession() {
    	
    	if(!session_id()) {
    		session_start();
    	}
    
    	d($_SESSION['iteration']);
    	$_SESSION['iteration'] += 1;
    	d($_SESSION['iteration']);
    }
    add_action('init', 'myStartSession');

    The expected behavior is that on every page refresh the starting value of “iteration” will be the previous end value of “iteration”. e.g.

    val = 1
    val = 2
    refresh page
    val = 2
    val = 3
    refresh page
    val = 3
    val = 4

    When I have kint + debug bar active it all works as expected. But when I have kint + query monitor active then WP behaves like it runs the functions twice, with one of the runs being kinda invisible (no output). So instead of the above expected result I get something like:

    val = 1
    val = 2
    refresh page
    val = 3
    val = 4
    refresh page
    val = 5
    val = 6

    I discovered this behavior because another plugin that I use writes an activity log to the db. With kint + query monitor active I always get duplicate entries into the database. But without that combination everything is fine.

    Here’s a screencast that walks through what I’m seeing:

  • The topic ‘kint with query monitor causes functions to run twice’ is closed to new replies.