From d578bf35ee9d6f54eb90299a028d652c1ed863b2 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Tue, 12 Apr 2022 16:34:05 +0200 Subject: [PATCH] hotline #155404 fix journal rendering with deleted articles --- VERSIONS_HOTLINE/155404 | 1 + library/Class/Journal/ArticleType.php | 4 +++- tests/scenarios/Journal/JournalTest.php | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 VERSIONS_HOTLINE/155404 diff --git a/VERSIONS_HOTLINE/155404 b/VERSIONS_HOTLINE/155404 new file mode 100644 index 00000000000..8f10a5a598b --- /dev/null +++ b/VERSIONS_HOTLINE/155404 @@ -0,0 +1 @@ + - correctif #155404 : Administration : correction de l'affichage du journal lorsque des articles ont été supprimés. \ No newline at end of file diff --git a/library/Class/Journal/ArticleType.php b/library/Class/Journal/ArticleType.php index 8d19f3b23b3..e46db57b6fb 100644 --- a/library/Class/Journal/ArticleType.php +++ b/library/Class/Journal/ArticleType.php @@ -43,7 +43,9 @@ class Class_Journal_ArticleType extends Class_Journal_Type { public function renderModelLinkOn($id, Zend_View_Interface $view) : string { - $article = Class_Article::find($id); + if ( ! $article = Class_Article::find($id)) + return $this->_('inconnu id: %d', $id); + return $view->tagAnchor(['module' => 'admin', 'controller' => 'cms', 'action' => 'edit', diff --git a/tests/scenarios/Journal/JournalTest.php b/tests/scenarios/Journal/JournalTest.php index 7a7fb2dfc60..8d413b448ee 100644 --- a/tests/scenarios/Journal/JournalTest.php +++ b/tests/scenarios/Journal/JournalTest.php @@ -308,3 +308,16 @@ class JournalErrorsTest extends JournalTestCase { $this->assertRedirectTo('/admin/journal/index'); } } + + + + +class JournalWithDeletedArticleTest extends JournalWithEntriesTestCase { + + /** @test */ + public function journalShouldRenderTable() { + Class_Article::find(2)->delete(); + $this->dispatch('/admin/journal'); + $this->assertXPathContentContains('//table//td', 'a modifié l\'article inconnu id: 2'); + } +} -- GitLab