You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c478159
Browse filesBrowse the repository at this point in the historyBrowse files
Entity Fields: Validate the ids of collection fields before using them.
A `field.php` that returned a non-string `id`, such as an array, caused
a fatal error when the id was used as a key in get_collection_fields().
Other non-string ids were silently coerced, and a folder setting the id
of an earlier one silently replaced it.
Such fields are now reported with _doing_it_wrong() and skipped, along
with a `field.php` that does not return an array. The rest of the
collection is read, and register_collection() returns false when a
field was skipped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/* translators: 1: The name of a field collection. 2: Comma-separated list of folder names. */
906
+
__( 'The `field.php` of a field must return an array, with a non-empty string `id` if it sets one. These fields of the field collection "%1$s" are skipped: %2$s.' ),
907
+
$collection,
908
+
implode( ', ', $invalid )
909
+
),
910
+
'7.2.0'
911
+
);
912
+
}
913
+
914
+
if ( $duplicated ) {
915
+
_doing_it_wrong(
916
+
$method,
917
+
sprintf(
918
+
/* translators: 1: The name of a field collection. 2: Comma-separated list of folder names. */
919
+
__( 'A field can only be defined once in a field collection. These fields of the field collection "%1$s" are skipped because an earlier folder defines their id: %2$s.' ),
920
+
$collection,
921
+
implode( ', ', $duplicated )
922
+
),
923
+
'7.2.0'
924
+
);
925
+
}
926
+
927
+
returnarray(
928
+
'fields' => $fields,
929
+
'skipped' => $invalid || $duplicated,
930
+
);
931
+
}
932
+
851
933
/**
852
934
* Requires a file without sharing the variables of the caller: this is
0 commit comments