diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php
index 26cf85cb3d6..3fa238894e1 100644
--- a/htdocs/opensurvey/card.php
+++ b/htdocs/opensurvey/card.php
@@ -46,11 +46,6 @@ if (GETPOST('id')) {
$object=new Opensurveysondage($db);
$result=$object->fetch(0, $numsondage);
-if ($result <= 0)
-{
- dol_print_error($db,$object->error);
- exit;
-}
$expiredate=dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear'));
@@ -206,7 +201,17 @@ foreach ($toutsujet as $value)
$toutsujet=str_replace("@","
",$toutsujet);
$toutsujet=str_replace("°","'",$toutsujet);
-
+if (empty($object->ref)) // For survey, id is a hex string
+{
+ $langs->load("errors");
+ print $langs->trans("ErrorRecordNotFound");
+
+ llxFooter();
+
+ $db->close();
+ exit;
+}
+
print '
';
print '
';
-llxFooterSurvey();
+llxFooter();
$db->close();
diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php
index 02952f4bf75..5ad27731d88 100644
--- a/htdocs/opensurvey/class/opensurveysondage.class.php
+++ b/htdocs/opensurvey/class/opensurveysondage.class.php
@@ -228,8 +228,7 @@ class Opensurveysondage extends CommonObject
$obj = $this->db->fetch_object($resql);
$this->id_sondage = $obj->id_sondage;
- //For compatibility
- $this->ref = $this->id_sondage;
+ $this->ref = $this->id_sondage; //For compatibility
$this->commentaires = $obj->description; // deprecated
$this->description = $obj->description;
diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php
index 834f17b8b2c..6f242a00544 100644
--- a/htdocs/public/opensurvey/studs.php
+++ b/htdocs/public/opensurvey/studs.php
@@ -41,7 +41,6 @@ if (GETPOST('sondage'))
$object=new Opensurveysondage($db);
$result=$object->fetch(0,$numsondage);
-if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
$nblignes=$object->fetch_lines();
@@ -241,6 +240,16 @@ $arrayofjs=array();
$arrayofcss=array('/opensurvey/css/style.css');
llxHeaderSurvey($object->titre, "", 0, 0, $arrayofjs, $arrayofcss);
+if (empty($object->ref)) // For survey, id is a hex string
+{
+ $langs->load("errors");
+ print $langs->trans("ErrorRecordNotFound");
+
+ llxFooterSurvey();
+
+ $db->close();
+ exit;
+}
// Define format of choices
$toutsujet=explode(",",$object->sujet);