diff options
| author | Michael Foster <savetheinternet@tinyboard.org> | 2013-07-16 01:21:06 -0400 |
|---|---|---|
| committer | Michael Foster <savetheinternet@tinyboard.org> | 2013-07-16 01:21:06 -0400 |
| commit | 77e4d926d9992dd56e1ab3c3af29ffd4bea92b59 (patch) | |
| tree | 4f9382eefc20208b485a15e4f37fb46310a0f295 /inc | |
| parent | 34dc31c50e89b38e9489826661edb3f0fffd23ea (diff) | |
Add "write" (files written to) to debug section
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/functions.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/inc/functions.php b/inc/functions.php index 70848468..67019e0a 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -78,7 +78,7 @@ function loadConfig() { if ($config['debug']) { if (!isset($debug)) { - $debug = array('sql' => array(), 'purge' => array(), 'cached' => array()); + $debug = array('sql' => array(), 'purge' => array(), 'cached' => array(), 'write' => array()); $debug['start'] = microtime(true); } } @@ -392,7 +392,7 @@ function purge($uri) { } function file_write($path, $data, $simple = false, $skip_purge = false) { - global $config; + global $config, $debug; if (preg_match('/^remote:\/\/(.+)\:(.+)$/', $path, $m)) { if (isset($config['remote'][$m[1]])) { @@ -419,7 +419,7 @@ function file_write($path, $data, $simple = false, $skip_purge = false) { error('Unable to truncate file: ' . $path); // Write data - if (fwrite($fp, $data) === false) + if (($bytes = fwrite($fp, $data)) === false) error('Unable to write to file: ' . $path); // Unlock @@ -445,6 +445,10 @@ function file_write($path, $data, $simple = false, $skip_purge = false) { purge($path); } + if ($config['debug']) { + $debug['write'][] = $path . ': ' . $bytes . ' bytes'; + } + event('write', $path); } |
