| Comment | File | Size | Author |
|---|---|---|---|
| #51 | interdiff.txt | 812 bytes | slashrsm |
| #51 | 2763529_51.patch | 26.78 KB | slashrsm |
| #49 | interdiff.txt | 7.84 KB | slashrsm |
| #49 | 2763529_46.patch | 27.14 KB | slashrsm |
| #46 | interdiff.txt | 7.84 KB | slashrsm |
| Comment | File | Size | Author |
|---|---|---|---|
| #51 | interdiff.txt | 812 bytes | slashrsm |
| #51 | 2763529_51.patch | 26.78 KB | slashrsm |
| #49 | interdiff.txt | 7.84 KB | slashrsm |
| #49 | 2763529_46.patch | 27.14 KB | slashrsm |
| #46 | interdiff.txt | 7.84 KB | slashrsm |
Comments
Comment #2
slashrsm commentedComment #3
samuel.mortensonRe-roll.
Comment #4
samuel.mortensonComment #5
slashrsm commentedComment #6
samuel.mortensonSorry to tack this on, but DropzoneJS will still have fatal errors now that we've committed #2366335: Support defining conditions. Here's a new patch.
Comment #8
marcoscanoI can confirm there is a fatal in dropzonejs (or File Entity Browser) without the patch, and that the patch in #6 applies and functionally solves the problem (everything works fine again after applying it).
Comment #9
slashrsm commentedPatch needs a re-roll. Entity browser changed signature of the
prepareEntities()again.Comment #10
samuel.mortensonFixed per #9.
Comment #11
slashrsm commentedComment #12
samuel.mortensonThis isn't quite right - prepareEntities needs to return entities and right now it returns an array type that DropzoneJS uses to load File Entities. Doing one more re-roll with more manual testing this time.
Comment #13
samuel.mortensonLast review, promise. :-)
Comment #14
duneblI confirm that this patch solve the 'prepareEntities' problem.
But I don't know if it is related to another change in entity browser but I get a new problem:
Fatal error: Call to a member function getStorage() on a non-object in .../modules/dropzonejs/modules/eb_widget/src/Plugin/EntityBrowser/Widget/MediaEntityDropzoneJsEbWidget.php on line 100This error appears at the last stage of the setting up of the browser:
admin/config/content/entity_browser/my_browser/widgetsIf it is not related, I can create a new bug report.
Thanks you for your hard work!
Comment #15
duneblSome more info:
Comment #16
leksat commentedReplaced
entityManagerwithentityTypeManagerto fix the error described in #14.Comment #17
primsi commentedTested manually and works fine. Will wait a bit more for additional feedback and then commit.
Comment #18
duneblmarvelous, this is perfect! works fine!
Comment #19
slashrsm commentedThere are few other changes that happened in EB. We also need to update media entity widget.
#2767867: Chase changes in entity_browser could be used as the inspiration. Note that that patch doesn't save media entities to prevent duplicates from being created. Not sure if that is the right way to go. I'd love to hear @samuel.mortenson's opinion on this.
Comment #20
samuel.mortensonThe docs for "prepareEntities" describe the method as something that "Prepares the entities without saving them", which is why I wrote it the way I did for this patch. Otherwise you might see strange behavior with multiple calls to that function during one bootstrap or form "session" (i.e. multiple calls to validate over multiple bootstraps).
I'm updating
DropzoneJsEbWidget::getFormto match the recent widget-button changes, and doing manual testing as well. Should have a new patch today.Comment #21
samuel.mortensonNew patch.
Comment #22
duneblI have not made a deep testing, but before this patch, my select button was gone... Now it is ok!
Thank you for your hard work!!!!
Comment #23
slashrsm commentedWe should re-implement prepareEntities() in MediaEntityDropzoneJsEbWidget to return media entities and not files (which is what inherited function does at the moment).
Comment #24
samuel.mortensonIf we re-implement prepareEntities(), we would also have to re-implement the validation logic that the parent class uses, or would have to have two prepareEntities() functions - one for the submit callback and one for the validate callback. I'm not sure what the cleanest way to do this is. I guess the question here is - should the MediaEntityDropzoneJsEbWidget widget validate Files, Media Entities, or somehow both?
Comment #25
slashrsm commentedValidating media entities is the most obvious choice I think. If the entity type constraint is provided to the Entity browser then validation won't even pass if we validate files, right?
Comment #26
mtodor commentedI have looked also in this issue and it's a bit tricky to get clean solution for prepareEntities() that will return media entities.
Problem is related with 'media_entity' module dependancy, because when that module is not enabled, files will still be uploaded and saved. I don't know is that wanted functionality or not, but best would be that media entity drop zone can't work without that module at all. Then you have clean solution for prepareEntities() that always returns media entities and there is no need for check in submit(), etc.
Regarding validation, I think it should be sufficient to trigger media entity validation, file size/extensions will be anyway checked when file is dropped in zone, based on configuration defined for that widget in EB. So validate() should be re-implemented too and it can be same as in base widget, I guess.
btw. code in DropzoneJsEbWidget.php:
if ($trigger['#value'] == 'Select') {will not work nice, it would be better to use something else, for example:
if ($trigger['#name'] == 'op') {Comment #27
slashrsm commentedYes, this widget doesn't make any sense if media_entity is disabled. Will it help if we update the plugin to declare the module as its dependency? I am not sure how exactly that works, but I think that this dependencies should bubble up to the main config entity which should then require the module.
Comment #28
primsi commentedThe media entity eb widget should be a separate submodule, or handle the dependency in a different way. I am not sure why we didn't do it like that in the first place (probably because it was more of a quick and dirty thing we started with).
Comment #29
mtodor commentedI agree, cleanest solution would be separate submodule with properly defined dependencies.
Comment #30
slashrsm commentedI'd like to prevent further fragmentation. Having a gazillion of submodules will make the (already complex) ecosystem even harder to understand. I'd even go into the opposite direction. Ideally I'd like to see plugins moved into the main dropzone module and dropzone_eb_widgets being removed altogether.
If plugins correctly provide dependencies that they need (see patch) we can filter the ones with missing dependencies out before displaying them in the UI. Would that work?
I think that we should solve this in a separate issue.
Comment #31
mtodor commentedThat is possible solution too, only thing that I don't like is coupling of things that potentially will never be used, but that's meaning of plugins.
In that case two tickets are needed:
1. entity browser should be aware of widget dependencies
2. move plugins into dropzonejs module (remove submodule(s))
I have tested patch and it works.
More or less functionality is same as for #21 and I have just adjusted "if" statement otherwise we have dead code there.
Comment #32
slashrsm commentedMedia entity widget needs to be updated to work with media entities instead of files. It turned out this was trickier than expected, but I think that I managed to make it work.
Comment #33
mtodor commentedI have tested changes from #32, it works for me.
Regarding code:
Can $file be changed in process when it's assign to entity field?
If yes, then it would be nice to make that line more readable (split in 2 lines or assign result from file_move to entity field directly and then assign $file from it).
Is there need for redeclare of prepareEntities() to be public (because it's defined protected in interface)?
And also code that is commented out should be removed.
Nice work!!!
Comment #34
royal121 commentedTo test this, I installed the latest Entity Browser module and Dropzone. I tried adding the Media entity Dropzone widget to an Entity browser. I received the following error without the patch:
After applying the patch:
After I installed the media entity module:
I cleared the cache, rebuild the router and also re-installed all these modules but still received the same error.
Comment #35
mtodor commented@royal121 - did you create any media bundle?
Because you need at least one to be available for selection when you create Media Entity DropzoneJS widget.
Comment #36
slashrsm commentedI was discussing this with @primsi today. It seems that we introduced a regression at some point. Dropzone should take care about moving files from temporary folder. We will look at this and update the patch.
Comment #37
slashrsm commentedThis should be much nicer solution. Also fixed few code sniffer's complains.
Comment #38
slashrsm commentedTo do this we need to change behaviour of upload save service. It currently returns FALSE if there is an error while it should throw exceptions IMO.
But this is not the scope of this issue.
Comment #39
mtodor commentedI did quick check of patch (not full review):
PHP complains in this case, because variable should be passed as reference.
And execution of this line triggers warning for me:
Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 227 of ../core/lib/Drupal/Core/Entity/EntityStorageBase.php).In this case $ids is array with one element and it's NULL. Here is shortened stack trace:
And with same setup I don't get any errors with #32 patch.
Comment #40
slashrsm commentedThanks!
#39.1 - Fixed
#39.2 - One possible source of this (and an actual bug in validation) fixed. However, I am not sure if this was the real source. Could you make sure to test this on a clean install with file systems permissions set correctly? Could you also provide more detailed steps to reproduce it?
Comment #41
dagmarComment #42
primsi commentedI have tested this today and overall looks great. We can wait for additional feedback but I think we are almost done here.
Comment #43
berdirJust some questions/thoughts, I don't know the surrounding code too well.
I thought per-user size was removed in Drupal 6 or so, who would re-add this, dropzone specific?
storing those files makes things a bit more complicated, I guess that's needed because getFiles() is called more than once?
hm, avoing the bundle property should be easier, though. is it really worth statically caching that?
config entities do optionally support static cache, you just have to enable it. trying to enable it by default showed a few side effects though that we haven't yet figured out (that's why it didn't happen).
also, the config objects themself are already statically cached.
I haven't checked how often this is saved vs not, but maybe instead of an optional argument, saving could be done by the caller if it is only a few cases. a different name might also make sense then.
Comment #44
dawehnerI worked with this patch the entire day and it seemed to work quite well.
Comment #45
ada hernandez commentedCould @dawehner please share which versions about the dependencies of media entity are using, I want to use media entity, I have some errors with the combinations of modules, thks
Comment #46
slashrsm commentedThank you for the review!
#43.1 - Removed @todo
#43.2 - Yes, I wanted to avoid validate callback in the widget and generic validators code in the base widget class to run on different entities. For paranoia sake mostly....
#43.3 - Refactored and bundle property is now gone.
#43.4 - Makes sense. It is used only here AFAIK. Lightning could potentially use it, but I checked and it seems that they do not. Removed save option and renamed the function.
I also figured out that now Media entity creates new file for thumbnail since the main file is not saved yet when thumbnail stuff happens. We end up with two file entities sharing the same URI (which is strange since there is a unique constraint on URI...). Added workaround for now. This should be fixed in ME, but the problem is that this logic happens in plugins (image, audio, document, ...).
@Adita: latest -dev of all relevant modules (Entity browser, Entity embed, Media entity, Media entity image, ...) should do the job.
Comment #49
slashrsm commentedWrong patch.
Comment #50
berdirAnd so God spoke: "Though shall be a file". And so it was.
I think you removed a bit too much here :) (or more likely, didn't replace with something else)
Comment #51
slashrsm commentedIt turns out I didn't remove enough. I moved entire body from fileEntityFromUri() to createFile() since it was the only caller.
Comment #52
rakesh falke commentedFacing issue WSOD while installing "File Browser" module.Confirm that 2763529_51.patch patch working properly to install module without any issue.
Comment #53
berdir@slashrsm: Fine from my POV. I haven't tested it but I think others did :)
Comment #54
dagmarI'm going to provide feedback about the behavior of this patch tomorrow if you want to wait for another review.
Comment #56
primsi commentedMerged. Thanks to all for this awesome work!
Comment #57
primsi commented