From 039223ec207c0f1f93c6e29debe7336413c61d42 Mon Sep 17 00:00:00 2001 From: Alex Arnaud <alex.arnaud@biblibre.com> Date: Tue, 28 Jul 2015 10:14:16 +0200 Subject: [PATCH] hotline #27726 - Don't index articles with exceeded date or non validated status --- VERSIONS_HOTLINE/27726 | 1 + library/Class/Article.php | 3 ++- tests/library/Class/ArticleTest.php | 33 +++++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 VERSIONS_HOTLINE/27726 diff --git a/VERSIONS_HOTLINE/27726 b/VERSIONS_HOTLINE/27726 new file mode 100644 index 00000000000..721a711a9e4 --- /dev/null +++ b/VERSIONS_HOTLINE/27726 @@ -0,0 +1 @@ +- ticket #27726: Empèche l'indexation des articles avec une date de fin dépassées ou un statut autre que validé diff --git a/library/Class/Article.php b/library/Class/Article.php index 9f7b283089b..e1a689518bc 100644 --- a/library/Class/Article.php +++ b/library/Class/Article.php @@ -784,7 +784,8 @@ class Class_Article extends Storm_Model_Abstract { protected function hasToBeIndexed() { - return $this->_get('indexation') == 1; + return ($this->isVisible() + && $this->_get('indexation') == 1); } diff --git a/tests/library/Class/ArticleTest.php b/tests/library/Class/ArticleTest.php index 0b26d2dc619..4738f8240a0 100644 --- a/tests/library/Class/ArticleTest.php +++ b/tests/library/Class/ArticleTest.php @@ -1096,14 +1096,31 @@ class ArticleIndexAllTest extends Storm_Test_ModelTestCase { 'titre' => 'My Cms First Step', 'contenu' => 'My Cms First Step', 'auteur' => $user, - 'indexation' => 1]); + 'indexation' => 1, + 'status' => Class_Article::STATUS_VALIDATED]); $this->fixture('Class_Article', ['id' => 2, 'titre' => 'My Cms article', 'indexation' => 1, 'contenu' => 'My Cms First Step', - 'domaine_ids' => '1']); + 'domaine_ids' => '1', + 'status' => Class_Article::STATUS_VALIDATED]); + + $this->fixture('Class_Article', + ['id' => 3, + 'titre' => 'Le circuit de la peur', + 'indexation' => 1, + 'contenu' => 'Le circuit de la peur', + 'debut' => '2014-10-09', + 'fin' => '2014-10-30', + 'status' => Class_Article::STATUS_VALIDATED]); + + $this->fixture('Class_Article', + ['id' => 4, + 'titre' => 'La fête de la Science', + 'contenu' => 'La fête de la Science', + 'status' => Class_Article::STATUS_DRAFT]); Class_Article::indexAll(); } @@ -1131,6 +1148,18 @@ class ArticleIndexAllTest extends Storm_Test_ModelTestCase { public function myDomainShouldHaveANoticeLineked() { $this->assertEquals('My Cms article', Class_NoticeDomain::findFirstBy(['domain_id' => 1])->getNotice()->getTitrePrincipal()); } + + + /** @test */ + public function article3ShouldNotHaveANotice() { + $this->assertNull(Class_Article::find(3)->getNotice()); + } + + + /** @test */ + public function article4ShouldNotHaveANotice() { + $this->assertNull(Class_Article::find(4)->getNotice()); + } } -- GitLab