pts-core: PHP 8.4 warning fixes and optimizations
This commit is contained in:
@@ -293,7 +293,7 @@ class pts_module_manager
|
||||
}
|
||||
public static function clean_module_list()
|
||||
{
|
||||
array_unique(self::$modules);
|
||||
self::$modules = array_unique(self::$modules);
|
||||
|
||||
foreach(self::$modules as $i => $module)
|
||||
{
|
||||
|
||||
@@ -114,7 +114,7 @@ class pts_graph_lines extends pts_graph_core
|
||||
protected function render_graph_pre_init()
|
||||
{
|
||||
// Do some common work to this object
|
||||
$this->i['identifier_width'] = $this->max_count > 0 ? (($this->i['graph_left_end'] - $this->i['left_start']) / $this->max_count) : 1;
|
||||
$this->i['identifier_width'] = $this->max_count > 0 ? round(($this->i['graph_left_end'] - $this->i['left_start']) / $this->max_count) : 1;
|
||||
|
||||
if(!$this->i['hide_graph_identifiers'])
|
||||
{
|
||||
@@ -159,10 +159,10 @@ class pts_graph_lines extends pts_graph_core
|
||||
else
|
||||
{
|
||||
$max_v = max($v);
|
||||
if(!is_numeric($max_v))
|
||||
/*if(!is_numeric($max_v))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}*/
|
||||
$max_value = max($max_value, $max_v);
|
||||
if($min_value == -1)
|
||||
$min_value = $max_value;
|
||||
@@ -339,7 +339,7 @@ class pts_graph_lines extends pts_graph_core
|
||||
{
|
||||
foreach($data_set as $i => $v)
|
||||
{
|
||||
if($v === NULL || !is_numeric($v))
|
||||
if($v === null) // 2024 XXX dropped: || !is_numeric($v)
|
||||
{
|
||||
unset($data_set[$i]);
|
||||
}
|
||||
@@ -380,7 +380,7 @@ class pts_graph_lines extends pts_graph_core
|
||||
{
|
||||
$value = 0;
|
||||
}
|
||||
else if($value < 0 || !is_numeric($value))
|
||||
else if($value < 0) // XXX 2024 removed: || !is_numeric($value)
|
||||
{
|
||||
// Draw whatever is needed of the line so far, since there is no result here
|
||||
if(!$this->i['on_zero_plot_connect'])
|
||||
@@ -394,8 +394,8 @@ class pts_graph_lines extends pts_graph_core
|
||||
$std_error = isset($raw_array[$i]) ? pts_math::standard_error(pts_strings::colon_explode($raw_array[$i])) : 0;
|
||||
$data_string = $identifier . ': ' . $value;
|
||||
|
||||
$value_plot_top = $this->i['graph_top_end'] + 1 - ($this->i['graph_max_value'] == 0 ? 0 : round((($value - $this->i['graph_min_value']) / ($this->i['graph_max_value'] - $this->i['graph_min_value'])) * ($this->i['graph_top_end'] - $this->i['top_start'])));
|
||||
$px_from_left = round($this->i['left_start'] + ($this->i['identifier_width'] * ($i + (count($this->graph_identifiers) > 1 ? 1 : 0))));
|
||||
$value_plot_top = round($this->i['graph_top_end'] + 1 - ($this->i['graph_max_value'] == 0 ? 0 : (($value - $this->i['graph_min_value']) / ($this->i['graph_max_value'] - $this->i['graph_min_value'])) * ($this->i['graph_top_end'] - $this->i['top_start'])));
|
||||
$px_from_left = $this->i['left_start'] + ($this->i['identifier_width'] * ($i + (count($this->graph_identifiers) > 1 ? 1 : 0)));
|
||||
|
||||
if($px_from_left > $this->i['graph_left_end'])
|
||||
{
|
||||
@@ -432,13 +432,12 @@ class pts_graph_lines extends pts_graph_core
|
||||
return;
|
||||
}
|
||||
|
||||
$svg_poly = array();
|
||||
$svg_poly_str = '';
|
||||
foreach($poly_points as $x_y)
|
||||
{
|
||||
$svg_poly[] = round($x_y[0]) . ',' . round($x_y[1]);
|
||||
$svg_poly_str .= $x_y[0] . ',' . $x_y[1] . ' ';
|
||||
}
|
||||
$svg_poly = implode(' ', $svg_poly);
|
||||
$this->svg_dom->add_element('polyline', array('points' => $svg_poly, 'fill' => 'none', 'stroke-width' => 2), $g);
|
||||
$this->svg_dom->add_element('polyline', array('points' => substr($svg_poly_str, 0, -1), 'fill' => 'none', 'stroke-width' => 2), $g);
|
||||
|
||||
// plot error bars if needed
|
||||
foreach($poly_points as $i => $x_y_pair)
|
||||
|
||||
@@ -29,8 +29,6 @@ class pts_graph_run_vs_run extends pts_graph_core
|
||||
public static function cmp_result_object_sort($a, $b)
|
||||
{
|
||||
return strcmp($b->get_spread(false), $a->get_spread(false));
|
||||
|
||||
return strcmp($a, $b);
|
||||
}
|
||||
public function __construct($result_file)
|
||||
{
|
||||
|
||||
@@ -590,7 +590,7 @@ class pts_result_file
|
||||
{
|
||||
$identifiers = $this->get_system_identifiers();
|
||||
}
|
||||
$is_multi_way = count($identifiers) < 2 ? false : pts_render::multi_way_identifier_check($identifiers, $hw, $this);
|
||||
$is_multi_way = count($identifiers) < 2 ? false : pts_render::multi_way_identifier_check($identifiers);
|
||||
$this->is_multi_way_inverted = $is_multi_way && $is_multi_way[1];
|
||||
}
|
||||
|
||||
@@ -1147,10 +1147,10 @@ class pts_result_file
|
||||
else
|
||||
{
|
||||
return strnatcmp($a_suites, $b_suites);
|
||||
$a_suites .= ' ';
|
||||
/*$a_suites .= ' ';
|
||||
$b_suites .= ' ';
|
||||
$first_suite_cmp = strcmp(substr($a_suites, 0, strpos($a_suites, ' ')), substr($b_suites, 0, strpos($b_suites, ' ')));
|
||||
return $first_suite_cmp != 0 ? $first_suite_cmp : strcmp($a_suites, $b_suites);
|
||||
return $first_suite_cmp != 0 ? $first_suite_cmp : strcmp($a_suites, $b_suites);*/
|
||||
}
|
||||
}
|
||||
public function sort_result_object_order_by_title($asc = true)
|
||||
|
||||
@@ -249,7 +249,7 @@ class pts_result_file_analyzer
|
||||
}
|
||||
}
|
||||
|
||||
if($added_count > 1)
|
||||
if($added_count > 1 && isset($scale))
|
||||
{
|
||||
$test_result->test_profile->set_result_scale($scale);
|
||||
return $test_result;
|
||||
@@ -270,6 +270,10 @@ class pts_result_file_analyzer
|
||||
$result_file = false;
|
||||
$ros = array($input);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($ros as &$result_object)
|
||||
{
|
||||
@@ -984,11 +988,11 @@ class pts_result_file_analyzer
|
||||
{
|
||||
foreach($test_results as $identifier => $values)
|
||||
{
|
||||
if(false && count($values) < 4)
|
||||
/*if(count($values) < 4)
|
||||
{
|
||||
// If small result file with not a lot of data, don't bother showing...
|
||||
unset($results[$test][$identifier]);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if(empty($results[$test]))
|
||||
|
||||
@@ -802,7 +802,7 @@ class pts_result_viewer_embed
|
||||
break;
|
||||
}
|
||||
}
|
||||
$suites_in_result_file = $system_count > 1 ? pts_test_suites::suites_in_result_file($result_file, true, 0) : array();
|
||||
$suites_in_result_file = $system_count > 1 && self::check_request_for_var($request, 'lcs') ? pts_test_suites::suites_in_result_file($result_file, true, 0) : array();
|
||||
// END OF CHECKS
|
||||
|
||||
$analyze_options .= '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">';
|
||||
@@ -832,6 +832,7 @@ class pts_result_viewer_embed
|
||||
$analyze_checkboxes['View'][] = array('hlc', 'Do Not Show Results With Little Change/Spread');
|
||||
$analyze_checkboxes['View'][] = array('spr', 'List Notable Results');
|
||||
$analyze_checkboxes['View'][] = array('src', 'Show Result Confidence Charts');
|
||||
$analyze_checkboxes['View'][] = array('lcs', 'Allow Limiting Results To Certain Suite(s)');
|
||||
|
||||
if($has_identifier_with_color_brand)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,6 @@ class pts_sys_graph
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->plot_data = array();
|
||||
foreach($data as $name => $value)
|
||||
{
|
||||
$this->__set($name, $value);
|
||||
|
||||
@@ -48,7 +48,7 @@ class pts_test_profile_results_definition
|
||||
}
|
||||
public function get_extra_data_definitions()
|
||||
{
|
||||
return $this->system_monitors;
|
||||
return $this->extra_data;
|
||||
}
|
||||
public function add_image_parser_definition($s, $m, $x, $y, $w, $h)
|
||||
{
|
||||
|
||||
@@ -226,7 +226,6 @@ class pts_test_result_buffer
|
||||
{
|
||||
if($buffer_item->get_result_value() < $value_below)
|
||||
{
|
||||
$other_value += $buffer_item->get_result_value();
|
||||
unset($this->buffer_items[$key]);
|
||||
$cleared = true;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ class pts_test_run_options
|
||||
|
||||
$error_handle = null;
|
||||
$option_objects = $test_profile->get_test_option_objects(true, $error_handle);
|
||||
if($error_handle)
|
||||
if(!empty($error_handle))
|
||||
{
|
||||
echo PHP_EOL . pts_client::$display->get_tab() . pts_client::cli_just_italic($error_handle) . PHP_EOL;
|
||||
return false;
|
||||
@@ -256,7 +256,7 @@ class pts_test_run_options
|
||||
|
||||
$error_handle = null;
|
||||
$option_objects = $test_profile->get_test_option_objects(true, $error_handle, $validate_options_now);
|
||||
if($error_handle)
|
||||
if(!empty($error_handle))
|
||||
{
|
||||
echo PHP_EOL . pts_client::$display->get_tab() . pts_client::cli_just_italic($error_handle) . PHP_EOL;
|
||||
return false;
|
||||
|
||||
@@ -60,7 +60,7 @@ class phoromatic_tests implements pts_webui_interface
|
||||
{
|
||||
$main .= '<p>No results found on this Phoromatic Server for the ' . $tp->get_title() . ' test profile.</p>';
|
||||
}
|
||||
else if(false && $recent_result_count > 5)
|
||||
else if(false) // previously: $recent_result_count > 5 TODO broken
|
||||
{
|
||||
// TODO XXX below code is borked
|
||||
$stmt = phoromatic_server::$db->prepare('SELECT UploadID, SystemID, UploadTime FROM phoromatic_results WHERE AccountID = :account_id AND UploadID IN (SELECT DISTINCT UploadID FROM phoromatic_results_results WHERE AccountID = :account_id AND TestProfile LIKE :tp) ORDER BY UploadTime DESC LIMIT 1000');
|
||||
|
||||
@@ -97,7 +97,7 @@ else if(isset($_GET['test']))
|
||||
{
|
||||
// Object is a test
|
||||
$test_profile = new pts_test_profile($tp_identifier);
|
||||
if(true || pts_validation::validate_test_profile($test_profile)) // TODO decide whether validate_test_profile is really desired for local tests where they might be sloppy
|
||||
if(true) // previously had pts_validation::validate_test_profile($test_profile) TODO decide whether validate_test_profile is really desired for local tests where they might be sloppy
|
||||
{
|
||||
pts_logger::add_to_log($_SERVER['REMOTE_ADDR'] . ' requested a fallback copy of the ' . $test_profile->get_identifier() . ' test profile');
|
||||
$zip_file = tempnam(sys_get_temp_dir(), 'phoromatic-zip') . '.zip';
|
||||
|
||||
Reference in New Issue
Block a user