Page MenuHomePhabricator

The wbeditentity API seems to overwrite labels/descriptions even with the "add" parameter (that should preserve them)
Open, Needs TriagePublic

Description

Prehamble

Knowing that the wbeditentity API module can be used to save a label/description, and that the add parameter can be used to don't overwrite an existing label/description, in the following way:

{
    "labels": [
        {
            "language": "en",
            "value": "English label that will be added without overwriting. It works!",
            "add": "1"
        }
    ]
}

...and knowing that the same API module can be used also to create claims, in the following way:

{
    "claims": {
        'P123': [ some statements on this property ]
    }
}

Bug

Apparently only when doing both the actions in the same request (creating claims and adding unexisting labels/descriptions), it seems to ignore the add parameter, and labels/descriptions are overwrited.

As an example, look at this diff:

You can note that labels were overwrited. But this was the data (note the add parameters) related of that save:

{
    "labels": [
        {
            "language": "en",
            "value": "Milos Culafic",
            "add": "1"
        },
        {
            "language": "it",
            "value": "Milos Culafic",
            "add": "1"
        }
    ],
    "descriptions": [
        {
            "language": "en",
            "value": "Montenegrin volleyball player",
            "add": "1"
        },
        {
            "language": "it",
            "value": "pallavolista montenegrino",
            "add": "1"
        }
    ],
    "claims": {
        "P18": [
            {
                "type": "statement",
                "rank": "normal",
                "references": [
                    {
                        "snaks": {
                            "P248": [
                                {
                                    "snaktype": "value",
                                    "property": "P248",
                                    "datatype": "wikibase-item",
                                    "datavalue": {
                                        "type": "wikibase-entityid",
                                        "value": {
                                            "entity-type": "item",
                                            "numeric-id": 16571730,
                                            "id": "Q16571730"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                ],
                "mainsnak": {
                    "snaktype": "value",
                    "property": "P18",
                    "datatype": "commonsMedia",
                    "datavalue": {
                        "type": "string",
                        "value": "Milos Culafic (Legavolley 2017).jpg"
                    }
                }
            }
        ],
        "P373": [
            {
                "type": "statement",
                "rank": "normal",
                "references": [
                    {
                        "snaks": {
                            "P248": [
                                {
                                    "snaktype": "value",
                                    "property": "P248",
                                    "datatype": "wikibase-item",
                                    "datavalue": {
                                        "type": "wikibase-entityid",
                                        "value": {
                                            "entity-type": "item",
                                            "numeric-id": 16571730,
                                            "id": "Q16571730"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                ],
                "mainsnak": {
                    "snaktype": "value",
                    "property": "P373",
                    "datatype": "string",
                    "datavalue": {
                        "type": "string",
                        "value": "Milos Culafic"
                    }
                }
            }
        ]
    }
}

As workaround, I have to don't rely on the add parameter on labels/descriptions and do some client-side decisions for them, like comparing the existing labels/descriptions values and skipping the existings.

Related Objects