Commit dd3b5d35 authored by Henri-Damien LAURENT's avatar Henri-Damien LAURENT

Merge branch 'hotline#95499_rendez_vous_portail_mdaude' into 'hotline'

hotline#95499 : rendezvous : fix sql error on rendezvous index when no customfields defined

See merge request !3196
parents c4f319b9 b4e48920
Pipeline #8013 passed with stage
in 37 minutes and 32 seconds
- ticket #95499 : RendezVous : Correction plantage erreur SQL en absence de champs personnalisés
\ No newline at end of file
......@@ -33,15 +33,15 @@ class Class_CustomField_ValueLoader extends Storm_Model_Loader {
public function findAllByInstance($instance) {
if (!$instance
|| (!$model = Class_CustomField_Model::getModel(get_class($instance))))
|| (!$model = Class_CustomField_Model::getModel(get_class($instance)))
|| (!$fields = $model->getFields()))
return [];
$fields = $model->getFields();
$field_ids = array_map(function($f) {return $f->getId();},
$fields);
return $this->findAllBy(['model_id' => $instance->getId(),
'custom_field_id' => $field_ids]);
return Class_CustomField_Value::findAllBy(['model_id' => $instance->getId(),
'custom_field_id' => $field_ids]);
}
}
......
......@@ -76,6 +76,31 @@ abstract class UsergroupAgendaAdminModoPortailLoggedTestCase extends Admin_Abstr
/** @see https://forge.afi-sa.net/issues/95499 */
class UsergroupAgendaAdminIndexWithoutCustomFieldsTest
extends UsergroupAgendaAdminModoPortailLoggedTestCase {
public function setUp() {
parent::setUp();
$groupagenda = $this->fixture('Class_UserGroup_Agenda',
['id' => 5,
'libelle' => 'MonAgenda',
'model_class' => 'Class_RendezVous']);
$this->onLoaderOfModel('Class_CustomField_Value');
$this->dispatch('/admin/usergroup-agenda');
}
/** @test */
public function shouldNotCallFindCustomFieldValues() {
$this->assertFalse(Class_CustomField_Value::methodHasBeenCalled('findAllBy'));
}
}
class UsergroupAgendaAdminIndexValidTest extends UsergroupAgendaAdminModoPortailLoggedTestCase {
public function setUp() {
parent::setUp();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment