Page MenuHomePhabricator

"pages" property does not allow for integers and arrays of integers
Closed, DeclinedPublic

Description

Author: molly.white5

Description:
The code that I took from EventLogging only allows arrays to contain one type of value. The "pages" property should allow for something like the following:

[2, [5,8]]

This would indicate that the section included pages 2, 5, 6, 7, 8.

Right now the validation either allows only numbers, which would require the JSON to be formatted:

[2, 5, 6, 7, 8]

or only arrays, which would require the JSON to be formatted:

[[2], [5,8]]

Both of these seem a little silly, so it seems like it would be worth adjusting the code to allow for more than one type of value, and, ideally, pushing the changes back to EventLogging as well.


Version: unspecified
Severity: normal

Details

Reference
bz51063

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 2:05 AM
bzimport set Reference to bz51063.
bzimport created this task.Jul 9 2013, 7:20 PM
ori added a comment.Jul 11 2013, 9:34 AM

I'm not able to reproduce this; can you provide some additional details?

Here's what I tried:

$schema = array( 'properties' => array(
    'collection' => array(
        'type' => 'array',
    ),
) );

$obj = array( 'collection' => array( 8, "hello", array(6) ) );
var_dump ( efSchemaValidate( $obj, $schema ) ); // output:

bool(true)

molly.white5 wrote:

Sure. The schema that I am using is https://meta.wikimedia.org/wiki/Schema:BookManagerv2. The relevant bits are lines 179–199. Is this the incorrect way to indicate that an array should contain numbers or arrays of numbers?

In your example, why is the string passing the validation?

molly.white5 wrote:

The "Refactoring of Proofread Page extension" is working on a system to populate book pages with the <pages index> tags, and so we are stepping back from that feature. The "pages" property will be removed from the schema entirely.