Commit 189329d0 authored by klausi's avatar klausi Committed by Ra Mänd
Browse files

Issue #2841004 by klausi: Replace confusing empty 'Too many items.' page with Access Denied page

parent 0ef247a1
...@@ -118,8 +118,7 @@ function field_collection_item_add($field_name, $entity_type, $entity_id, $revis ...@@ -118,8 +118,7 @@ function field_collection_item_add($field_name, $entity_type, $entity_id, $revis
$langcode = !empty($field['translatable']) ? entity_language($entity_type, $entity) : LANGUAGE_NONE; $langcode = !empty($field['translatable']) ? entity_language($entity_type, $entity) : LANGUAGE_NONE;
if (!($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || !isset($entity->{$field_name}[$langcode]) || count($entity->{$field_name}[$langcode]) < $field['cardinality'])) { if (!($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || !isset($entity->{$field_name}[$langcode]) || count($entity->{$field_name}[$langcode]) < $field['cardinality'])) {
drupal_set_message(t('Too many items.'), 'error'); return MENU_ACCESS_DENIED;
return '';
} }
$field_collection_item = entity_create('field_collection_item', array('field_name' => $field_name)); $field_collection_item = entity_create('field_collection_item', array('field_name' => $field_name));
......
...@@ -361,7 +361,7 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase { ...@@ -361,7 +361,7 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
// Make sure adding doesn't work any more as we have restricted cardinality // Make sure adding doesn't work any more as we have restricted cardinality
// to 1. // to 1.
$this->drupalGet($path); $this->drupalGet($path);
$this->assertText(t('Too many items.'), 'Maxium cardinality has been reached.'); $this->assertResponse(403);
$this->drupalPost('field-collection/field-test-collection/1/delete', array(), t('Delete')); $this->drupalPost('field-collection/field-test-collection/1/delete', array(), t('Delete'));
$this->drupalGet($path); $this->drupalGet($path);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment