codefog / contao-haste

Haste is a collection of tools and classes to ease working with Contao
http://codefog.pl/extension/haste.html
MIT License
42 stars 24 forks source link

Error deleting things: "DcaRelationsManager.php line 61: Argument #2 ($fieldName) must be of type string, int given" #204

Closed Anke closed 1 year ago

Anke commented 1 year ago

Hi,

in a Contao 4.13.15 installation including Notification Center 1.7 with Haste 5 and PHP 8.1.14 I'm running into errors whenever deleting anything, e.g. a data field in catalog manager, a Contao template or a content-element.

The error messages are always referring to line 61 in DcaRelationsManager.php saying that "Argument #2 ($fieldName) must be of type string, int given":

[2023-02-05T13:45:51.671407+01:00] request.INFO: Matched route "contao_backend". {"route":"contao_backend","route_parameters":{"_route":"contao_backend","_scope":"backend","_token_check":true,"_controller":"Contao\\CoreBundle\\Controller\\BackendController::mainAction"},"request_uri":"https://xxx.com/contao?act=delete&do=catalog-manager&id=404&ref=G_Eim8vB&rt=aaeded050b52f9dcab7fe706120c3a.naCa-9zBXSC88R8pWyzMI8N8kX17gX7WuE-I7hCx_nM.xcjsrIimOhb9vEVTFR6EYvEP8joa1Q_g0znmul-CvDik6cO6jLtqQcilKw&table=tl_catalog_fields","method":"GET"} []
[2023-02-05T13:45:52.042321+01:00] request.CRITICAL: Uncaught PHP Exception TypeError: "Codefog\HasteBundle\DcaRelationsManager::getRelation(): Argument #2 ($fieldName) must be of type string, int given, called in /xxx/vendor/codefog/contao-haste/src/DcaRelationsManager.php on line 61" at /xxx/vendor/codefog/contao-haste/src/DcaRelationsManager.php line 721 {"exception":"[object] (TypeError(code: 0): Codefog\\HasteBundle\\DcaRelationsManager::getRelation(): Argument #2 ($fieldName) must be of type string, int given, called in /xxx/vendor/codefog/contao-haste/src/DcaRelationsManager.php on line 61 at /xxx/vendor/codefog/contao-haste/src/DcaRelationsManager.php:721)"} []
fritzmg commented 1 year ago

In theory you have a misconfigured DCA in your system. You should debug the DCA that is responsible for this.

derkosmonaut commented 1 year ago

While debugging I get this message:

[2023-02-06T10:39:39.711795+01:00] request.CRITICAL: Uncaught PHP Exception ErrorException: "Warning: Undefined array key 502" at /xxxxx/vendor/alnv/catalog-manager/library/alnv/CatalogView.php line 710 {"exception":"[object] (ErrorException(code: 0): Warning: Undefined array key 502 at /xxxxx/vendor/alnv/catalog-manager/library/alnv/CatalogView.php:710)"} []

@Anke You also use the Catalog Manager, right?

Anke commented 1 year ago

Yes, I'm also using Catalog Manager, which officially is compatible up to Contao 4.9 or so. However I'm getting the haste error deleting any element, not just CM fields. Everything was working fine until I updated the installation from 4.13.13 to 4.13.15 including some extensions, including notification center to 1.7, later downgrading notification center to 1.6 again, which didn't eliminate this new error.

fritzmg commented 1 year ago

This must be an error in the Catalog Manager then. It appears the Catalog Manager is creating DCA entries with fields that are indexed by integers instead of strings, which is not supported.

Anke commented 1 year ago

Yes, I believe so, too. Using the latest Catalog Manager 1 version and now set PHP down to 7.4 again, which resulted in Haste being downgraded to version 4 - and deleting stuff is possible again. Thank you for your help! @derkosmonaut: I'm closing this issue. I think you ought to place yours in the catalog manager repository.

k-webdesign commented 4 months ago

Hm, getting the same error in Contao 4.13.43 with the notification center and PHP 8.2. Originally NC v1.5 was installed, I tried upgrading in steps up to 2.0 but the frontend only works properly when I deinstall the notification center.

fritzmg commented 4 months ago

@k-webdesign use the debug mode and post the stack trace.