https://bugzilla.wikimedia.org/show_bug.cgi?id=52072

       Web browser: ---
            Bug ID: 52072
           Summary: Annotation serialization is inconsistent and sometimes
                    incorrect
           Product: MediaWiki extensions
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: Annotator
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified
   Mobile Platform: ---

There are two separate ways to serialize, and one of them is incorrect for
ranges.

Search serializes the entire rows array at once, which includes all annotation
contents.  However, Read explicitly lists certain fields.  Read has a bug. 
When the database has:

{"ranges":[{"start":"/p[1]","startOffset":118,"end":"/p[1]","endOffset":134}],"quote":"The
local legend","text":"Is the legend accurate?"}

it is serialized by ApiAnnotatorRead as:

{"id":14,"text":"Is the legend accurate?","quote":"The local
legend","ranges":{"start":"/p[1]","startOffset":118,"end":"/p[1]","endOffset":134}}


Note how the array of ranges is stripped of its brackets.

It would be good to filter the annotation (only allowing valid fields). 
However,  I don't think that's a blocker, since FormatJson can only serialize
JSON, not arbitrary objects.

So to simply serialize the entire object in Read, you can loop like:

https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FEventLogging.git/3985fbf7d20c9c2ef47fb561b418a62618ff1177/includes%2FApiJsonSchema.php#L112

You still need to explicitly add the ID, but that will handle the ranges
correctly, and everything else.

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

Reply via email to