Commit 0e95fcf8 authored by webchick's avatar webchick

Issue #1966998 by andypost, swentel: Add a constant OR use TRUE/FALSE for...

Issue #1966998 by andypost, swentel: Add a constant OR use TRUE/FALSE for active storage vs. inactive storage and other properties.
parent af7bd456
......@@ -35,11 +35,11 @@
* - weight: The default weight of the element.
* - visible: The default visibility of the element. Only for 'display'
* context.
* - edit: (optional) String containing markup (normally a link) used as the
* element's 'edit' operation in the administration interface. Only for
* - edit: (optional) String containing markup (normally a link) used as the
* element's 'edit' operation in the administration interface. Only for
* 'form' context.
* - delete: (optional) String containing markup (normally a link) used as the
* element's 'delete' operation in the administration interface. Only for
* - delete: (optional) String containing markup (normally a link) used as the
* element's 'delete' operation in the administration interface. Only for
* 'form' context.
*/
function hook_field_extra_fields() {
......@@ -1652,7 +1652,7 @@ function hook_field_storage_create_field($field) {
*/
function hook_field_storage_delete_field($field) {
// Mark all data associated with the field for deletion.
$field['deleted'] = 0;
$field['deleted'] = FALSE;
$table = _field_sql_storage_tablename($field);
$revision_table = _field_sql_storage_revision_tablename($field);
db_update($table)
......@@ -1660,7 +1660,7 @@ function hook_field_storage_delete_field($field) {
->execute();
// Move the table to a unique name while the table contents are being deleted.
$field['deleted'] = 1;
$field['deleted'] = TRUE;
$new_table = _field_sql_storage_tablename($field);
$revision_new_table = _field_sql_storage_revision_tablename($field);
db_rename_table($table, $new_table);
......
......@@ -1565,7 +1565,7 @@ function field_entity_bundle_delete($entity_type, $bundle) {
// Get the instances on the bundle. field_read_instances() must be used
// here since field_info_instances() does not return instances for disabled
// entity types or bundles.
$instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle), array('include_inactive' => 1));
$instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle), array('include_inactive' => TRUE));
foreach ($instances as $instance) {
field_delete_instance($instance);
}
......
......@@ -169,8 +169,8 @@ function field_read_fields($conditions = array(), $include_additional = array())
// Translate "do not include inactive instances" into actual conditions.
if (!$include_inactive) {
$conditions['active'] = 1;
$conditions['storage.active'] = 1;
$conditions['active'] = TRUE;
$conditions['storage.active'] = TRUE;
}
// Collect matching fields.
......@@ -360,8 +360,8 @@ function field_read_instances($conditions = array(), $include_additional = array
// Translate "do not include inactive fields" into actual conditions.
if (!$include_inactive) {
$conditions['field.active'] = 1;
$conditions['field.storage.active'] = 1;
$conditions['field.active'] = TRUE;
$conditions['field.storage.active'] = TRUE;
}
// Collect matching instances.
......@@ -520,7 +520,7 @@ function field_delete_instance(FieldInstance $instance, $field_cleanup = TRUE) {
function field_purge_batch($batch_size) {
// Retrieve all deleted field instances. We cannot use field_info_instances()
// because that function does not return deleted instances.
$instances = field_read_instances(array('deleted' => 1), array('include_deleted' => 1));
$instances = field_read_instances(array('deleted' => TRUE), array('include_deleted' => TRUE));
$factory = Drupal::service('entity.query');
$info = entity_get_info();
foreach ($instances as $instance) {
......
......@@ -32,8 +32,8 @@ function _update_7000_field_create_field(&$field) {
'locked' => FALSE,
'settings' => array(),
'indexes' => array(),
'deleted' => 0,
'active' => 1,
'deleted' => FALSE,
'active' => TRUE,
);
// Set storage.
......@@ -41,7 +41,7 @@ function _update_7000_field_create_field(&$field) {
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => 1,
'active' => TRUE,
);
// Fetch the field schema to initialize columns and indexes. The field module
......@@ -208,7 +208,7 @@ function _update_7000_field_create_instance($field, &$instance) {
$instance += array(
'field_id' => $field['id'],
'field_name' => $field['field_name'],
'deleted' => 0,
'deleted' => FALSE,
'description' => '',
'required' => FALSE,
);
......
......@@ -235,7 +235,7 @@ public function __construct(array $values, $entity_type = 'field_entity') {
'translatable' => FALSE,
'entity_types' => array(),
'locked' => FALSE,
'deleted' => 0,
'deleted' => FALSE,
'storage' => array(),
'indexes' => array(),
);
......@@ -315,7 +315,7 @@ public function save() {
throw new FieldException(format_string('Attempt to create a field of unknown type %type.', array('%type' => $this->type)));
}
$this->module = $field_type['module'];
$this->active = 1;
$this->active = TRUE;
// Make sure all settings are present, so that a complete field
// definition is passed to the various hooks and written to config.
......@@ -332,7 +332,7 @@ public function save() {
throw new FieldException(format_string('Attempt to create a field with unknown storage type %type.', array('%type' => $this->storage['type'])));
}
$this->storage['module'] = $storage_type['module'];
$this->storage['active'] = 1;
$this->storage['active'] = TRUE;
// Provide default storage settings.
$this->storage['settings'] += $storage_type['settings'];
......
......@@ -273,7 +273,7 @@ public function __construct(array $values, $entity_type = 'field_instance') {
'default_value_function' => '',
'settings' => array(),
'widget' => array(),
'deleted' => 0,
'deleted' => FALSE,
);
parent::__construct($values, $entity_type);
}
......
......@@ -451,7 +451,7 @@ function fakeFieldInstance($formatter, $formatter_settings) {
'required' => FALSE,
'label' => $field_name,
'description' => '',
'deleted' => 0,
'deleted' => FALSE,
);
}
......
......@@ -166,7 +166,7 @@ function testDeleteFieldInstance() {
field_delete_instance($instance);
// The instance still exists, deleted.
$instances = field_read_instances(array('field_id' => $field['uuid'], 'deleted' => 1), array('include_deleted' => 1, 'include_inactive' => 1));
$instances = field_read_instances(array('field_id' => $field['uuid'], 'deleted' => TRUE), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
$this->assertEqual(count($instances), 1, 'There is one deleted instance');
$this->assertEqual($instances[0]['bundle'], $bundle, 'The deleted instance is for the correct bundle');
......@@ -193,7 +193,7 @@ function testDeleteFieldInstance() {
$ids->entity_id = $entity_id;
$entities[$entity_id] = _field_create_entity_from_ids($ids);
}
field_attach_load($this->entity_type, $entities, FIELD_LOAD_CURRENT, array('field_id' => $field['uuid'], 'deleted' => 1));
field_attach_load($this->entity_type, $entities, FIELD_LOAD_CURRENT, array('field_id' => $field['uuid'], 'deleted' => TRUE));
$this->assertEqual(count($found), 10, 'Correct number of entities found after deleting');
foreach ($entities as $id => $entity) {
$this->assertEqual($this->entities[$id]->{$field['field_name']}, $entity->{$field['field_name']}, "Entity $id with deleted data loaded correctly");
......@@ -249,18 +249,18 @@ function testPurgeInstance() {
$this->checkHooksInvocations($hooks, $actual_hooks);
// The instance still exists, deleted.
$instances = field_read_instances(array('field_id' => $field['uuid'], 'deleted' => 1), array('include_deleted' => 1, 'include_inactive' => 1));
$instances = field_read_instances(array('field_id' => $field['uuid'], 'deleted' => TRUE), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
$this->assertEqual(count($instances), 1, 'There is one deleted instance');
// Purge the instance.
field_purge_batch($batch_size);
// The instance is gone.
$instances = field_read_instances(array('field_id' => $field['uuid'], 'deleted' => 1), array('include_deleted' => 1, 'include_inactive' => 1));
$instances = field_read_instances(array('field_id' => $field['uuid'], 'deleted' => TRUE), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
$this->assertEqual(count($instances), 0, 'The instance is gone');
// The field still exists, not deleted, because it has a second instance.
$fields = field_read_fields(array('uuid' => $field['uuid']), array('include_deleted' => 1, 'include_inactive' => 1));
$fields = field_read_fields(array('uuid' => $field['uuid']), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
$this->assertTrue(isset($fields[$field['uuid']]), 'The field exists and is not deleted');
}
......@@ -302,7 +302,7 @@ function testPurgeField() {
field_purge_batch(0);
// The field still exists, not deleted.
$fields = field_read_fields(array('uuid' => $field['uuid']), array('include_deleted' => 1));
$fields = field_read_fields(array('uuid' => $field['uuid']), array('include_deleted' => TRUE));
$this->assertTrue(isset($fields[$field['uuid']]) && !$fields[$field['uuid']]->deleted, 'The field exists and is not deleted');
// Delete the second instance.
......@@ -326,14 +326,14 @@ function testPurgeField() {
$this->checkHooksInvocations($hooks, $actual_hooks);
// The field still exists, deleted.
$fields = field_read_fields(array('uuid' => $field['uuid']), array('include_deleted' => 1));
$fields = field_read_fields(array('uuid' => $field['uuid']), array('include_deleted' => TRUE));
$this->assertTrue(isset($fields[$field['uuid']]) && $fields[$field['uuid']]->deleted, 'The field exists and is deleted');
// Purge again to purge the instance and the field.
field_purge_batch(0);
// The field is gone.
$fields = field_read_fields(array('uuid' => $field['uuid']), array('include_deleted' => 1, 'include_inactive' => 1));
$fields = field_read_fields(array('uuid' => $field['uuid']), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
$this->assertEqual(count($fields), 0, 'The field is purged.');
}
}
......@@ -18,7 +18,7 @@ public static function getInfo() {
}
/**
* Test that field types and field definitions are correcly cached.
* Test that field types and field definitions are correctly cached.
*/
function testFieldInfo() {
// Test that field_test module's fields, widgets, and formatters show up.
......@@ -69,7 +69,7 @@ function testFieldInfo() {
$this->assertEqual($fields[$field['field_name']]['settings'][$key], $val, format_string('Field setting %key has correct default value %value', array('%key' => $key, '%value' => $val)));
}
$this->assertEqual($fields[$field['field_name']]['cardinality'], 1, 'info fields contains cardinality 1');
$this->assertEqual($fields[$field['field_name']]['active'], 1, 'info fields contains active 1');
$this->assertEqual($fields[$field['field_name']]['active'], TRUE, 'info fields contains active 1');
// Create an instance, verify that it shows up
$instance = array(
......
......@@ -359,7 +359,7 @@ function field_sql_storage_field_storage_update_field($field, $prior_field, $has
*/
function field_sql_storage_field_storage_delete_field($field) {
// Mark all data associated with the field for deletion.
$field['deleted'] = 0;
$field['deleted'] = FALSE;
$table = _field_sql_storage_tablename($field);
$revision_table = _field_sql_storage_revision_tablename($field);
db_update($table)
......@@ -367,7 +367,7 @@ function field_sql_storage_field_storage_delete_field($field) {
->execute();
// Move the table to a unique name while the table contents are being deleted.
$field['deleted'] = 1;
$field['deleted'] = TRUE;
$new_table = _field_sql_storage_tablename($field);
$revision_new_table = _field_sql_storage_revision_tablename($field);
db_rename_table($table, $new_table);
......
Markdown is supported
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