39 return 'Invalid Number of Kids on Link Tree Test';
52 return 'A test to detect invalid number of kids entries on link tree';
66 public static function test(&$messages, &$errors)
72 $root_sql =
"SELECT pt.linkid, pt.treeid, pt.num_kids, count(ct.treeid) AS count FROM sq_ast_lnk_tree ct, sq_ast_lnk_tree pt WHERE pt.linkid = '1' AND ct.treeid LIKE '0000%' AND LENGTH(ct.treeid) = (LENGTH(pt.treeid) + ".SQ_CONF_ASSET_TREE_SIZE.
") GROUP BY pt.linkid, pt.treeid, pt.num_kids";
74 foreach ($root_results as $result) {
75 if ($result[
'num_kids'] != $result[
'count']) {
78 $errors[] =
'Link #'.$result[
'linkid'].
' has '.$result[
'num_kids'].
' kids listed, but actually '.$result[
'count'].
' kids were found';
83 $sql =
"SELECT pt.linkid, pt.treeid, pt.num_kids, count(ct.treeid) AS count FROM sq_ast_lnk_tree ct, sq_ast_lnk_tree pt WHERE pt.linkid IN (SELECT DISTINCT linkid FROM sq_ast_lnk_tree WHERE linkid > '1' AND num_kids>0) AND ct.treeid LIKE pt.treeid || '%' AND LENGTH(ct.treeid) = (LENGTH(pt.treeid) + ".SQ_CONF_ASSET_TREE_SIZE.
") GROUP BY pt.linkid, pt.treeid, pt.num_kids";
85 foreach ($results as $result) {
86 if ($result[
'num_kids'] != $result[
'count']) {
89 $errors[] =
'Link #'.$result[
'linkid'].
' has '.$result[
'num_kids'].
' kids listed, but actually '.$result[
'count'].
' kids were found';
93 if (!$status && !empty($count)) {
94 $messages[] =
'There are '.$count.
' invalid number of kids found on the system';