[Plugin: wp pear debug] Useful information
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
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.
- The topic ‘[Plugin: wp pear debug] Useful information’ is closed to new replies.