diff --git a/VERSIONS_HOTLINE/163727 b/VERSIONS_HOTLINE/163727 new file mode 100644 index 0000000000000000000000000000000000000000..c9786d5ce7af82401f342b45849e1c08fe9475d0 --- /dev/null +++ b/VERSIONS_HOTLINE/163727 @@ -0,0 +1 @@ + - correctif #169349 : Agenda : Correction du chargement des événements lorsqu'il y a plusieurs boites agenda ou d'articles dans une même page. \ No newline at end of file diff --git a/library/Class/Article/SelectWithTimings.php b/library/Class/Article/SelectWithTimings.php index 4c7f2b426490a8450699e2fe2482e694b76ae59c..3e4d0b603a02288e32b353918c3af9182e01fb42 100644 --- a/library/Class/Article/SelectWithTimings.php +++ b/library/Class/Article/SelectWithTimings.php @@ -25,11 +25,15 @@ class Class_Article_SelectWithTimings extends Class_Article_Select { protected function _selectArticles() { parent::_selectArticles(); + + Class_Article::clearCache(); + $this->_select ->joinLeft('cms_article_timings', 'cms_article.id_article=cms_article_timings.article_id', ['min(cms_article_timings.start) as start', 'min(cms_article_timings.end) as end']) ->group('id_article'); + return $this; } diff --git a/tests/library/Class/ArticleSelectTest.php b/tests/library/Class/ArticleSelectTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f13ce979ad56e916048ed089bee578fcaadf9239 --- /dev/null +++ b/tests/library/Class/ArticleSelectTest.php @@ -0,0 +1,71 @@ +<?php +/** + * Copyright (c) 2012-2022, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ArticleSelectCacheTest extends ModelTestCase { + + + /** @test */ + public function findAllArticlesWithselectWithTimingShouldClearArticlesCache() { + $this->fixture(Class_Article::class, + ['id' => 1, + 'titre' => 'Atelier de chansons potaches', + 'contenu' => 'L\'actualité parodiée et chantée.']); + + $this->fixture(Class_Article::class, + ['id' => 2, + 'titre' => 'Atelier de chansons potaches', + 'contenu' => 'L\'actualité parodiée et chantée.']); + + + Class_Article::newInstanceWithId(3, + ['titre' => 'Atelier de chansons potaches', + 'contenu' => 'L\'actualité parodiée et chantée.']); + + $params = ['order' => 'DebutPublicationDesc', + 'size' => 30, + 'nb_analyse' => '', + 'id_items' => '1', + 'id_categorie' => '', + 'langue' => '', + 'event_date' => '', + 'event_end_after' => '', + 'event_start_after' => '', + 'id_bib' => '', + 'id_lieu' => '', + 'status' => '', + 'events_only' => '', + 'published' => '', + 'display_mode' => '', + 'custom_fields' => '', + 'place_town' => '', + 'filter_by_workflow' => '', + 'filter_by_local' => '']; + + $loader = Class_Article::getLoader(); + + $articles = + (new Class_Article_SelectWithTimings($loader)) + ->findAll($params); + + $this->assertCount(2, $loader->getLoadedInstances()); + } +}