Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Db_Abstract E_STRICT errors (issue #41) #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions xhprof_lib/display/xhprof.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,15 +802,14 @@ function print_flat_data($url_params, $title, $flat_data, $sort, $run1, $run2, $
http_build_query(xhprof_array_set($url_params,
'all', 1)));
}

//Find top $n requests
$data_copy = $flat_data;
$data_copy = _aggregateCalls($data_copy, null, $run2);
usort($data_copy, 'sortWT');

$iterations = 0;
$colors = array('#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE', '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92', '#EAFEBB', '#FEB4B1', '#2B6979', '#E9D6FE', '#FECDA3', '#FED980');
foreach($data_copy as $datapoint)

foreach($data_copy as $index => $datapoint)
{
if (++$iterations > 14)
{
Expand All @@ -820,7 +819,8 @@ function print_flat_data($url_params, $title, $flat_data, $sort, $run1, $run2, $
$function_color[$datapoint['fn']] = $colors[$iterations-1];
}
}



include( "../xhprof_lib/templates/profChart.phtml");
include( "../xhprof_lib/templates/profTable.phtml");

Expand Down Expand Up @@ -868,12 +868,17 @@ function full_report($url_params, $symbol_tab, $sort, $run1, $run2, $links) {

//echo xhprof_render_actions($links);


$flat_data = array();
foreach ($symbol_tab as $symbol => $info) {
$tmp = $info;
$tmp["fn"] = $symbol;

$aggr = _aggregateCalls(array($tmp));
$aggrKeys = array_keys($aggr);
if (isset($aggrKeys[0]) && !is_numeric($aggrKeys[0])) {
$tmp['group'] = $aggr[$aggrKeys[0]]['fn'];
}

$flat_data[] = $tmp;
}
usort($flat_data, 'sort_cbk');
Expand All @@ -887,7 +892,7 @@ function full_report($url_params, $symbol_tab, $sort, $run1, $run2, $links) {
$all = false;
$limit = 100; // display only limited number of rows
}

$desc = str_replace("<br />", " ", $descriptions[$sort_col]);

if ($diff_mode) {
Expand All @@ -906,6 +911,7 @@ function full_report($url_params, $symbol_tab, $sort, $run1, $run2, $links) {
$title = "Displaying top $limit functions: Sorted by $desc";
}
}

print_flat_data($url_params, $title, $flat_data, $sort, $run1, $run2, $limit);
}

Expand Down
2 changes: 1 addition & 1 deletion xhprof_lib/templates/profChart.phtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script type="text/javascript">
Highcharts.setOptions({colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE', '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92', '#EAFEBB', '#FEB4B1', '#2B6979', '#E9D6FE', '#FECDA3', '#FED980']});
Highcharts.setOptions({colors: [<?php echo "'".implode("','", $colors)."'" ?>]});
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
Expand Down
16 changes: 9 additions & 7 deletions xhprof_lib/templates/profTable.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@
<?php
foreach($flat_data as $element)
{
$group = '';
if (isset($element['group'])) {
$color = $function_color[$element['group']];
} elseif (isset($function_color[$element['fn']])) {
$color = $function_color[$element['fn']];
} else {
$color = 'inherit';
}
$group = $element['group'];
$color = $function_color[$element['group']];
} elseif (isset($function_color[$element['fn']])) {
$color = $function_color[$element['fn']];
} else {
$color = 'inherit';
}
?>

<tr>
<td style="background-color: <?php echo $color; ?>;"><span style="display: none"><?php echo $color; ?></span>&nbsp;</td>
<td style="background-color: <?php echo $color; ?>;" title="<?php echo $group?>"><span style="display: none"><?php echo $color; ?></span>&nbsp;</td>
<td><a href="index.php?run=<?php echo $run1; ?>&amp;symbol=<?php echo urlencode($element['fn']); ?>"><?php echo htmlentities($element['fn'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td><?php echo $element['ct']; ?></td>
<td><?php echo $element['wt']; ?></td>
Expand Down
12 changes: 2 additions & 10 deletions xhprof_lib/utils/Db/Abstract.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
abstract class Db_Abstract
require_once XHPROF_LIB_ROOT.'/utils/Db/Interface.php';
abstract class Db_Abstract implements Db_Interface
{
protected $config;
public $linkID;
Expand All @@ -9,13 +10,4 @@ public function __construct($config)
$this->config = $config;
}

abstract public function connect();
abstract public function query($sql);
abstract public static function getNextAssoc($resultSet);
abstract public function escape($str);
abstract public function affectedRows();
abstract public static function unixTimestamp($field);
abstract public static function dateSub($days);


}
11 changes: 11 additions & 0 deletions xhprof_lib/utils/Db/Interface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
interface Db_Interface
{
public function connect();
public function query($sql);
public static function getNextAssoc($resultSet);
public function escape($str);
public function affectedRows();
public static function unixTimestamp($field);
public static function dateSub($days);
}