Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/avro/datum.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class AvroIODatumWriter
* Schema used by this instance to write Avro data.
* @var AvroSchema
*/
private $writers_schema;
public $writers_schema;

/**
* @param AvroSchema $writers_schema
Expand Down
8 changes: 5 additions & 3 deletions lib/avro/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,11 @@ public static function is_valid_datum($expected_schema, $datum)
case self::REQUEST_SCHEMA:
if (is_array($datum))
{
foreach ($expected_schema->fields() as $field)
if (!array_key_exists($field->name(), $datum) || !self::is_valid_datum($field->type(), $datum[$field->name()]))
return false;
foreach ($expected_schema->fields() as $field) {
$value = isset($datum[$field->name()]) ? $datum[$field->name()] : $field->default_value();
if (!self::is_valid_datum($field->type(), $value))
return false;
}
return true;
}
return false;
Expand Down