Skip to content

Updating troubles from v4 to 5.0.0 #73

@joeschi

Description

@joeschi

I had some troubles updating from cart_books 4.0.4 to 5.0.0 (Typo3 12.4.32, PHP 8.2, 8.3.)

a) Type Error
Uncaught TYPO3 Exception: array_values(): Argument #1 ($array) must be of type array, TYPO3\CMS\Extbase\Persistence\Generic\Qom\LogicalOr given | TypeError thrown in file /cart_books/Classes/Domain/Repository/BookRepository.php in line 46.
So I had to change Line 41 in BookRepository.php, cause Line 46 expects an Array

-            $constraints = $query->logicalOr(...array_values($categoryConstraints));
+            $constraints[] = $query->logicalOr(...array_values($categoryConstraints));

b) Error in Viewhelper
Uncaught TYPO3 Exception: Call to undefined method TYPO3\CMS\Extbase\Domain\Model\Category::getCartBookShowPid() | Error thrown in file /cart_books/Classes/ViewHelpers/Link/BookViewHelper.php in line 85.
The domain model of cart_books v5 uses traits in the cart extension for the getters and setters of categories. That doesn't work, i don't know why.
So i used the old file cart_books/Classes/Domain/Model/Book.php from version 4.0.5 and the error was gone.

c) The images of my book records were gone
The reason are changes in TCA for the field 'image'. So i had to run a database query:

UPDATE sys_file_reference SET fieldname = 'images', table_local = '' WHERE `tablenames` = 'tx_cartbooks_domain_model_book' AND fieldname = 'image';

d) The category of book records were gone
Changes in TCA too. The setting ‘category’ => [ ‘config’ => [ ‘type’ => ‘category’, ‘relationship’ => ‘oneToOne’, ], causes the UID of the category to be saved directly in the category field (and no longer via table sys_category_record_mm)
So i ran an database update

UPDATE tx_cartbooks_domain_model_book mybook
SET category = (
SELECT uid_local
FROM sys_category_record_mm
WHERE tablenames = 'tx_cartbooks_domain_model_book'
AND uid_foreign = mybook.uid
GROUP BY uid_foreign
);

After than i deleted the records in mm table

DELETE FROM sys_category_record_mm WHERE  tablenames = 'tx_cartbooks_domain_model_book' AND fieldname = 'category';

Because of a) and b) you could perhaps check the code. And for c) and d) an upgrade wizard would be nice, or a note in the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions