Commit 1c411780 authored by Richard Mansfield's avatar Richard Mansfield

Add performance info file logging in more places.

The perf_to_log() call was missing in several places, such as when serving files from
download.php & thumb.php, redirects, and many ajax scripts not using json_reply().

Change-Id: I64df2d3351320a0767a6fad6525b803aa3980fad
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent f1bd4df8
......@@ -41,10 +41,7 @@ if(!$result) {
$result = array();
}
json_headers();
$data['error'] = false;
$data['data'] = $result;
$data['count'] = ($result) ? count($result) : 0;
echo json_encode($data);
?>
json_reply(false, $data);
......@@ -54,11 +54,10 @@ if (!$data = get_records_sql_array($sql, array($owner, $type))) {
$count = count_records('artefact', 'owner', $owner, 'artefacttype', $type);
echo json_encode(array(
json_reply(false, array(
'data' => $data,
'limit' => $limit,
'offset' => $offset,
'count' => $count,
'type' => $type));
?>
'type' => $type,
));
......@@ -116,6 +116,4 @@ elseif ($jointype == 'invite') {
}
$data['message'] = get_string('userinvited', 'group');
}
json_headers();
echo json_encode($data);
exit;
json_reply(false, $data);
......@@ -120,7 +120,4 @@ $data['data'] = array(
);
$data['error'] = false;
$data['message'] = null;
json_headers();
echo json_encode($data);
exit;
json_reply(false, $data);
......@@ -36,9 +36,4 @@ $result = array();
$USER->set_account_preference('showhomeinfo', $showhomeinfo);
$result['error'] = false;
$result['message'] = false;
json_headers();
echo json_encode($result);
?>
json_reply(false, $result);
......@@ -48,8 +48,4 @@ if (empty($data)) {
}
$json = array('error' => false, 'content' => $data);
echo json_encode($json);
exit;
?>
json_reply(false, $json);
......@@ -64,9 +64,4 @@ foreach ($data['data'] as &$result) {
$result = array('id' => $result['id'], 'name' => $result['name']);
}
json_headers();
$data['error'] = false;
$data['message'] = false;
echo json_encode($data);
?>
json_reply(false, $data);
......@@ -177,6 +177,7 @@ function serve_file($path, $filename, $mimetype, $options=array()) {
header('Content-Length: ' . $filesize);
while (@ob_end_flush()); //flush the buffers - save memory and disable sid rewrite
readfile_chunked($path);
perf_to_log();
exit;
}
......
......@@ -2298,6 +2298,7 @@ function redirect($location='/') {
header('HTTP/1.1 303 See Other');
header('Location:' . $location);
perf_to_log();
exit;
}
......
......@@ -11,5 +11,6 @@
<div>
{$content|clean_html|safe}
</div>
{mahara_performance_info}
</body>
</html>
......@@ -90,8 +90,7 @@ switch ($type) {
header('Cache-Control: max-age=' . $maxage);
header('Pragma: public');
readfile($path);
exit;
readfile_exit($path);
}
}
}
......@@ -119,8 +118,7 @@ switch ($type) {
// below at the other get_config('theme') call!
if ($path = get_dataroot_image_path('artefact/file/profileicons/no_userphoto/' . get_config('theme'), 0, $size)) {
header('Content-type: ' . 'image/png');
readfile($path);
exit;
readfile_exit($path);
}
// If we couldn't find the no user photo picture, we put it into
......@@ -134,17 +132,14 @@ switch ($type) {
// Now we can try and get the image in the correct size
if ($path = get_dataroot_image_path('artefact/file/profileicons/no_userphoto/' . get_config('theme'), 0, $size)) {
header('Content-type: ' . 'image/png');
readfile($path);
exit;
readfile_exit($path);
}
}
// Emergency fallback
header('Content-type: ' . 'image/png');
readfile($THEME->get_path('images/no_userphoto.png'));
exit;
break;
readfile_exit($THEME->get_path('images/no_userphoto.png'));
case 'blocktype':
$bt = param_alpha('bt'); // blocktype
......@@ -161,21 +156,22 @@ switch ($type) {
header('Pragma: public');
$path = get_config('docroot') . $basepath . '/thumb.png';
if (is_readable($path)) {
readfile($path);
exit;
readfile_exit($path);
}
readfile($THEME->get_path('images/no_thumbnail.png'));
break;
readfile_exit($THEME->get_path('images/no_thumbnail.png'));
case 'viewlayout':
header('Content-type: image/png');
$vl = param_integer('vl');
if ($widths = get_field('view_layout', 'widths', 'id', $vl)) {
if ($path = $THEME->get_path('images/vl-' . str_replace(',', '-', $widths) . '.png')) {
readfile($path);
exit;
readfile_exit($path);
}
}
readfile($THEME->get_path('images/no_thumbnail.png'));
break;
readfile_exit($THEME->get_path('images/no_thumbnail.png'));
}
function readfile_exit($path) {
readfile($path);
perf_to_log();
exit;
}
\ No newline at end of file
......@@ -53,9 +53,6 @@ switch ($type) {
break;
}
json_headers();
$data['error'] = false;
$data['message'] = '';
echo json_encode($data);
?>
json_reply(false, $data);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment