diff --git a/VERSIONS_HOTLINE/169355 b/VERSIONS_HOTLINE/169355 new file mode 100644 index 0000000000000000000000000000000000000000..6723a9bab78fc2c53a0da89702f145a464b3eeb2 --- /dev/null +++ b/VERSIONS_HOTLINE/169355 @@ -0,0 +1 @@ + - correctif #169355 : Cosmogramme : Activation du calcul des facettes pour les notices de plus de 1000 exemplaires (revues et périodiques) \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_446.php b/cosmogramme/sql/patch/patch_446.php new file mode 100644 index 0000000000000000000000000000000000000000..b698a02c098d67fb0ae6216a0c2ba91a472c393c --- /dev/null +++ b/cosmogramme/sql/patch/patch_446.php @@ -0,0 +1,7 @@ +<?php +$adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); + +try { + $adapter->query("insert into variables (clef, valeur, commentaire, type_champ, liste, groupe, ordre, verrou, hidden) VALUES ('max_items',1000,'Nombre maximum d\'exemplaires traités par notices',0,'',4,1,0,0)"); +} +catch(Exception $e) {} diff --git a/library/Class/Cosmogramme/Integration/PhaseItemFacets.php b/library/Class/Cosmogramme/Integration/PhaseItemFacets.php index 153da8d03873584e7abf4efda4f91cd3a01ed72c..ac1a65ace3f5806e66b88ff0e7340726b05da3d5 100644 --- a/library/Class/Cosmogramme/Integration/PhaseItemFacets.php +++ b/library/Class/Cosmogramme/Integration/PhaseItemFacets.php @@ -23,7 +23,6 @@ class Class_Cosmogramme_Integration_PhaseItemFacets extends Class_Cosmogramme_Integration_PhaseAbstract { const MY_ID = 7; - const MAX_ITEMS = 1000; protected $_previous_records, $_last_update_date; protected $_db_reset = true; @@ -80,12 +79,13 @@ class Class_Cosmogramme_Integration_PhaseItemFacets return $this->_resetDbConnection() ->_phase; - if (static::MAX_ITEMS < Class_Exemplaire::countBy(['id_notice' => $record->getId()])) { + $max_items = Class_CosmoVar::get('max_items'); + if ($max_items < Class_Exemplaire::countBy(['id_notice' => $record->getId()])) { $this->_log->error('<span class="rouge">' . $this->_('La notice "%s" (id: %s) a plus de %s exemplaires: facettes non mises à jour', $record->getTitrePrincipal(), $record->getId(), - static::MAX_ITEMS) + $max_items) . '</span>'); $this->_setData('pointeur_notice', $record->getId()); $this->_incrementData('nombre'); diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php index fb0a8409ee7665009a7844225514b58dcb97195e..c5787eab19b7b0718d1999ace126fe901722699e 100644 --- a/tests/db/UpgradeDBTest.php +++ b/tests/db/UpgradeDBTest.php @@ -5069,3 +5069,26 @@ class UpgradeDB_445_Test extends UpgradeDBTestCase { $this->assertFieldType('cms_article', 'id_cat', 'int(11)'); } } + + + + +class UpgradeDB_446_Test extends UpgradeDBTestCase { + public function prepare() { + $this->silentQuery("delete from variables where clef='max_items'"); + } + + + /** @test */ + public function tableVariablesShouldHaveMaxItemsVariableInGroupe4() { + $this->assertEquals(4, + $this->query("select * from variables where clef='max_items'")->fetch()['groupe']); + } + + + /** @test */ + public function tableVariablesShouldHaveMaxItemsVariableSetTo1000() { + $this->assertEquals(1000, + $this->query("select * from variables where clef='max_items'")->fetch()['valeur']); + } +} diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseItemFacetsTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseItemFacetsTest.php index 6c2c36b519fd2ef3fcb5b108717455e7bb0f74fc..398b0073fa98614fa78641d17e0c9c660eaa697b 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseItemFacetsTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseItemFacetsTest.php @@ -47,7 +47,7 @@ class PhaseItemFacetsBadPreviousPhaseTest extends PhaseItemFacetsTestCase { -class PhaseItemFacetsExpectedPreviousPhaseTest extends PhaseItemFacetsTestCase { +abstract class PhaseItemFacetsExpectedPreviousPhaseTestCase extends PhaseItemFacetsTestCase { protected function _getPreviousPhase() { return (new Class_Cosmogramme_Integration_Phase(4)) ->beCron(); @@ -55,7 +55,7 @@ class PhaseItemFacetsExpectedPreviousPhaseTest extends PhaseItemFacetsTestCase { protected function _prepareFixtures() { - $this->fixture('Class_CosmoVar', + $this->fixture(Class_CosmoVar::class, ['id' => 'date_maj_facettes', 'valeur' => '']); @@ -96,12 +96,6 @@ class PhaseItemFacetsExpectedPreviousPhaseTest extends PhaseItemFacetsTestCase { } - /** @test */ - public function logShouldContainsRecordTwoHasMoreThan1000Items() { - $this->assertLogContains('La notice "Les cassetouts" (id: 2) a plus de 1000 exemplaires'); - } - - /** @test */ public function logShouldContainsProcessedRecordCount() { $this->assertLogContains('2 notices traitées'); @@ -116,6 +110,34 @@ class PhaseItemFacetsExpectedPreviousPhaseTest extends PhaseItemFacetsTestCase { + +class PhaseItemWithMaxItems1000 extends PhaseItemFacetsExpectedPreviousPhaseTestCase { + /** @test */ + public function logShouldContainsRecordTwoHasMoreThan1000Items() { + $this->assertLogContains('La notice "Les cassetouts" (id: 2) a plus de 1000 exemplaires'); + } +} + + + + +class PhaseItemWithMaxItems10000 extends PhaseItemFacetsExpectedPreviousPhaseTestCase { + protected function _prepareFixtures() { + parent::_prepareFixtures(); + $this->fixture(Class_CosmoVar::class, + ['id' => 'max_items', + 'valeur' => '10000']); + } + + /** @test */ + public function logShouldNotContainsRecordTwoHasMoreThan1000Items() { + $this->assertNotLogContains('La notice "Les cassetouts" (id: 2) a plus de 1000 exemplaires'); + } +} + + + + abstract class PhaseItemFacetsCallbackTest extends PhaseItemFacetsTestCase { protected function _getPreviousPhase() { return (new Class_Cosmogramme_Integration_Phase(4)); @@ -165,6 +187,7 @@ class PhaseItemFacetsExpectedExceptionPhaseTest extends PhaseItemFacetsTestCase + /* Fix hotline #64218 */ class PhaseItemFacetsExecutePhaseTest extends PhaseItemFacetsTestCase { protected function _getPreviousPhase() { diff --git a/tests/library/Class/ModelTestCase.php b/tests/library/Class/ModelTestCase.php index 746c0b76e4c2aab8ab34101d411bc5e442e78d11..d5f6c8578fb0db2ff1a0bc3156d60d0ba6763025 100644 --- a/tests/library/Class/ModelTestCase.php +++ b/tests/library/Class/ModelTestCase.php @@ -66,6 +66,7 @@ abstract class ModelTestCase extends Storm_Test_ModelTestCase { Class_AdminVar::set("AVIS_MAX_SAISIE", 100); Class_AdminVar::set("FORCE_HTTPS", 0); Class_AdminVar::set('NOM_DOMAINE', 'http://localhost'); + Class_CosmoVar::setValueOf('max_items',1000); Class_Crypt::setPhpCommand($this->mock() ->whenCalled('password_hash') ->willDo(function($pass, $crypt) { return $pass; }));