5 years ago, mid-November
Fastest way to understand what a web app is doing
Posted by admin under technology
The fastest way I know of to understand what a web application is doing - is to simply get some logging on the database and webservice calls.
You could print the output to the apache error log, but I like the technique shown below simply because its really easy to use and you get a more insight into what component on the page is causing the database call. Its also quite frightening to see how many database hits are required to create one page.
Let take this blog as an example:
I want to see how wordpress works and hack in a feature to support setting the date an article was posted (backposting feature).
To see result straight away click on this debug url
Full details below:
I use 'grep -r' to find where wordpress database access code is
Its in wp-includes/wp-db.php
vi wp-includes/wp-db.php
at the top of the file add:
function displayQuery( $query) { if ( isset( $_REQUEST['debug_display'] )){ // As Rasmus says "never echo something you received from the user into the page directly" echo "< pre>" . htmlentities($query) . "</pre>;"; } }
and I added the call to displayQuery to the method query($query) as follows
// ================================================================== // Basic Query - see docs for more detail function query($query) {
you can now click on this debug url and see the sql that is used to build this site. The location of this SQL in the page indicates what module on the page it is used for.
