Skip to content
Snippets Groups Projects
Commit b4e48920 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

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

parent dd8e0f90
Branches
Tags
4 merge requests!3297WIP: Master,!3203Master,!3202Hotline,!3196hotline#95499 : rendezvous : fix sql error on rendezvous index when no customfields defined
Pipeline #8000 passed with stage
in 38 minutes and 26 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();
......
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