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

[Craft 5] Undefined array key when un-installing Neo (converting to Matrix fields) #972

Closed
naboo opened this issue Dec 10, 2024 · 1 comment

Comments

@naboo
Copy link

naboo commented Dec 10, 2024

Bug Description

When running ... craft plugin/uninstall neo the Conversion.php at row 174 sometimes throws this exception:

Exception: Undefined array key "companyBonusEntry" (/var/www/html/vendor/spicyweb/craft-neo/src/services/Conversion.php:174)

My guess is that maybe the related matrix block has yet to be created - or is just missing?

For testing purposes I modifed the source to the following code:

if ($relations) {
                foreach ($relations as $relation) {
                    $neoBlockId = $relation['sourceId'];
                    $matrixEntryId = $neoToMatrixElementIds[$neoBlockId];
                    $matrixEntryTypeId = $matrixEntryTypeIdsByEntryId[$matrixEntryId];
                    $globalFieldId = $relation['fieldId'];
                    $globalField = $globalFields[$globalFieldId];
                    $matrixFieldIds = $matrixEntryTypeFieldIds[$matrixEntryTypeId];
                    $matrixFieldId = $matrixFieldIds[$globalField->handle] ?? null;

                    if(is_null($matrixFieldId))
                        continue;

                    $newRelations[] = [
                        $matrixFieldId,
                        $matrixEntryId,
                        $relation['sourceSiteId'],
                        $relation['targetId'],
                        $relation['sortOrder'],
                    ];
                }
            }

... and I can't see that anything contentwise is missing or not working. But I haven't gone through everything of course so maybe there is some implication anyways.

Anything that can be fixed?

Steps to reproduce

  1. Uninstall Neo

Expected behaviour

Uninstallation goes through without the exception

Neo version

5.2.1

Craft CMS version

5.5.5

What is the affected Neo field's propagation method?

No response

Does this issue involve templating, and if so, is eager-loading used?

This is not a templating issue

@ttempleton ttempleton added bug report status: confirmed A bug report that has been reproduced by the maintainer(s), but has not yet been fixed and removed bug report status: new labels Dec 18, 2024
@ttempleton
Copy link
Contributor

Thanks for reporting that - fixed now in 5.2.21.

@ttempleton ttempleton added bug report status: fixed and removed bug report status: confirmed A bug report that has been reproduced by the maintainer(s), but has not yet been fixed labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants