From a6494c5f85a917e9b4dec9d1f4c4ee7681159a06 Mon Sep 17 00:00:00 2001
From: Julian Maurice <julian.maurice@biblibre.com>
Date: Thu, 22 May 2014 11:06:22 +0200
Subject: [PATCH] hotline #13749 Do not index not visible albums

---
 library/Class/Indexation/PseudoNotice.php        |  4 ++++
 .../RechercheControllerAlbumAudioRecordTest.php  | 16 +++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/library/Class/Indexation/PseudoNotice.php b/library/Class/Indexation/PseudoNotice.php
index 5702c6ba72d..cfe8fef44be 100644
--- a/library/Class/Indexation/PseudoNotice.php
+++ b/library/Class/Indexation/PseudoNotice.php
@@ -420,6 +420,10 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{
 		foreach ($this->_model->getRessources() as $ressource) 
 			$visitor->visitRessource($ressource);
 	}
+
+	public function isValid() {
+		return null != $this->_model && $this->_model->isVisible();
+	}
 }
 
 
diff --git a/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php b/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php
index 0a54981acbd..71ecbb9fa93 100644
--- a/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php
+++ b/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php
@@ -412,4 +412,18 @@ class RechercheControllerAlbumAudioRecordAsTelephoneViewRessourcesNumeriquesTest
 		$this->assertXPathContentContains('//ol//li', 'The prophecy');
 	}
 }
-?>
\ No newline at end of file
+
+
+
+
+class RechercheControllerAlbumAudioRecordNotVisibleTest extends RechercheControllerAlbumAudioRecordTestCase {
+	/** @test */
+	public function noNoticeShouldBeCreated() {
+		Class_Album::find(4)
+			->setVisible(false)
+			->index();
+		$this->assertEmpty(Class_Notice::findAll());
+	}
+}
+
+?>
-- 
GitLab