Skip to content

Commit 95d07ec

Browse files
John Saigledriusan
authored andcommitted
[Data Team Helper] Ensure test_name is always a string (#3909)
- Modify Utility function to always return a string - Change function in data_team_helper to default to a string and return a string instead of null.
1 parent 88588db commit 95d07ec

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

modules/data_team_helper/php/data_team_helper.class.inc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,15 @@ class Data_Team_Helper extends \NDB_Form
330330
* Get the list of fieldnames in conflict for the given test_name
331331
* from conflict_unresolved
332332
*
333-
* @param unknown_type $test_name the value of test name
334-
* @param string $visit_label the value of visit label
335-
* @param string $candidate the value of candidate
336-
* @param int|string $site the id or default value of the site
337-
* @param int|null $project the id of the project or can be null
333+
* @param string $test_name the value of test name
334+
* @param string $visit_label the value of visit label
335+
* @param string $candidate the value of candidate
336+
* @param int|string $site the id or default value of the site
337+
* @param int|null $project the id of the project or can be null
338338
*
339339
* @return unknown
340340
*/
341-
function instrumentInConflict($test_name,
341+
function instrumentInConflict(string $test_name,
342342
$visit_label=null,
343343
$candidate=null,
344344
$site=null,
@@ -760,15 +760,15 @@ class Data_Team_Helper extends \NDB_Form
760760
* @param string|null $full_name the value of full name
761761
* @param string|null $subprojectID the value of subproject ID
762762
*
763-
* @return mixed|Non
763+
* @return string
764764
* @throws \DatabaseException
765765
*/
766-
function getTestNameusingMappedName($full_name, $subprojectID = null)
766+
function getTestNameusingMappedName($full_name, $subprojectID = null): string
767767
{
768768
$DB =& \Database::singleton();
769769
$values = array();
770770

771-
$test_name = null;
771+
$test_name = '';
772772
if ((!(is_null($full_name)))) {
773773
if ($DB->ColumnExists('test_battery', 'Test_name_display')) {
774774
$sqlSelectOne = "SELECT Test_name".

modules/data_team_helper/test/data_team_helperTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,4 @@ function testDataTeamHelperPermission()
7575
);
7676
$this->resetPermissions();
7777
}
78-
7978
}
80-
?>

php/libraries/Utility.class.inc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,17 +724,15 @@ class Utility
724724
* @note Function comment written by Dave, not the author of this function.
725725
* @cleanup
726726
*/
727-
static function getTestNameUsingFullName($fullname)
727+
static function getTestNameUsingFullName($fullname): string
728728
{
729-
$test_name = '';
730-
$db =& Database::singleton();
731-
//print_r($instument);
729+
$test_name = '';
730+
$db =& Database::singleton();
732731
$instrument = $db->pselect(
733732
"SELECT Test_name FROM test_names WHERE Full_name =:fname",
734733
array('fname' => $fullname)
735734
);
736735
if (is_array($instrument) && count($instrument)) {
737-
//$full_name = $names[0]
738736
list(,$test_name) = each($instrument[0]);
739737
}
740738
return $test_name;

0 commit comments

Comments
 (0)