diff --git a/VERSIONS b/VERSIONS index 9da0be92ea007b0865023300e5bedfa87325e7ce..94a8aa1a74478ca069e19bada76935a66613a4a6 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,7 +1,9 @@ -15/03/2018 - v7.12.5 +15/03/2018 - v7.12.5 v7.12.6 - ticket #72835 : Explorateur de fichier : correction de la sélection d'une image lorsqu'on vient de la téléverser. - + + - ticket #72723 : Indexation : Correction de l'indexation d'articles liés à des domaines ayant été supprimés + 12/03/2018 - v7.12.4 diff --git a/library/Class/NoticeDomain.php b/library/Class/NoticeDomain.php index 5d2f5bffa138311af7e40258ae791f075cb7d4b8..bc050d23353555f7bf5433e4f45496c886159795 100644 --- a/library/Class/NoticeDomain.php +++ b/library/Class/NoticeDomain.php @@ -111,6 +111,7 @@ class Class_NoticeDomain extends Storm_Model_Abstract { $_belongs_to = ['domain' => ['model' => 'Class_Catalogue', 'referenced_in' => 'domain_id'], + 'panier_notice' => ['model' => 'Class_PanierNotice', 'referenced_in' => 'panier_id']], @@ -129,12 +130,23 @@ class Class_NoticeDomain extends Storm_Model_Abstract { } + public function getNotice() { + return Class_Notice::findFirstBy(['clef_alpha' => $this->getRecordAlphaKey()]); + } + + + public function updateFacette() { + $this->_withRecordAndDomainDo([$this, '_updateRecordFacets']); + return $this; + } + + public function beforeDelete() { - $record = $this->getNotice(); - $domain = $this->getDomain(); - if(!$record || !$domain) - return; + $this->_withRecordAndDomainDo([$this, '_deleteRecordFacetIfLast']); + } + + protected function _deleteRecordFacetIfLast($record, $domain) { $existing = Class_NoticeDomain::getLoader() ->countBy(['domain_id' => $domain->getId(), 'record_alpha_key' => $this->getRecordAlphaKey()]); @@ -145,15 +157,17 @@ class Class_NoticeDomain extends Storm_Model_Abstract { } - public function getNotice() { - return Class_Notice::findFirstBy(['clef_alpha' => $this->getRecordAlphaKey()]); + protected function _updateRecordFacets($record, $domain) { + $record->updateFacette($domain->getFacette())->save(); } - public function updateFacette() { - $this->getNotice() - ->updateFacette($this->getDomain()->getFacette()) - ->save(); - return $this; + protected function _withRecordAndDomainDo($callback) { + $record = $this->getNotice(); + $domain = $this->getDomain(); + if (!$record || !$domain) + return; + + return call_user_func($callback, $record, $domain); } } \ No newline at end of file diff --git a/library/startup.php b/library/startup.php index 36398881b98b138cfcd39a19f0111711036fae5e..4e93e6d7035c1b157dfc9fcee1c9be655666eb3f 100644 --- a/library/startup.php +++ b/library/startup.php @@ -82,7 +82,7 @@ class Bokeh_Engine { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','7.12'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.5'); + defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.6'); defineConstant('BOKEH_REMOTE_FILES', 'http://git.afi-sa.fr/afi/opacce/'); diff --git a/tests/library/Class/Indexation/PseudoNoticeTest.php b/tests/library/Class/Indexation/PseudoNoticeTest.php index 8c47e1cd1f18957dc3f70ce027d2ffda781baa20..a06bd2ef0b3987651556544cb463bd128eb016e0 100644 --- a/tests/library/Class/Indexation/PseudoNoticeTest.php +++ b/tests/library/Class/Indexation/PseudoNoticeTest.php @@ -323,6 +323,32 @@ class Class_Indexation_PseudoNoticeArticleTest } +/** @see http://forge.afi-sa.fr/issues/72723 */ +class Class_Indexation_PseudoNoticeArticleWithUnknownDomainTest + extends Class_Indexation_PseudoNoticeTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture('Class_NoticeDomain', + ['id' => 189, + 'domain_id' => 17, + 'record_alpha_key' => 'MYARTCILE-1-----8']); + + $this->fixture('Class_Article', + ['id' => 1, + 'titre' => 'My Artcile', + 'contenu' => 'article is about...', + 'domaine_ids' => '17']); + } + + + /** @test */ + public function indexAllShouldNotHaveFatalError() { + Class_Article::indexAll(); + } +} + + class Class_Indexation_PseudoNoticeArticleUpdateTest extends Class_Indexation_PseudoNoticeTestCase {