Skip to content

tests/TagsWithSameValueTest.php not adressing the problem #14

@Maturion

Description

@Maturion

Sorry if the title of this issue sounds a bit harsh. I'm not a native English speaker, so no offense intended. ;)

I have recently submitted issue #12 and you created the TagsWithSameValueTest.php test class for verifying that. I can indeed confirm that my original issue does not occur in this test class.

Puzzled by this, I tried around a bit and found out that my original problem does not occur when creating a new node (This is what's being done in TagsWithSameValueTest.php). It only happens when you are editing an existing node.

The cause of this behaviour is the following:
array_diff($this->getTags(), $set) does compare $this->getTags() and $set.

Values are assigned to $set this way:

$set = array();
            for ($i = 0; $i < $tags->length; $i++) {
                $key = $tags->item($i)->getAttribute('k');
                $val = $tags->item($i)->getAttribute('v');
                $set[$key] = $val;
            }

$set contains the values of an object before your new ChangeSet is applied. Hence when you create a new object, $set is empty and array_diff($this->getTags(), $set) will save two tags with the same value. However, when you're editing an existing object, $set is not empty, and the output of array_diff will indeed not contain two tags with the same value.

I didn't submit a pull request because I'm not sure wether this problem can be replicated without changing "real" data on the OSM database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions