Closed (fixed)
Project:
Scald: Media Management made easy
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Oct 2015 at 12:59 UTC
Updated:
20 Oct 2015 at 07:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
gifad commentedAttached patch is just a workaround - the modal state identification could probably be detected more efficiently...
Comment #3
nagy.balint commentedI think that, that function has to run, as it is the one that creates the new Atom entity and such.
And we cannot check whether form state values is empty or not (outside of the hook), because the idea behind the hook in that function was that the provider decides how many entity it needs.
So in fact the issue is in the image provider and any provider that implements this hook, to not do something that can throw a notice.
So attached a patch that fixes this for the base providers.
Comment #4
nagy.balint commentedAlthough it seems i cant reproduce the problem here, as that code only runs if
if (empty($form_state['scald'])) {And form_state scald is not empty for me if i edit an atom.
So for me this situation never appears.
Any additional steps to reproduce?
Comment #5
nagy.balint commentedBecause in the
function scald_atom_edit_page($js, $atom) {It will use
ctools_object_cache_set('scald_atom', 'edit:' . $atom->sid, $scald);Which is then read
So in fact if you are editing atoms it cannot be empty.
Unless its possible to somehow avoid using that edit_page function and not have this cache.
Comment #6
gifad commentedThis call of
scald_atom_add_form_add_submit()is here for the case of atom creation, when the provider does not specify a specific add_form hook - so the add step is 'automatically' validated;In the case of the bug, we are just editing an existing atom, the edit has successfully completed, and
scald_atom_add_page()is called to finalize the ctools wizard; the real bug is that this call is made with the$atom_idargument set to NULL (instead of the actual atom id), and that confusesscald_atom_add_page(): the $cache_id is set to 'add', at line 57, so the cache is not retrieved, so the $form_state['scald'] is NULL, etc...Anyway, it does not make sense to submit a form without values, hence my simple patch...
--- cross posting , this is reply to #3
Comment #7
gifad commentedfresh install of scald suite
Comment #8
nagy.balint commentedI think that "scald_atom_add_page" should not be called when clicking the finish on the edit form, that might be the real bug.
But still checking.
Comment #9
gifad commented"scald_atom_add_page" should actually be called at this stage, but just for executing :
(around line 145)
Comment #10
nagy.balint commentedI see, then the bug is that it does too much in that step, maybe a code restructure is needed.
Comment #11
nagy.balint commentedWhen adding a new atom:
If the first step is options and not add, then form_state values will be empty.
Yet that function should run, because it will create the single atom entity or whatever the provider defines.
So then i think patch #2 breaks that.
Patch #3 would remove the notice, but it requires all providers to pay attention to it, and add issets.
Alternatively if we can detect that its just about to close and add that to the if, it could be a good solution as well.
Comment #12
nagy.balint commentedComment #13
nagy.balint commentedMaybe this patch will work.
The idea behind it is that when rendering the options form, we can check whether
$form_state['scald']['atoms']is empty or not. If its empty then very likely its not an edit form, and it had no first add step, as otherwise it would not be empty.
And then we can run that function.
Please test :)
Comment #14
nagy.balint commentedIn fact because of that we can spare one more line.
Comment #15
gifad commented#14 works for me with
Also ok with scald_gallery...
I had built another workaround, based on distinction between $step passed as argument vs $step computed, but #14 is far a better approach ;)
Comment #16
nagy.balint commentedGreat! Will commit tomorrow if no negative feedback til then :)
Comment #17
nagy.balint commentedComment #18
nagy.balint commentedThanks, Committed.