Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array to string conversion in the product picker #2340

Closed
ameotoko opened this issue Jul 24, 2022 · 1 comment · Fixed by #2341
Closed

Array to string conversion in the product picker #2340

ameotoko opened this issue Jul 24, 2022 · 1 comment · Fixed by #2341

Comments

@ameotoko
Copy link
Contributor

ameotoko commented Jul 24, 2022

Contao 4.13.6, Isotope 2.8.5, PHP 8.1

Exactly the same problem as in #2324. It happens in backend when you go to the related products of a product, and then edit the category.

ErrorException:
Warning: Array to string conversion

  at vendor/contao/core-bundle/src/Resources/contao/classes/DataContainer.php:1715
  at Contao\DataContainer->generateRecordLabel(array('id' => 108, 'pid' => 0, 'images' => 'a:1:{i:0;a:5:{s:3:"src";s:20:"image.jpg";s:3:"alt";s:0:"";s:4:"link";s:0:"";s:4:"desc";s:0:"";s:9:"translate";s:4:"none";}}', ...), 'tl_iso_product')
     (vendor/contao/core-bundle/src/Resources/contao/widgets/Picker.php:296)
  at Contao\Picker->renderLabel(array('id' => 108, 'pid' => 0, 'images' => 'a:1:{i:0;a:5:{s:3:"src";s:20:"image.jpg";s:3:"alt";s:0:"";s:4:"link";s:0:"";s:4:"desc";s:0:"";s:9:"translate";s:4:"none";}}', ...), object(DC_ProductData))
     (vendor/contao/core-bundle/src/Resources/contao/widgets/Picker.php:261)
  at Contao\Picker->generateValues(true)
     (vendor/contao/core-bundle/src/Resources/contao/widgets/Picker.php:123)
  at Contao\Picker->generate()
     (vendor/contao/core-bundle/src/Resources/contao/library/Contao/Widget.php:652)
  at Contao\Widget->generateWithError(true)
     (vendor/contao/core-bundle/src/Resources/contao/templates/backend/be_widget.html5:3)
  at include('/Users/andrey/Sites/schlossakademie/vendor/contao/core-bundle/src/Resources/contao/templates/backend/be_widget.html5')
     (vendor/contao/core-bundle/src/Resources/contao/library/Contao/TemplateInheritance.php:108)
  at Contao\Widget->inherit()
     (vendor/contao/core-bundle/src/Resources/contao/library/Contao/Widget.php:599)
  at Contao\Widget->parse()
     (vendor/contao/core-bundle/src/Resources/contao/classes/DataContainer.php:788)
  at Contao\DataContainer->row('{category_legend},category;{products_legend},products')
     (vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php:1946)
  at Contao\DC_Table->edit()
     (vendor/contao/core-bundle/src/Resources/contao/classes/Backend.php:667)
  at Contao\Backend->getBackendModule('iso_products', null)
     (vendor/contao/core-bundle/src/Resources/contao/controllers/BackendMain.php:168)
  at Contao\BackendMain->run()
     (vendor/contao/core-bundle/src/Controller/BackendController.php:49)
  at Contao\CoreBundle\Controller\BackendController->mainAction()
     (vendor/symfony/http-kernel/HttpKernel.php:152)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:74)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:202)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:44)

(irrelevant product data has been cut out)

This happens when Contao tries to render the preview of the picker widget, i.e. this part:

Screenshot 2022-07-24 at 12 09 45

This has been already fixed for product list in 175a07f, but is not applied here, because rendering labels has been refactored into a separate method in Contao 4.13 (DataContainer::generateRecordLabel()), and the picker widget calls that method directly, which in this case resolves to the parent class, not DC_ProductData.

You cannot check it in the demo because it uses Isotope 2.7 (no picker widget) and Contao 4.9 (no separate method).

I'll provide a PR.

@aschempp
Copy link
Member

aschempp commented Jun 2, 2023

see #2341

@aschempp aschempp closed this as completed Jun 2, 2023
leofeyer added a commit to contao/contao that referenced this issue Jul 28, 2023
Description
-----------

I have fixed this issue in Isotope core previously in isotope/core#2324, but now realized this is actually a Contao bug to me. This issue resurfaced in isotope/core#2340 because of the new `DataContainer::generateRecordLabel`, which overrides the default Isotope label fix.

Commits
-------

800d1a4 Recursively implode fields when generating record labels
90348f9 Use a recursive iterator to implode the array

Co-authored-by: leofeyer <1192057+leofeyer@users.noreply.github.com>
leofeyer added a commit to contao/core-bundle that referenced this issue Jul 28, 2023
Description
-----------

I have fixed this issue in Isotope core previously in isotope/core#2324, but now realized this is actually a Contao bug to me. This issue resurfaced in isotope/core#2340 because of the new `DataContainer::generateRecordLabel`, which overrides the default Isotope label fix.

Commits
-------

800d1a42 Recursively implode fields when generating record labels
90348f9a Use a recursive iterator to implode the array

Co-authored-by: leofeyer <1192057+leofeyer@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants