summaryrefslogtreecommitdiff
path: root/modules/field
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2013-04-01 23:22:07 -0400
committerDavid Rothstein <drothstein@gmail.com>2013-04-01 23:22:07 -0400
commit9c52b7180366804f19a148e89f8edac32a0bec68 (patch)
treef26956673d9c828f51fb671f419ec621d9f3fda3 /modules/field
parent025ad199b53fbe8db4c71f59f8493e61116b5e46 (diff)
downloadbrdo-9c52b7180366804f19a148e89f8edac32a0bec68.tar.gz
brdo-9c52b7180366804f19a148e89f8edac32a0bec68.tar.bz2
Issue #1821906 followup by David_Rothstein: Validate that the new $options parameter in various Field API public API functions is actually an array, to prevent conflicts with contrib modules.
Diffstat (limited to 'modules/field')
-rw-r--r--modules/field/field.attach.inc24
1 files changed, 24 insertions, 0 deletions
diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc
index 267be93df..30a12d003 100644
--- a/modules/field/field.attach.inc
+++ b/modules/field/field.attach.inc
@@ -562,6 +562,10 @@ function _field_invoke_get_instances($entity_type, $bundle, $options) {
* @see field_form_set_state()
*/
function field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode = NULL, $options = array()) {
+ // Validate $options since this is a new parameter added after Drupal 7 was
+ // released.
+ $options = is_array($options) ? $options : array();
+
// Set #parents to 'top-level' by default.
$form += array('#parents' => array());
@@ -775,6 +779,10 @@ function field_attach_load_revision($entity_type, $entities, $options = array())
* details.
*/
function field_attach_validate($entity_type, $entity, $options = array()) {
+ // Validate $options since this is a new parameter added after Drupal 7 was
+ // released.
+ $options = is_array($options) ? $options : array();
+
$errors = array();
// Check generic, field-type-agnostic errors first.
$null = NULL;
@@ -827,6 +835,10 @@ function field_attach_validate($entity_type, $entity, $options = array()) {
* details.
*/
function field_attach_form_validate($entity_type, $entity, $form, &$form_state, $options = array()) {
+ // Validate $options since this is a new parameter added after Drupal 7 was
+ // released.
+ $options = is_array($options) ? $options : array();
+
// Extract field values from submitted values.
_field_invoke_default('extract_form_values', $entity_type, $entity, $form, $form_state);
@@ -870,6 +882,10 @@ function field_attach_form_validate($entity_type, $entity, $form, &$form_state,
* details.
*/
function field_attach_submit($entity_type, $entity, $form, &$form_state, $options = array()) {
+ // Validate $options since this is a new parameter added after Drupal 7 was
+ // released.
+ $options = is_array($options) ? $options : array();
+
// Extract field values from submitted values.
_field_invoke_default('extract_form_values', $entity_type, $entity, $form, $form_state, $options);
@@ -1109,6 +1125,10 @@ function field_attach_delete_revision($entity_type, $entity) {
* details.
*/
function field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode = NULL, $options = array()) {
+ // Validate $options since this is a new parameter added after Drupal 7 was
+ // released.
+ $options = is_array($options) ? $options : array();
+
$options['language'] = array();
// To ensure hooks are only run once per entity, only process items without
@@ -1188,6 +1208,10 @@ function field_attach_prepare_view($entity_type, $entities, $view_mode, $langcod
* A renderable array for the field values.
*/
function field_attach_view($entity_type, $entity, $view_mode, $langcode = NULL, $options = array()) {
+ // Validate $options since this is a new parameter added after Drupal 7 was
+ // released.
+ $options = is_array($options) ? $options : array();
+
// Determine the actual language to display for each field, given the
// languages available in the field data.
$display_language = field_language($entity_type, $entity, NULL, $langcode);