Page MenuHomePhabricator

Empty objects can pass schemas with required fields
Closed, DeclinedPublic

Description

I found this while testing the fix for bug 65385, but it's a distinct (and more serious) issue.

Blank objects can pass schemas with required fields. To test, run the following in phpsh:


$schema = array(
'properties' => array(

		'someRequiredField' => array(
			'type' => 'string',
			'required' => true
		)

)
);

var_export( efSchemaValidate( array(), $schema ) );

var_export( efSchemaValidate( array( 'a' => 'b' ), $schema ) );


The first passes, which is the bug. The second throws:

Missing required field "someRequiredField"

as expected (It is also invalid for an additional reason, the extra property, but there is no issue, since it fails it for one of the correct reasons).


Version: unspecified
Severity: major
Whiteboard: u=dandreescu@wikimedia.org c=EventLogging p=9999
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=65385

Details

Reference
bz65607