diff --git a/VERSIONS_HOTLINE/184104 b/VERSIONS_HOTLINE/184104 new file mode 100644 index 0000000000000000000000000000000000000000..2d98b79e1b8825a1eae69b10cfd9908749ff59b1 --- /dev/null +++ b/VERSIONS_HOTLINE/184104 @@ -0,0 +1 @@ + - correctif #184104 : PHP 8.1 : Erreur cosmogramme mise à jour des clés d'étagères \ No newline at end of file diff --git a/library/Class/Exemplaire/ShelfKey.php b/library/Class/Exemplaire/ShelfKey.php index d79ec4425bc80c8f836dbf3137f4b788f3481197..9b0def0be08361b07d442d94ff6a630977401dd8 100644 --- a/library/Class/Exemplaire/ShelfKey.php +++ b/library/Class/Exemplaire/ShelfKey.php @@ -43,10 +43,10 @@ class Class_Exemplaire_ShelfKey { public function generateForArray(array $row) : string { - $parts = $this->_coteKeyParts($row['cote']); - $parts [] = $this->_padLeft($row['clef_chapeau'], $this->_subkey_len * 2); - $parts [] = $this->_padLeft($row['tome_alpha'], $this->_subkey_len); - $parts [] = $this->_padLeft($row['clef_alpha'], $this->_subkey_len * 2); + $parts = $this->_coteKeyParts($row['cote'] ?? ''); + $parts [] = $this->_padLeft($row['clef_chapeau'] ?? '', $this->_subkey_len * 2); + $parts [] = $this->_padLeft($row['tome_alpha'] ?? '', $this->_subkey_len); + $parts [] = $this->_padLeft($row['clef_alpha'] ?? '', $this->_subkey_len * 2); $parts [] = str_pad(substr($row['id'], -$this->_subkey_len), $this->_subkey_len, diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseItemsShelfKeyGenerationTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseItemsShelfKeyGenerationTest.php index 3491e5975b8a0d0e73168bc911687d6c07297ab1..ca1d4dc52db243d64d7a151b6ebd117953797dcd 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseItemsShelfKeyGenerationTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseItemsShelfKeyGenerationTest.php @@ -20,12 +20,12 @@ */ -abstract class PhaseItemsShelfKeyGenerationTestCase extends Class_Cosmogramme_Integration_PhaseTestCase { +abstract class PhaseItemsShelfKeyGenerationTestCase + extends Class_Cosmogramme_Integration_PhaseTestCase { protected bool $_build_result_to_update_done = false; protected bool $_build_result_to_init_done = false; - public function setUp() { parent::setUp(); @@ -51,6 +51,10 @@ abstract class PhaseItemsShelfKeyGenerationTestCase extends Class_Cosmogramme_In ->with('update exemplaires set shelf_key = (CASE WHEN (id = "1") THEN "0AMT_000R_0GER_0740_0001_0698_BOOK-OF-_BOOK_BOOK-OF-_0001" WHEN (id = "2") THEN "0AMT_000R_0GER_0740_0001_0698_BOOK-OF-_BOOK_BOOK-OF-_0002" WHEN (id = "3") THEN "0AMT_000R_0GER_0740_0001_0698_BOOK-OF-_BOOK_BOOK-OF-_0003" ELSE shelf_key END), shelf_key_update_date = \'2022-06-01 03:07:10\' WHERE id in (1,2,3)') ->answers(true) + ->whenCalled('execute') + ->with('update exemplaires set shelf_key = (CASE WHEN (id = "1") THEN "0000_0000_0000_0000_0000_0000_00000000_0000_00000000_0001" WHEN (id = "2") THEN "0000_0000_0000_0000_0000_0000_00000000_0000_00000000_0002" WHEN (id = "3") THEN "0000_0000_0000_0000_0000_0000_00000000_0000_00000000_0003" ELSE shelf_key END), shelf_key_update_date = \'2022-06-01 03:07:10\' WHERE id in (1,2,3)') + ->answers(true) + ->whenCalled('execute') ->with('update exemplaires set shelf_key = (CASE WHEN (id = "1") THEN "0AMT_000R_0GER_0740_0001_0698_BOOK-OF-_BOOK_BOOK-OF-_0001" WHEN (id = "2") THEN "0AMT_000R_0GER_0740_0001_0698_BOOK-OF-_BOOK_BOOK-OF-_0002" ELSE shelf_key END), shelf_key_update_date = \'2022-06-01 03:07:10\' WHERE id in (1,2,3)') ->answers(true); @@ -105,7 +109,8 @@ abstract class PhaseItemsShelfKeyGenerationTestCase extends Class_Cosmogramme_In -class PhaseItemsShelfKeyGenerationBadPreviousPhaseTest extends PhaseItemsShelfKeyGenerationTestCase { +class PhaseItemsShelfKeyGenerationBadPreviousPhaseTest + extends PhaseItemsShelfKeyGenerationTestCase { protected function _getPreviousPhase() { return new Class_Cosmogramme_Integration_Phase(7); @@ -161,7 +166,8 @@ class PhaseItemsShelfKeyGenerationRunTest extends PhaseItemsShelfKeyGenerationTe -class PhaseItemsShelfKeyGenerationRunWithMysqlLoopTest extends PhaseItemsShelfKeyGenerationTestCase { +class PhaseItemsShelfKeyGenerationRunWithMysqlLoopTest + extends PhaseItemsShelfKeyGenerationTestCase { protected function _getPreviousPhase() { return (new Class_Cosmogramme_Integration_Phase(7.3)) @@ -199,4 +205,39 @@ class PhaseItemsShelfKeyGenerationRunWithMysqlLoopTest extends PhaseItemsShelfKe ', $this->_log_content); } -} \ No newline at end of file +} + + + + +/* hotline : https://forge.afi-sa.net/issues/184104 */ +class PhaseItemsShelfKeyGenerationWithNullValueTest + extends PhaseItemsShelfKeyGenerationTestCase { + + protected function _getPreviousPhase() { + return (new Class_Cosmogramme_Integration_Phase(7.3)) + ->beCron(); + } + + + protected function _buildResult(int $count) : array { + $result = []; + + for ($i = 1; $i <= $count ; $i++) + $result [] = + ['id' => $i, + 'id_notice' => $i, + 'cote' => null, + 'clef_chapeau' => null, + 'tome_alpha' => null, + 'clef_alpha' => null]; + + return $result; + } + + + /** @test */ + public function phaseShouldBeSevenDotThree() { + $this->assertTrue($this->_phase->isId(7.3)); + } +}