Closed (fixed)
Project:
Entity API
Version:
7.x-1.x-dev
Component:
Entity CRUD API - UI
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
18 Nov 2010 at 17:03 UTC
Updated:
9 Dec 2010 at 17:00 UTC
Jump to comment: Most recent file
Comments
Comment #1
fagoLooks good. However, what's the purpose of having export without an "import" page? I guess we should only add all at once, as the UI is already used by modules. Probably we should do it like views in d7, provide another action link for creating new entities by import.
Comment #2
klausiRight, here is a new patch with an import action link included.
Open issue: ID or machine name clashes when an entity with same ID/name already exists in the DB.
Comment #3
klausiImproved patch that validates imported entities before saving. Fixed a WSOD in entity_id() on the way when it is called with an invalid non-object entity.
Comment #4
klausiEven better: in entity_id() we just check for the identifier() method in the actual $entity object, that works for invalid $entity variables and for subclasses of the specified entity class as well.
Comment #6
klausi#4: 975758-entity-import-export.patch queued for re-testing.
Comment #7
klausiMinor change, added a description for the export text area.
Comment #8
fagoLet's set this to a fixed, but high value.
This won't work generically, e.g. Rules implements an export using JSON. I guess the entity API misses an entity_import() function + a respective entity controller method.
Comment #9
fagohm, also eval() is problematic as we need to implement a new "eval php" permission for that. Perhaps we should just stick to the json export by default? The entity API has already an API function to print beautified JSON.
An option like views has in 7.x would be nice too. "checkbox: Allow overwriting existing configurations" or such.
Comment #10
fagoResults of discussion: We really need something like entity_import($entity_type, $export_code) - which takes the export and returns an entity as expected by the default hook. For security, we go with JSON by default.
Comment #11
fagorelated: #978832: enable modules to apply configuration (exportable entities)
Comment #12
klausiI agree, we avoid implementing complicated PHP execution permissions and we avoid a huge security risk by using JSON. New patch that addresses all that concerns.
Comment #13
klausiOh, I forgot: this patch contains a tiny API change for the create() functions so that $values always has to be an array (again saving as from nasty WSODs)
Comment #14
klausiAnd i forgot to change the Features export rendering, here is an updated patch that uses PHP heredoc syntax to store the JSON export. entity_import() is used to create entity objects from that strings.
Comment #15
klausiSmall improvement: avoid using a foreach loop in the Features rendered export.
Comment #16
fagoLet's use "identifier" instead of ID.
These or this data is the question.. ;)
I think it should be @entity, as it makes not much sense to me to mark entity as a placeholder. For the label though it does. It is already that way in the existing code though, so this should be probably another issue.
The logic in
operationFormValidate()looks a bit complex to me, perhaps it can be simplified? Not sure.reset(entity_load($this->entityType, array($id)));This will produce warnings or notices on some platforms as reset() takes the argument by reference.
Previously the return was valid PHP but that changed now. We need to document what entity_export() is supposed to return.
We may only add this menu item if the entity is exportable.
Comment #17
klausiGood points, I addressed nearly all of them. Only '%' vs. '@' is still open, but should probably be a separate issue.
Comment #19
klausiRight, the test case needs a minor fix to deal with JSON.
Comment #20
fagoLooks good, I gave it a test with profile2.
When export the default profile + importing it with overwrite enabled I got:
Then I got the message:
>Imported Profile type Profile.
-> but profile type should start lower case there - that applies to any sentence where it is not in the beginning. I wonder though how that is supposed to work for translations?
>entity_ui_import_title()
This seems to somehow duplicate entity_ui_get_page_title() ?
>applyOperation() + others
It's getting increasingly confusing which operation is handled by what, in particular with import+export being sometimes handled by the same functions, but in sometimes not (applyOperation). I guess we should document that better.
Comment #21
klausi* Fixed the notice when overwriting default entities with an import.
* Unified the duplicate page/menu title functions.
* Improved documentation on applyOperation() and operationForm() with hints for the export operation.
I'm not sure regarding the lower casing of entity type labels, I left that open as it affects other status messages as well and should probably handled in a separate issue (not import/export specific)
Comment #22
fagogreat! Committed it, thanks!
See #981786: UI: bad casing of translation replacements for the text follow-ups.