Skip to content

Commit

Permalink
Tracing earlier and later
Browse files Browse the repository at this point in the history
  • Loading branch information
makss committed Jul 11, 2015
1 parent 692e938 commit f7af455
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
7 changes: 5 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,19 @@

include txpath.'/lib/constants.php';
include txpath.'/lib/txplib_misc.php';
trace_log(TEXTPATTERN_TRACE_START);

if (!isset($txpcfg['table_prefix'])) {
txp_status_header('503 Service Unavailable');
exit('config.php is missing or corrupt. To install Textpattern, visit <a href="./textpattern/setup/">textpattern/setup/</a>');
}

// Custom caches, et cetera?
if (isset($txpcfg['pre_publish_script'])) {
// Custom caches, etc?
if (!empty($txpcfg['pre_publish_script'])) {
trace_add("[Pre Publish Script: '{$txpcfg['pre_publish_script']}']");
require $txpcfg['pre_publish_script'];
}

include txpath.'/publish.php';
textpattern();
trace_log(TEXTPATTERN_TRACE_DISPLAY);
1 change: 1 addition & 0 deletions textpattern/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
include txpath.'/lib/txplib_theme.php';
include txpath.'/lib/txplib_validator.php';
include txpath.'/lib/admin_config.php';
trace_add("[PHP Include end]");

set_error_handler('adminErrorHandler', error_reporting());

Expand Down
2 changes: 2 additions & 0 deletions textpattern/lib/txplib_misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -5643,13 +5643,15 @@ function trace_log($flags = TEXTPATTERN_TRACE_RESULT)
$microstart = getmicrotime();
$production_status = 'debug';
$txptrace = array();
trace_add("[Trace Start]");
return;
}

$microdiff = (getmicrotime() - $microstart);
$memory_peak = is_callable('memory_get_peak_usage') ? ceil(memory_get_peak_usage(true) / 1024) : '-';

if ($production_status !== 'live' && $flags & TEXTPATTERN_TRACE_DISPLAY) {
trace_add("[Trace End]");
echo n,comment('Runtime: '.substr($microdiff, 0, 6));
echo n,comment('Query time: '.sprintf('%02.6f', $qtime));
echo n,comment('Queries: '.$qcount);
Expand Down
6 changes: 1 addition & 5 deletions textpattern/publish.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
include_once txpath.'/lib/constants.php';
include_once txpath.'/lib/txplib_publish.php';
include_once txpath.'/lib/txplib_misc.php';

trace_log(TEXTPATTERN_TRACE_START);

include_once txpath.'/lib/txplib_db.php';
include_once txpath.'/lib/txplib_html.php';
include_once txpath.'/lib/txplib_forms.php';
Expand All @@ -53,6 +50,7 @@
include_once txpath.'/publish/taghandlers.php';
include_once txpath.'/publish/log.php';
include_once txpath.'/publish/comment.php';
trace_add("[PHP Include end]");

set_error_handler('publicErrorHandler', error_reporting());

Expand Down Expand Up @@ -617,8 +615,6 @@ function textpattern()
header("Content-type: text/html; charset=utf-8");
echo $html;

trace_log(TEXTPATTERN_TRACE_DISPLAY);

callback_event('textpattern_end');
}

Expand Down

0 comments on commit f7af455

Please sign in to comment.