diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php
index 0b247e7f5f4..ebf568e68fe 100644
--- a/htdocs/hrm/class/skill.class.php
+++ b/htdocs/hrm/class/skill.class.php
@@ -410,7 +410,13 @@ class Skill extends CommonObject
$skilldet = new Skilldet($this->db);
$this->lines = $skilldet->fetchAll('ASC', '', '', '', array('fk_skill' => $this->id), '');
- return (count($this->lines) > 0 ) ? $this->lines : array();
+ if (is_array($this->lines)) {
+ return (count($this->lines) > 0) ? $this->lines : array();
+ } elseif ($this->lines < 0) {
+ $this->errors = array_merge($this->errors, $skilldet->errors);
+ $this->error = $skilldet->error;
+ return $this->lines;
+ }
}
diff --git a/htdocs/hrm/lib/hrm_skillrank.lib.php b/htdocs/hrm/lib/hrm_skillrank.lib.php
index 2aca41504ad..78a53823c2d 100644
--- a/htdocs/hrm/lib/hrm_skillrank.lib.php
+++ b/htdocs/hrm/lib/hrm_skillrank.lib.php
@@ -115,44 +115,48 @@ function displayRankInfos($selected_rank, $fk_skill, $inputname = 'TNote', $mode
$skilldet = new Skilldet($db);
$Lines = $skilldet->fetchAll('ASC', 'rank', 0, 0, array('customsql'=>'fk_skill = '.$fk_skill));
+ if (!is_array($Lines) && $Lines<0) {
+ setEventMessages($skilldet->error, $skilldet->errors, 'errors');
+ }
if (empty($Lines)) return $langs->trans('SkillHasNoLines');
$ret = '0';
+ if (is_array($Lines) && !empty($Lines)) {
+ foreach ($Lines as $line) {
+ $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL;
+ if ($line->rank > $MaxNumberSkill) {
+ continue;
+ }
- foreach ($Lines as $line) {
- $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL;
- if ($line->rank > $MaxNumberSkill) {
- continue;
+ $ret .= '' . $line->rank . '';
}
- $ret.= ''.$line->rank.'';
- }
-
- if ($mode == 'edit') {
- $ret.= '
-
+ if ($mode == 'edit') {
+ $ret .= '
+
';
+ }
}
return $ret;