In function context_ui_editor_submit() on line 353 of context_ui.module we are cloning $values['context'] for later comparison against form values to check to see if a context has been edited in the UI before saving. In php 5.3 this is a "shallow" clone - the pointers to the original object are preserved - so when in the next line the $values array is run through context_ui_editor_process() in some cases both the original and cloned object are affected. This creates a situation in which users are unable to edit a context through the UI.
The attached patch "solves" this by serializing and unserializing the cloned object before context_ui_editor_process() is run, thus breaking the pointers. It is a terrible solution and should absolutely not be committed.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | context-786542.patch | 3.48 KB | steven jones |
| #1 | php53clonefailpatchfail.patch | 1014 bytes | rsoden |
| php53clonefail.patch | 938 bytes | rsoden |
Comments
Comment #1
rsoden commentedPatching from the root of context, not context_ui.
Comment #2
steven jones commentedAccording to the PHP docs:
http://www.php.net/manual/en/language.oop5.cloning.php
and the comments:
http://www.php.net/manual/en/language.oop5.cloning.php#89321
it would seem that the context objects should implement a
__clonemethod:Comment #3
steven jones commentedThe cleanest way to implement this is to add a new 'base' object for context to base everything else off. Views does exactly the same, so I guess we're following a well worn path.
Comment #4
yhahn commentedlol
Comment #5
yhahn commentedBoth fixes (cloning fix for plugin objects, fix for context objects) committed here http://drupal.org/cvs?commit=371258.
Not implemented through a base class atm, I think there is more work to do to concept a singular base class for conditions/reactions.