Thanks to visit codestin.com
Credit goes to github.com

Skip to content

sync issue - new event steals attributes #2

@cvandeplas

Description

@cvandeplas

Reported by Christophe Vandeplas, Nov 9, 2012

Steps to reproduce the problem:

  1. Create event with attributes: E1 with A1, A2,
  2. Using REST API add new event E2 with other uuid as E1, but with
    attributes with same UUID as A1.

Expected result:

  • new event E2 is created, and contains all the attributes.
  • original event E1 is left untouched

Actual result:

  • new event E2 is created, and contains all the attributes.
  • original event E1 lost it's attribute A1

Comment 1 by Christophe Vandeplas, Nov 9, 2012
Summary: sync issue - new event steals attributes

Comment 2 by Christophe Vandeplas, Nov 9, 2012

The bug is in EventsController.php line 280-290.

            if (isset($data['Attribute'])) {
                foreach ($data['Attribute'] as $attribute) {
                    // ..do some
                    $existingAttributeCount = $this->Event->Attribute->find('count', array('conditions' => array('Attribute.uuid' => $attribute['uuid'])));
                    if ($existingAttributeCount > 0) {
                        $existingAttribute = $this->Event->Attribute->find('first', array('conditions' => array('Attribute.uuid' => $attribute['uuid'])));
                        $data['Attribute'][$c]['id'] = $existingAttribute['Attribute']['id'];
                    }
                    $c++;
                }
            }

The find('count') only searches for UUID, and not UUID event_id
combination.

Multiple solutions are possible:

  • allow duplicate UUIDs for attributes, and keep event_id-uuid as
    uniqueness : however this is not very clean as we then have
    different uuids
  • regenerate a new UUID, however this might cause problems with
    later syncs.

Comment 3 by Christophe Vandeplas, Nov 9, 2012

In all cases this bug needs to be solved, as it creates a way where
someone can steal someone elses attributes.

Comment 4 by Andras Iklody, Dec 11, 2012

another solution,
now we have event::attribute being 1::n,
given the use described this should (or could) be
event::attribute n::m.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugType: bug report: This issue describes unexpected behaviour

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions