-
Notifications
You must be signed in to change notification settings - Fork 96
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
FIX: Update model class importer key #1743
FIX: Update model class importer key #1743
Conversation
CMS 4 has entered its security-only support phase, and won't be getting any new patch releases. Please target the |
Is it fine to re-use the same branch name (and target |
If you retarget to |
fe80854
to
efc9f08
Compare
Marked this ready for review but some jobs on workflow still failing, do I need to re-run them until green? |
CI is green here: https://github.com/silverstripe/silverstripe-admin/actions/runs/9008788626 You can force a push without making any changes by running |
- using a custom URL slug throws exception due to non-existing key equivalent to the model class. Using model tab solves this since it utilises either the custom url slug or the fully-qualified name(FQN) of the class.
efc9f08
to
78eb177
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well locally. Looks like there's no unit test for the import()
method so I won't ask you to add that now.
Thank you for implementing this fix
Description
Using a custom URL slug throws an exception due to non-existing key equivalent to the model class. Using model tab solves this since it utilises either the custom url slug or the fully-qualified name of the class as key on the model importers.
This fixes the undefined array key exception e.g.
[Warning] Undefined array key "Sheadawson\Linkable\Models\Link"
seen when importing on a model admin with a custom URL slug.This should not have any regressions on model admins without custom slug.
Code clean-up on a test suite.
Manual testing steps
With custom url slug
Add a model admin and model class e.g.:
ContactAdmin
andContact
(model admin and model, respectively).Assign a custom slug to the model admin e.g.:
Once setup and viewable on the CMS, go to the ContactAdmin landing page on the CMS and import a file to populate the model. (Note: this can also be done by pre-populating the model and exporting the records as
.csv
file then re-uploading the same file via import)Import should not cause any exception.
Without custom url slug
Follow same steps above but do not assign a custom slug to the model admin i.e.
Using the import form should not generate any errors.
Issues
Pull request checklist