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.

Comments

rsoden’s picture

StatusFileSize
new1014 bytes

Patching from the root of context, not context_ui.

steven jones’s picture

Status: Active » Needs work

According 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 __clone method:

  function __clone() {
    foreach ($this as $key => $val) {
      if (is_object($val) || (is_array($val))) {
        $this->{$key} = unserialize(serialize($val));
      }
    }
  }
steven jones’s picture

Status: Needs work » Needs review
StatusFileSize
new3.48 KB

The 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.

yhahn’s picture

lol

yhahn’s picture

Status: Needs review » Fixed

Both 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.