https://bugzilla.wikimedia.org/show_bug.cgi?id=38234
Web browser: ---
Bug #: 38234
Summary: wbsetitem api action returns invalid xml on error
Product: MediaWiki extensions
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: blocker
Priority: Unprioritized
Component: WikidataRepo
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Classification: Unclassified
Mobile Platform: ---
My bot gets an error message when parsing response of wbsetitem
This bug is not about the error itself but about the wrong return format:
Request:
http://wikidata-test-repo.wikimedia.de/w/api.php?action=wbsetitem&format=xml&item=add&data={%22label%22%3A{%22en%22%3A{%22language%22%3A%22en%22%2C%22value%22%3A%22Sina%22}%2C%22de%22%3A{%22language%22%3A%22de%22%2C%22value%22%3A%22Sina%22}%2C%22la%22%3A{%22language%22%3A%22la%22%2C%22value%22%3A%22Sina%22}%2C%22fy%22%3A{%22language%22%3A%22fy%22%2C%22value%22%3A%22Sina%22}%2C%22nl%22%3A{%22language%22%3A%22nl%22%2C%22value%22%3A%22Sina%22}%2C%22mg%22%3A{%22language%22%3A%22mg%22%2C%22value%22%3A%22Sina%22}}%2C%22links%22%3A{%22en%22%3A{%22site%22%3A%22en%22%2C%22title%22%3A%22Sina%22}%2C%22de%22%3A{%22site%22%3A%22de%22%2C%22title%22%3A%22Sina%22}%2C%22la%22%3A{%22site%22%3A%22la%22%2C%22title%22%3A%22Sina%22}%2C%22fy%22%3A{%22site%22%3A%22fy%22%2C%22title%22%3A%22Sina+%28betsjuttings%29%22}%2C%22nl%22%3A{%22site%22%3A%22nl%22%2C%22title%22%3A%22Sina%22}%2C%22mg%22%3A{%22site%22%3A%22mg%22%2C%22title%22%3A%22Sina%22}}}
Response:
Fatal error: Call to a member function getPrefixedDBkey() on a non-object in
/var/www/wikidata-test-repo.wikimedia.de/w/extensions/Wikibase/repo/includes/ItemContent.php
on line 139
So the returned content is plain text although the request contains
'format=xml'. This should _never_ happend because most parsers always expect
valid xml. So please always catch all errors and wrap then into valid xml.
An exmaple from the same module containing another error, but returning valid,
so that it can be handled by the requestor:
http://wikidata-test-repo.wikimedia.de/w/api.php?action=wbsetitem&format=xml&item=add&data={%22label%22%3A{%22en%22%3A{%22language%22%3A%22en%22%2C%22value%22%3A%22ABC%22}}%2C%22links%22%3A{%22en%22%3A{%22site%22%3A%22en%22%2C%22title%22%3A%22ABC%22}}}
Respone:
<?xml version="1.0"?><api><error code="internal_api_error_DBQueryError"
info="Database query error" xml:space="preserve">
#0 /var/www/wikidata-test-repo.wikimedia.de/w/includes/db/Database.php(939):
DatabaseBase->reportQueryError('Duplicate entry...', 1062, 'INSERT INTO
`w...', 'Wikibase\ItemSt...', false)
...
</error></api>
--
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l