Closed (fixed)
Project:
Collect
Version:
8.x-1.x-dev
Component:
Storage
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
27 Mar 2015 at 08:11 UTC
Updated:
27 Oct 2015 at 11:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
miro_dietikerComment #2
arla commentedIn the current state, this feature would help with
A potential complication is that this might not be logically well covered by the FieldDefinition plugin (already in the name there is a mismatch). Perhaps it's in order to create a new entity-focused definition plugin, just like we are already considering for CollectJson/EntityJson. Discussable.
Comment #3
mbovan commentedProviding a first patch...
Added bundle data to the fields definition container (in case there is a bundle).
Serialized bundle (e.g article) data looks like:
Now, we have some more information about the bundle (like name, description etc.) that are used in recreation.
Do we need uuid in the bundle data? Currently, it is unset during bundle recreation, but it might be removed on the client, before serialization?
Comment #5
mbovan commentedSmall test improvement and fix.
Comment #7
mbovan commentedBut first, we need to add description to assert it. :)
Comment #9
miro_dietikerThis can return NULL and you don't consider it.
Other than that, looking good.
Comment #10
mbovan commentedActually, in
CreateMissingFieldsController::checkAccesswe callgetMissingFields()which callsgetContainerTypedData(). If it fails, the button "Create missing fields" won't be displayed, so I think in current design there is no case that button is displayed and$field_definition_container_idor$typed_dataisnull.Based on this, I would only change
getContainerTypedData()doc comment.Comment #11
LKS90 commentedThere is an exception when I try to recreate an entity without first recreating it's content type. I'd say catch that exception (as discussed).
Comment #12
mbovan commentedThanks for the review. :)
Yes, that's a bug as we don't check if the bundle exists (in the current system) before reconstruction. Not directly related to this issue, but I guess we can fix it here.
This doesn't happen with the fields as we skip them if they are not available in the current system.
Providing a fix... I added a check for the bundle before entity reconstruction and displaying an error if it is the case. Maybe we can change the message... I was thinking about adding a link to the model plugin (the page where we create missing bundle/fields), but then we should load the model just to display the url of it, so skipping it for now.
One of the options (for the follow-ups) could be to move
CreateMissingFieldslogic to the service, so we can call the method to create missing bundle/fields in this case. Discuss.Added tests for the bug...
Comment #14
LKS90 commentedWorks as intended.
Btw: I thought you'd just catch the exception, but your solution is definitely nicer. What I had in mind:
Edit: Almost forgot, can you create a (Meta) Issue with the follow-up issues?
Comment #15
mbovan commentedYes, there are lot of expensive operations after it, so I don't think we should go that deep...
Regarding follow-ups, not sure if suggestions about automatic missing bundle/fields creation is the Collect-way of doing it... :)
I'll wait for some feedback about it and then we can open (followup) issues.
Comment #16
miro_dietikerYes, would love to commit this. Here some clarifications about the concepts.
OK the bundle key is thus missing if an entity has only a default bundle. Can these really be properly reconstructed? We need a test case for reconstructing an entity without a bundle.
Also i think we should additionally persist entity type as key and not match them from the URL.
Then this should not consider matches at all. Instead it should be loaded from the data.
Finally there are lots of lines like this in collect:
When persisting entity type and bundle to the container, we should no more consider the SchemaUri to match things. It should just be used for a lookup address. The original container then contains the actual (entity type and bundle) data. The reason is that we don't have any hardcoded assumptions anymore in the Schema URI except possibly for the auto schema suggestions.
Comment #17
mbovan commentedYes. If an entity type has only default bundle then we don't need to specify bundle when recreating. Adding a test in this patch.
Added entity type as a part of field definitions data.
Not sure if we want to have those information in values container instead of fields definition or in both? In field definition container we can have normalized bundle data and entity type and in values container only entity type id and bundle key?
As now, when we have values container and want to get container entity type and bundle key, we have to:
- Load a model
- Find a field definition container ID
- Load a field definition container
- Call typed data service and get typed data
- Get parsed data and access the 'entity_type' and 'bundle' elements,
I'll wait for some opinions about this before making the changes in other classes that use
matchSchemaUri(). By the way, in CreateEntityController we load the typed data withFieldDefinition::getContainerTypedData($model). If it fails we throw 404.Do we need to add one more
elseifcondition between, so we usematchSchemaUri()as a fallback in case typed data fails. Also not sure when this case is possible. though.Comment #19
mbovan commentedTest fails are not related to this issue. They will be fixed in #2554445: Tests broken due to core change safemarkup::XssFilter()
Comment #22
giancarlosotelo commentedRebase needed.
Comment #23
mbovan commentedRerolled.
Comment #26
mbovan commentedTested locally. All test fails are related to #2580413: Remove target_bundle setting from Collect Demo config files. Uploading a rerolled patch after #2578899: Title block core change.
Comment #27
giancarlosotelo commentedLooks good.
Comment #28
arla commentedCame up with a few review comments. They're mostly DX and UX, nothing super important, and I'm fine with committing without them too.
I think the FieldDefinition plugin should offer the bundle data and entity type ID as properties, just like it does with
['fields']. Then this can be$bundle_data = $typed_data->get('bundle').I suppose the point here is to assert that you can recreate an entity whose bundle is not missing? Perhaps that should be stated clearly in a comment.
Please clarify: what container, and why does it have to be found?
It would be helpful if this error message contained some instructions on how to recreate the bundle. Like "use the 'Create entity' button" or whatever makes the most sense in this context.
Comment #30
mbovan commentedApplied the suggestions above.
Comment #35
mbovan commentedTest are failing because of #2575869: Remove all remaining usage of deprecated UrlGeneratorInterface::generateFromPath() and delete it. Should be fixed in #2582989: Core Change remove generatefrompath() from core.
Comment #38
mbovan commentedComment #39
arla commentedThe testbot run is passing (although it says "Queued for testing" in the comment) but it failed on DrupalCI. I'm not sure about the error message, "The test did not complete due to a fatal error", what is that about?
Comment #40
mbovan commentedFrom the logs:
It seems more related to #2582989: Core Change remove generatefrompath() from core.
Uploading again to see the results. (rerolled)
Comment #42
arla commentedOkay, looks good. Committed, with the attached minor change. (ControllerBase has a special take on service injection...)
Comment #43
arla commentedThe change I made.