WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: wp pear debug] Useful information (6 posts)

  1. silasco
    Member
    Posted 4 years ago #

    I have often found myself trying new things and having to endure much frustration because of the absence of good tutorials for noobies. Therefore, I have decided to create a few posts demonstrating the use of the wp-pear-debug plugin while explaining a few concepts.

    The most obvious gotcha about this plugin is that it will not work with php5. This means that all you guys still using wordpress on php4 are out of luck. So please don't be hasty to report the plugin as broken as this may be your issue.

    Another issue is, despite the fact that it is a debugger, the plugin still relies on the successful interpretation of php code. Therefore, making a call to the debugger to add debug information may not always be successful. Here is an example to illustrate.

    //Block of code with syntax error
    $foo = array('bar';
    
    //Call to wp-pear-debug
    wp_pear_debug::dump($foo);

    The above call to the wp-pear-debug library will not be executed because of the syntax error in the previous block of code.

    Another thing to note is that sql queries not made using the wpdb class will not appear in the list of sql queries displayed by the debugger. In order to add custom queries to the debugger, you must use the following in your code:

    //This will appear in debug query listing
    $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post));
    
    //Here is how to add queries not making use of $wpdb
    //define query
    $sql = "select * from mycustomtable";
    //add query to debugger
    wp_pear_debug::query($sql);
    //execute query
    $rs = mysql_query($sql);

    Despite the fact that a query is executed using the wpdb class it may still not appear in the list of executed queries. This really depends on the point in the script the sql query is executed. The plugin is initialized as soon as plugins are loaded but some queries are executed before this and therefore may not be recorded. Here is how you handle this:
    Define the following in your wp-config.php

    define('SAVEQUERIES',true);

    Still after all this there is no guarantee all the queries will appear in the debugger. This is again because of the point in the script where the query is being executed. The debugger interface is being rendered at the wp_footer hook. Therefore the saved queries are gathered and added to the debugger instance right before this. Any queries executed after this point will not be included.

    Despite the above mentioned constrains, I still hope this plugin will be as useful to others as it is to me.

    http://wordpress.org/extend/plugins/wp-pear-debug/

  2. Roland Fauster
    Member
    Posted 4 years ago #

    Hi

    I would love to use this Plugin on WPMU but I can not enable Debuggin with it on 2.8.6. MU Installation (Fresh and Clean tried)..

    I can activate without problem but after that when I try enabling in the settings I get an error message!

    Could you look into that maybe!?

    Cheers

  3. silasco
    Member
    Posted 4 years ago #

    Unfortunately the plugin will activate fine in MU but the method used to save the settings seems to not be compatible. However, I can look into it and possibly create a branch for wordpress mu.

  4. silasco
    Member
    Posted 4 years ago #

    It just hit me that if you were to submit to a page which subsequently redirects then your debug information will not display on the final destination. There may be a way to display debug information from the previous request by storing the information temporarily in the session. I will probably add in a few functions to make this possible in the 1.5 release if redirects are a real issue for people attempting to debug pages.

    Off the top of my head, the present debug interface may not be suitable for this and therefore may require some enhancements. The possibility exists for a history tab which allows you to view debug information for previous requests.

    The above interface change is a perfect opportunity for me to attempt to populate the debug bar using ajax. This would mean that all debug information would be placed in a history stack that can be readily accessed from the client side. Also, it should then alleviate the issue of missing queries and debug information which occur after the wp_footer hook which renders the debugger.

  5. Jens Wedin
    Member
    Posted 4 years ago #

    Thanks for the plugin!

    Just a note. You need the

    <?php wp_footer(); ?>

    In the footer.php for this plugin to work.

  6. silasco
    Member
    Posted 4 years ago #

    Thanks for the plugin!

    Just a note. You need the

    <?php wp_footer(); ?>

    In the footer.php for this plugin to work.

    Do people really have templates that do not include wp_footer() ? I may have to add in an option for the admin to add in the name of a custom render hook.

Topic Closed

This topic has been closed to new replies.

About this Topic