diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index ec49512..04ac341 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -239,12 +239,8 @@ function comment_menu() { ); $items['comment/%comment/approve'] = array( 'title' => 'Approve', - 'page callback' => 'comment_approve', - 'page arguments' => array(1), - 'access callback' => 'entity_page_access', - 'access arguments' => array(1, 'approve'), - 'file' => 'comment.pages.inc', 'weight' => 10, + 'route_name' => 'comment_approve', ); $items['comment/%comment/delete'] = array( 'title' => 'Delete', diff --git a/core/modules/comment/comment.pages.inc b/core/modules/comment/comment.pages.inc index 5e1b190..5f408d4 100644 --- a/core/modules/comment/comment.pages.inc +++ b/core/modules/comment/comment.pages.inc @@ -99,26 +99,3 @@ function comment_reply(EntityInterface $node, $pid = NULL) { return $build; } -/** - * Page callback: Publishes the specified comment. - * - * @param \Drupal\comment\Plugin\Core\Entity\Comment $comment - * A comment entity. - * - * @see comment_menu() - */ -function comment_approve(Comment $comment) { - // @todo CSRF tokens are validated in page callbacks rather than access - // callbacks, because access callbacks are also invoked during menu link - // generation. Add token support to routing: http://drupal.org/node/755584. - $token = drupal_container()->get('request')->query->get('token'); - if (!isset($token) || !drupal_valid_token($token, 'comment/' . $comment->id() . '/approve')) { - throw new AccessDeniedHttpException(); - } - - $comment->status->value = COMMENT_PUBLISHED; - $comment->save(); - - drupal_set_message(t('Comment approved.')); - drupal_goto('node/' . $comment->nid->target_id); -} diff --git a/core/modules/comment/comment.routing.yml b/core/modules/comment/comment.routing.yml index 6f786dd..ddc6048 100644 --- a/core/modules/comment/comment.routing.yml +++ b/core/modules/comment/comment.routing.yml @@ -1,7 +1,14 @@ comment_edit_page: - pattern: 'comment/{comment}/edit' - defaults: - _entity_form: comment.default - requirements: - _entity_access: comment.update + pattern: 'comment/{comment}/edit' + defaults: + _entity_form: comment.default + requirements: + _entity_access: comment.update +comment_approve: + pattern: 'comment/{comment}/approve' + defaults: + _content: '\Drupal\comment\Controller\CommentController::commentApprove' + entity_type: 'comment' + requirements: + _entity_access: comment.approve diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php new file mode 100644 index 0000000..3d27901 --- /dev/null +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -0,0 +1,65 @@ +query->get('token'); + if (!isset($token) || !drupal_valid_token($token, 'comment/' . $comment->id() . '/approve')) { + throw new AccessDeniedHttpException(); + } + + $comment->status->value = COMMENT_PUBLISHED; + $comment->save(); + + drupal_set_message(t('Comment approved.')); + return new RedirectResponse(url('node/' . $comment->nid->target_id, array('absolute' => TRUE))); + } + +} diff --git a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php index 00ebd9c..3598446 100644 --- a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php +++ b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php @@ -28,34 +28,6 @@ class FieldSqlStorageTest extends EntityUnitTestBase { */ public static $modules = array('field_test', 'text', 'number'); - /** - * The name of the created field. - * - * @var string - */ - protected $field_name; - - /** - * A field to use in this class. - * - * @var \Drupal\field\Plugin\Core\Entity\Field - */ - protected $field; - - /** - * A field instance to use in this test class. - * - * @var \Drupal\field\Plugin\Core\Entity\FieldInstance - */ - protected $instance; - - /** - * Name of the revision table of the field. - * - * @var string - */ - protected $revision_table; - public static function getInfo() { return array( 'name' => 'Field SQL Storage tests', @@ -69,20 +41,17 @@ function setUp() { $this->installSchema('field_test', array('test_entity', 'test_entity_revision', 'test_entity_bundle')); $this->field_name = strtolower($this->randomName()); - $this->field = entity_create('field_entity', array( - 'field_name' => $this->field_name, - 'type' => 'test_field', - 'cardinality' => 4, - )); - $this->field->save(); - $this->instance = entity_create('field_instance', array( + $this->field = array('field_name' => $this->field_name, 'type' => 'test_field', 'cardinality' => 4); + $this->field = field_create_field($this->field); + $this->instance = array( 'field_name' => $this->field_name, 'entity_type' => 'test_entity', 'bundle' => 'test_bundle' - )); - $this->instance->save(); + ); + $this->instance = field_create_instance($this->instance); $this->table = _field_sql_storage_tablename($this->field); $this->revision_table = _field_sql_storage_revision_tablename($this->field); + } /** @@ -184,7 +153,7 @@ function testFieldAttachInsertAndUpdate() { } // Test update. - $entity = field_test_create_entity(0, 1, $this->instance->bundle); + $entity = field_test_create_entity(0, 1, $this->instance['bundle']); $values = array(); // Note: we try to update one extra value ('<=' instead of '<'). for ($delta = 0; $delta <= $this->field['cardinality']; $delta++) { @@ -224,7 +193,7 @@ function testFieldAttachInsertAndUpdate() { field_attach_update($entity); $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); foreach ($values as $delta => $value) { - if ($delta < $this->field->cardinality) { + if ($delta < $this->field['cardinality']) { $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Update with no field_name entry leaves value $delta untouched")); } } @@ -241,7 +210,7 @@ function testFieldAttachInsertAndUpdate() { */ function testFieldAttachSaveMissingData() { $entity_type = 'test_entity'; - $entity = field_test_create_entity(0, 0, $this->instance->bundle); + $entity = field_test_create_entity(0, 0, $this->instance['bundle']); $langcode = Language::LANGCODE_NOT_SPECIFIED; // Insert: Field is missing @@ -292,7 +261,7 @@ function testFieldAttachSaveMissingData() { $unavailable_langcode = 'xx'; db_insert($this->table) ->fields(array('entity_type', 'bundle', 'deleted', 'entity_id', 'revision_id', 'delta', 'langcode')) - ->values(array($entity_type, $this->instance->bundle, 0, 0, 0, 0, $unavailable_langcode)) + ->values(array($entity_type, $this->instance['bundle'], 0, 0, 0, 0, $unavailable_langcode)) ->execute(); $count = db_select($this->table) ->countQuery() @@ -336,26 +305,18 @@ function testFieldAttachSaveMissingData() { */ function testUpdateFieldSchemaWithData() { // Create a decimal 5.2 field and add some data. - $field = entity_create('field_entity', array( - 'field_name' => 'decimal52', - 'type' => 'number_decimal', - 'settings' => array('precision' => 5, 'scale' => 2), - )); - $field->save(); - $instance = entity_create('field_instance', array( - 'field_name' => 'decimal52', - 'entity_type' => 'test_entity', - 'bundle' => 'test_bundle', - )); - $instance->save(); - $entity = field_test_create_entity(0, 0, $instance->bundle); + $field = array('field_name' => 'decimal52', 'type' => 'number_decimal', 'settings' => array('precision' => 5, 'scale' => 2)); + $field = field_create_field($field); + $instance = array('field_name' => 'decimal52', 'entity_type' => 'test_entity', 'bundle' => 'test_bundle'); + $instance = field_create_instance($instance); + $entity = field_test_create_entity(0, 0, $instance['bundle']); $entity->decimal52[Language::LANGCODE_NOT_SPECIFIED][0]['value'] = '1.235'; $entity->save(); // Attempt to update the field in a way that would work without data. - $field->settings['scale'] = 3; + $field['settings']['scale'] = 3; try { - $field->save(); + field_update_field($field); $this->fail(t('Cannot update field schema with data.')); } catch (FieldException $e) { @@ -368,18 +329,14 @@ function testUpdateFieldSchemaWithData() { */ function testFieldUpdateFailure() { // Create a text field. - $field = entity_create('field_entity', array( - 'field_name' => 'test_text', - 'type' => 'text', - 'settings' => array('max_length' => 255), - )); - $field->save(); + $field = array('field_name' => 'test_text', 'type' => 'text', 'settings' => array('max_length' => 255)); + $field = field_create_field($field); // Attempt to update the field in a way that would break the storage. $prior_field = $field; - $field->settings['max_length'] = -1; + $field['settings']['max_length'] = -1; try { - $field->save(); + field_update_field($field); $this->fail(t('Update succeeded.')); } catch (\Exception $e) { @@ -396,18 +353,13 @@ function testFieldUpdateFailure() { * Test adding and removing indexes while data is present. */ function testFieldUpdateIndexesWithData() { + // Create a decimal field. $field_name = 'testfield'; - $field = entity_create('field_entity', array( - 'field_name' => $field_name, - 'type' => 'text')); - $field->save(); - $instance = entity_create('field_instance', array( - 'field_name' => $field_name, - 'entity_type' => 'test_entity', - 'bundle' => 'test_bundle', - )); - $instance->save(); + $field = array('field_name' => $field_name, 'type' => 'text'); + $field = field_create_field($field); + $instance = array('field_name' => $field_name, 'entity_type' => 'test_entity', 'bundle' => 'test_bundle'); + $instance = field_create_instance($instance); $tables = array(_field_sql_storage_tablename($field), _field_sql_storage_revision_tablename($field)); // Verify the indexes we will create do not exist yet. @@ -417,27 +369,27 @@ function testFieldUpdateIndexesWithData() { } // Add data so the table cannot be dropped. - $entity = field_test_create_entity(1, 1, $instance->bundle); + $entity = field_test_create_entity(1, 1, $instance['bundle']); $entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['value'] = 'field data'; $entity->save(); - // Add an index. - $field->indexes = array('value' => array(array('value', 255))); - $field->save(); + // Add an index + $field = array('field_name' => $field_name, 'indexes' => array('value' => array(array('value', 255)))); + field_update_field($field); foreach ($tables as $table) { $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in $table")); } // Add a different index, removing the existing custom one. - $field->indexes = array('value_format' => array(array('value', 127), array('format', 127))); - $field->save(); + $field = array('field_name' => $field_name, 'indexes' => array('value_format' => array(array('value', 127), array('format', 127)))); + field_update_field($field); foreach ($tables as $table) { $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in $table")); $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value removed in $table")); } // Verify that the tables were not dropped. - $entity = field_test_create_entity(1, 1, $instance->bundle); + $entity = field_test_create_entity(1, 1, $instance['bundle']); field_attach_load('test_entity', array(1 => $entity)); $this->assertEqual($entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['value'], 'field data', t("Index changes performed without dropping the tables")); } @@ -450,23 +402,21 @@ function testFieldStorageDetails() { $revision = _field_sql_storage_revision_tablename($this->field); // Retrieve the field and instance with field_info so the storage details are attached. - $field = field_info_field($this->field_name); - $instance = field_info_instance($this->instance->entity_type, $field->id(), $this->instance->bundle); + $field = field_info_field($this->field['field_name']); + $instance = field_info_instance($this->instance['entity_type'], $this->instance['field_name'], $this->instance['bundle']); // The storage details are indexed by a storage engine type. - $storage_details = $field->getStorageDetails(); - $this->assertTrue(array_key_exists('sql', $storage_details), 'The storage type is SQL.'); + $this->assertTrue(array_key_exists('sql', $field['storage_details']), 'The storage type is SQL.'); // The SQL details are indexed by table name. - $details = $storage_details['sql']; + $details = $field['storage_details']['sql']; $this->assertTrue(array_key_exists($current, $details[FIELD_LOAD_CURRENT]), 'Table name is available in the instance array.'); $this->assertTrue(array_key_exists($revision, $details[FIELD_LOAD_REVISION]), 'Revision table name is available in the instance array.'); // Test current and revision storage details together because the columns // are the same. - $schema = $this->field->getSchema(); - foreach ($schema['columns'] as $column_name => $attributes) { - $storage_column_name = _field_sql_storage_columnname($this->field_name, $column_name); + foreach ((array) $this->field['columns'] as $column_name => $attributes) { + $storage_column_name = _field_sql_storage_columnname($this->field['field_name'], $column_name); $this->assertEqual($details[FIELD_LOAD_CURRENT][$current][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $current))); $this->assertEqual($details[FIELD_LOAD_REVISION][$revision][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $revision))); } @@ -480,32 +430,25 @@ function testFieldSqlStorageForeignKeys() { // field_test_field_schema()). $field_name = 'testfield'; $foreign_key_name = 'shape'; - $field = entity_create('field_entity', array( - 'field_name' => $field_name, - 'type' => 'shape', - 'settings' => array('foreign_key_name' => $foreign_key_name), - )); - $field->save(); - // Get the field schema. - $schema = $field->getSchema(); + $field = array('field_name' => $field_name, 'type' => 'shape', 'settings' => array('foreign_key_name' => $foreign_key_name)); + field_create_field($field); // Retrieve the field definition and check that the foreign key is in place. - $this->assertEqual($schema['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, 'Foreign key table name preserved through CRUD'); - $this->assertEqual($schema['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', 'Foreign key column name preserved through CRUD'); + $field = field_info_field($field_name); + $this->assertEqual($field['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, 'Foreign key table name preserved through CRUD'); + $this->assertEqual($field['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', 'Foreign key column name preserved through CRUD'); // Update the field settings, it should update the foreign key definition too. $foreign_key_name = 'color'; - $field->settings['foreign_key_name'] = $foreign_key_name; - $field->save(); - // Reload the field schema after the update. - $schema = $field->getSchema(); + $field['settings']['foreign_key_name'] = $foreign_key_name; + field_update_field($field); // Retrieve the field definition and check that the foreign key is in place. $field = field_info_field($field_name); - $this->assertEqual($schema['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, t('Foreign key table name modified after update')); - $this->assertEqual($schema['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', t('Foreign key column name modified after update')); + $this->assertEqual($field['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, t('Foreign key table name modified after update')); + $this->assertEqual($field['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', t('Foreign key column name modified after update')); - // Verify the SQL schema. + // Now grab the SQL schema and verify that too. $schemas = _field_sql_storage_schema($field); $schema = $schemas[_field_sql_storage_tablename($field)]; $this->assertEqual(count($schema['foreign keys']), 1, 'There is 1 foreign key in the schema'); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php index c643cd0..55028d1 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php @@ -207,7 +207,7 @@ function testNoFieldsDisplayOverview() { $this->drupalCreateContentType(array('type' => 'no_fields', 'name' => 'No fields')); // Remove the 'body' field. - field_info_instance('node', 'body', 'no_fields')->delete(); + field_delete_instance(field_info_instance('node', 'body', 'no_fields')); $this->drupalGet('admin/structure/types/manage/no_fields/display'); $this->assertRaw(t('There are no fields yet added. You can add new fields on the Manage fields page.', array('@link' => url('admin/structure/types/manage/no_fields/fields')))); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php index 471a575..dd362cd 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php @@ -45,7 +45,7 @@ function setUp() { 'field_name' => 'field_' . $vocabulary->id(), 'type' => 'taxonomy_term_reference', ); - entity_create('field_entity', $field)->save(); + field_create_field($field); $instance = array( 'field_name' => 'field_' . $vocabulary->id(), @@ -53,7 +53,7 @@ function setUp() { 'label' => 'Tags', 'bundle' => 'article', ); - entity_create('field_instance', $instance)->save(); + field_create_instance($instance); entity_get_form_display('node', 'article', 'default') ->setComponent('field_' . $vocabulary->id()) @@ -280,16 +280,17 @@ function testFieldPrefix() { function testDefaultValue() { // Create a test field and instance. $field_name = 'test'; - entity_create('field_entity', array( + $field = array( 'field_name' => $field_name, 'type' => 'test_field' - ))->save(); - $instance = entity_create('field_instance', array( + ); + field_create_field($field); + $instance = array( 'field_name' => $field_name, 'entity_type' => 'node', 'bundle' => $this->type, - )); - $instance->save(); + ); + $instance = field_create_instance($instance); entity_get_form_display('node', $this->type, 'default') ->setComponent($field_name) @@ -430,14 +431,14 @@ function testHiddenFields() { // Create a field and an instance programmatically. $field_name = 'hidden_test_field'; - entity_create('field_entity', array('field_name' => $field_name, 'type' => $field_name))->save(); + field_create_field(array('field_name' => $field_name, 'type' => $field_name)); $instance = array( 'field_name' => $field_name, 'bundle' => $this->type, 'entity_type' => 'node', 'label' => t('Hidden field'), ); - entity_create('field_instance', $instance)->save(); + field_create_instance($instance); entity_get_form_display('node', $this->type, 'default') ->setComponent($field_name) ->save(); diff --git a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php index 65e3aec..7697423 100644 --- a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php @@ -16,11 +16,10 @@ class MultiStepNodeFormBasicOptionsTest extends NodeTestBase { /** - * The field name to create. + * Modules to enable. * - * @var string + * @var array */ - protected $field_name; public static function getInfo() { return array( @@ -40,14 +39,15 @@ function testMultiStepNodeFormBasicOptions() { // Create an unlimited cardinality field. $this->field_name = drupal_strtolower($this->randomName()); - entity_create('field_entity', array( - 'field_name' => $this->field_name, + $this->field = array( + 'field_name' => drupal_strtolower($this->field_name), 'type' => 'text', 'cardinality' => -1, - ))->save(); + ); + field_create_field($this->field); // Attach an instance of the field to the page content type. - entity_create('field_instance', array( + $this->instance = array( 'field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => 'page', @@ -55,7 +55,8 @@ function testMultiStepNodeFormBasicOptions() { 'settings' => array( 'text_processing' => TRUE, ), - ))->save(); + ); + field_create_instance($this->instance); entity_get_form_display('node', 'page', 'default') ->setComponent($this->field_name, array( 'type' => 'text_textfield', @@ -68,11 +69,10 @@ function testMultiStepNodeFormBasicOptions() { 'title' => 'a', 'promote' => FALSE, 'sticky' => 1, - "{$this->field_name}[$langcode][0][value]" => $this->randomString(32), + "$this->field_name[$langcode][0][value]" => $this->randomString(32), ); $this->drupalPost('node/add/page', $edit, t('Add another item')); $this->assertNoFieldChecked('edit-promote', 'promote stayed unchecked'); $this->assertFieldChecked('edit-sticky', 'sticky stayed checked'); } - } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php index e1a33aa..4b3dc88 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php @@ -21,27 +21,6 @@ class NodeAccessFieldTest extends NodeTestBase { */ public static $modules = array('node_access_test', 'field_ui'); - /** - * A user with permission to bypass access content. - * - * @var \Drupal\user\UserInterface - */ - protected $admin_user; - - /** - * A user with permission to manage content types and fields. - * - * @var \Drupal\user\UserInterface - */ - protected $content_admin_user; - - /** - * The name of the created field. - * - * @var string - */ - protected $field_name; - public static function getInfo() { return array( 'name' => 'Node access and fields', @@ -61,15 +40,13 @@ public function setUp() { // Add a custom field to the page content type. $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); - entity_create('field_entity', array( - 'field_name' => $this->field_name, - 'type' => 'text' - ))->save(); - entity_create('field_instance', array( + $this->field = field_create_field(array('field_name' => $this->field_name, 'type' => 'text')); + $instance = array( 'field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => 'page', - ))->save(); + ); + $this->instance = field_create_instance($instance); entity_get_display('node', 'page', 'default') ->setComponent($this->field_name) ->save(); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php index d613cc4..6b60907 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php @@ -31,17 +31,10 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase { /** * A normal authenticated user. * - * @var \Drupal\user\Plugin\Core\Entity\UserInterface. + * @var \Drupal\user\Plugin\Core\Entity\User. */ protected $web_user; - /** - * User 1. - * - * @var \Drupal\user\Plugin\Core\Entity\UserInterface. - */ - protected $admin_user; - public static function getInfo() { return array( 'name' => 'Node access language-aware combination', diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php index e9447ec..18c879f 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php @@ -60,8 +60,8 @@ function setUp() { // Make node body translatable. $field = field_info_field('body'); - $field->translatable = TRUE; - $field->save(); + $field['translatable'] = TRUE; + field_update_field($field); } /** diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php index 9344355..ac024bb 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php @@ -169,7 +169,7 @@ function testFieldTranslationForm() { $this->assertRaw('Not translated'); // Delete the only translatable field. - field_info_field('field_test_et_ui_test')->delete(); + field_delete_field('field_test_et_ui_test'); // Visit translation page. $this->drupalGet('node/' . $article->nid . '/translations'); diff --git a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php index ae7529b..d46c24e 100644 --- a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php @@ -21,13 +21,6 @@ class PagePreviewTest extends NodeTestBase { */ public static $modules = array('node', 'taxonomy'); - /** - * The name of the created field. - * - * @var string - */ - protected $field_name; - public static function getInfo() { return array( 'name' => 'Node preview', @@ -67,7 +60,7 @@ function setUp() { // Set up a field and instance. $this->field_name = drupal_strtolower($this->randomName()); - entity_create('field_entity', array( + $this->field = array( 'field_name' => $this->field_name, 'type' => 'taxonomy_term_reference', 'settings' => array( @@ -79,27 +72,30 @@ function setUp() { ), ), 'cardinality' => '-1', - ))->save(); - entity_create('field_instance', array( + ); + + field_create_field($this->field); + $this->instance = array( 'field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => 'page', - ))->save(); + ); + field_create_instance($this->instance); entity_get_form_display('node', 'page', 'default') - ->setComponent($this->field_name, array( + ->setComponent($this->field['field_name'], array( 'type' => 'taxonomy_autocomplete', )) ->save(); // Show on default display and teaser. entity_get_display('node', 'page', 'default') - ->setComponent($this->field_name, array( + ->setComponent($this->field['field_name'], array( 'type' => 'taxonomy_term_reference_link', )) ->save(); entity_get_display('node', 'page', 'teaser') - ->setComponent($this->field_name, array( + ->setComponent($this->field['field_name'], array( 'type' => 'taxonomy_term_reference_link', )) ->save(); @@ -210,5 +206,4 @@ function testPagePreviewWithRevisions() { // Check that the log field has the correct value. $this->assertFieldByName('log', $edit['log'], 'Log field displayed.'); } - } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 1d90683..9904f0d 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -530,39 +530,39 @@ function node_add_body_field($type, $label = 'Body') { $field = field_info_field('body'); $instance = field_info_instance('node', 'body', $type->type); if (empty($field)) { - $field = entity_create('field_entity', array( + $field = array( 'field_name' => 'body', 'type' => 'text_with_summary', 'entity_types' => array('node'), - )); - $field->save(); + ); + $field = field_create_field($field); } if (empty($instance)) { - $instance = entity_create('field_instance', array( + $instance = array( 'field_name' => 'body', 'entity_type' => 'node', 'bundle' => $type->type, 'label' => $label, 'settings' => array('display_summary' => TRUE), - )); - $instance->save(); + ); + $instance = field_create_instance($instance); // Assign widget settings for the 'default' form mode. entity_get_form_display('node', $type->type, 'default') - ->setComponent($field->id(), array( + ->setComponent($field['field_name'], array( 'type' => 'text_textarea_with_summary', )) ->save(); // Assign display settings for the 'default' and 'teaser' view modes. entity_get_display('node', $type->type, 'default') - ->setComponent($field->id(), array( + ->setComponent($field['field_name'], array( 'label' => 'hidden', 'type' => 'text_default', )) ->save(); entity_get_display('node', $type->type, 'teaser') - ->setComponent($field->id(), array( + ->setComponent($field['field_name'], array( 'label' => 'hidden', 'type' => 'text_summary_or_trimmed', )) diff --git a/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module b/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module index 1baa48e..3d67454 100644 --- a/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module +++ b/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module @@ -49,7 +49,7 @@ function node_access_test_language_node_access_records(EntityInterface $node) { * (restricted access) in a given translation. */ function node_access_test_language_enable() { - $field_private = entity_create('field_entity', array( + $field_private = array( 'field_name' => 'field_private', 'type' => 'list_boolean', 'cardinality' => 1, @@ -57,22 +57,23 @@ function node_access_test_language_enable() { 'settings' => array( 'allowed_values' => array(0 => 'Not private', 1 => 'Private'), ), - )); - $field_private->save(); + ); + $field_private = field_create_field($field_private); - entity_create('field_instance', array( - 'field_name' => $field_private->id(), + $instance = array( + 'field_name' => $field_private['field_name'], 'entity_type' => 'node', 'bundle' => 'page', 'widget' => array( 'type' => 'options_buttons', ), - ))->save(); + ); + $instance = field_create_instance($instance); } /** * Implements hook_disable(). */ function node_access_test_language_disable() { - field_read_instance('node', 'field_private', 'page')->delete(); + field_delete_instance(field_read_instance('node', 'field_private', 'page')); } diff --git a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php index 904509c..f9a817f 100644 --- a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php +++ b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php @@ -22,25 +22,8 @@ class NumberFieldTest extends WebTestBase { */ public static $modules = array('node', 'entity_test', 'number', 'field_ui'); - /** - * A field to use in this class. - * - * @var \Drupal\field\Plugin\Core\Entity\Field - */ protected $field; - - /** - * A field instance to use in this test class. - * - * @var \Drupal\field\Plugin\Core\Entity\FieldInstance - */ protected $instance; - - /** - * A user with permission to view and manage entities and content types. - * - * @var \Drupal\user\UserInterface - */ protected $web_user; public static function getInfo() { @@ -63,22 +46,23 @@ function setUp() { */ function testNumberDecimalField() { // Create a field with settings to validate. - $this->field = entity_create('field_entity', array( + $this->field = array( 'field_name' => drupal_strtolower($this->randomName()), 'type' => 'number_decimal', 'settings' => array( 'precision' => 8, 'scale' => 4, 'decimal_separator' => '.', ) - )); - $this->field->save(); - entity_create('field_instance', array( - 'field_name' => $this->field->id(), + ); + field_create_field($this->field); + $this->instance = array( + 'field_name' => $this->field['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ))->save(); + ); + field_create_instance($this->instance); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->field->id(), array( + ->setComponent($this->field['field_name'], array( 'type' => 'number', 'settings' => array( 'placeholder' => '0.00' @@ -86,7 +70,7 @@ function testNumberDecimalField() { )) ->save(); entity_get_display('entity_test', 'entity_test', 'default') - ->setComponent($this->field->id(), array( + ->setComponent($this->field['field_name'], array( 'type' => 'number_decimal', )) ->save(); diff --git a/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php b/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php index a0cc904..fa7e0fa 100644 --- a/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php +++ b/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php @@ -36,15 +36,17 @@ public function setUp() { // Create number fields and instances for validation. foreach (array('integer', 'float', 'decimal') as $type) { - entity_create('field_entity', array( + $this->field[$type] = array( 'field_name' => 'field_' . $type, 'type' => 'number_' . $type, - ))->save(); - entity_create('field_instance', array( + ); + field_create_field($this->field[$type]); + $this->instance[$type] = array( 'entity_type' => 'entity_test', 'field_name' => 'field_' . $type, 'bundle' => 'entity_test', - ))->save(); + ); + field_create_instance($this->instance[$type]); } } diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php index c270e4a..df3ac66 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php @@ -32,20 +32,23 @@ function setUp() { parent::setUp(); $this->field_name = 'test_options'; - entity_create('field_entity', array( + $this->field = array( 'field_name' => $this->field_name, 'type' => 'list_text', 'cardinality' => 1, 'settings' => array( 'allowed_values_function' => 'options_test_dynamic_values_callback', ), - ))->save(); - $this->instance = entity_create('field_instance', array( + ); + $this->field = field_create_field($this->field); + + $this->instance = array( 'field_name' => $this->field_name, 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev', 'required' => TRUE, - ))->save(); + ); + $this->instance = field_create_instance($this->instance); entity_get_form_display('entity_test_rev', 'entity_test_rev', 'default') ->setComponent($this->field_name, array( 'type' => 'options_select', diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php index 218e413..cc42901 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php @@ -48,9 +48,9 @@ function testUpdateAllowedValues() { $entity = entity_create('entity_test', array()); $entity->{$this->fieldName}->value = 1; $entity->save(); - $this->field->settings['allowed_values'] = array(2 => 'Two'); + $this->field['settings']['allowed_values'] = array(2 => 'Two'); try { - $this->field->save(); + field_update_field($this->field); $this->fail(t('Cannot update a list field to not include keys with existing data.')); } catch (FieldException $e) { @@ -61,8 +61,8 @@ function testUpdateAllowedValues() { $entity->save(); // Removed options do not appear. - $this->field->settings['allowed_values'] = array(2 => 'Two'); - $this->field->save(); + $this->field['settings']['allowed_values'] = array(2 => 'Two'); + field_update_field($this->field); $entity = entity_create('entity_test', array()); $form = \Drupal::entityManager()->getForm($entity); $this->assertTrue(empty($form[$this->fieldName][$langcode][1]), 'Option 1 does not exist'); @@ -71,7 +71,7 @@ function testUpdateAllowedValues() { // Completely new options appear. $this->field['settings']['allowed_values'] = array(10 => 'Update', 20 => 'Twenty'); - $this->field->save(); + field_update_field($this->field); $form = \Drupal::entityManager()->getForm($entity); $this->assertTrue(empty($form[$this->fieldName][$langcode][1]), 'Option 1 does not exist'); $this->assertTrue(empty($form[$this->fieldName][$langcode][2]), 'Option 2 does not exist'); @@ -80,13 +80,15 @@ function testUpdateAllowedValues() { $this->assertTrue(!empty($form[$this->fieldName][$langcode][20]), 'Option 20 exists'); // Options are reset when a new field with the same name is created. - $this->field->delete(); - entity_create('field_entity', $this->fieldDefinition)->save(); - entity_create('field_instance', array( + field_delete_field($this->fieldName); + unset($this->field['id']); + field_create_field($this->fieldDefinition); + $this->instance = array( 'field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ))->save(); + ); + field_create_instance($this->instance); entity_get_form_display('entity_test', 'entity_test', 'default') ->setComponent($this->fieldName, array( 'type' => 'options_buttons', diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php index d34f178..f28fb7c 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php @@ -78,7 +78,7 @@ function testOptionsAllowedValuesInteger() { // Create a node with actual data for the field. $settings = array( 'type' => $this->type, - $this->field_name => array(array('value' => 1)), + $this->field_name =>array(array('value' => 1)), ); $node = $this->drupalCreateNode($settings); @@ -258,15 +258,17 @@ function testOptionsTrimmedValuesText() { */ protected function createOptionsField($type) { // Create a test field and instance. - entity_create('field_entity', array( + $field = array( 'field_name' => $this->field_name, 'type' => $type, - ))->save(); - entity_create('field_instance', array( + ); + field_create_field($field); + $instance = array( 'field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => $this->type, - ))->save(); + ); + field_create_instance($instance); entity_get_form_display('node', $this->type, 'default')->setComponent($this->field_name)->save(); diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php index 8d335c3..f206d0e 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php @@ -22,35 +22,6 @@ class OptionsWidgetsTest extends FieldTestBase { */ public static $modules = array('options', 'entity_test', 'options_test', 'taxonomy', 'field_ui'); - /** - * A field with cardinality 1 to use in this test class. - * - * @var \Drupal\field\Plugin\Core\Entity\Field - */ - protected $card_1; - - /** - * A field with cardinality 2 to use in this test class. - * - * @var \Drupal\field\Plugin\Core\Entity\Field - */ - protected $card_2; - - /** - * A boolean field to use in this test class. - * - * @var \Drupal\field\Plugin\Core\Entity\Field - */ - protected $bool; - - /** - * A user with permission to view and manage entities. - * - * @var \Drupal\user\UserInterface - */ - protected $web_user; - - public static function getInfo() { return array( 'name' => 'Options widgets', @@ -63,7 +34,7 @@ function setUp() { parent::setUp(); // Field with cardinality 1. - $this->card_1 = entity_create('field_entity', array( + $this->card_1 = array( 'field_name' => 'card_1', 'type' => 'list_integer', 'cardinality' => 1, @@ -71,11 +42,11 @@ function setUp() { // Make sure that 0 works as an option. 'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some & unescaped markup'), ), - )); - $this->card_1->save(); + ); + $this->card_1 = field_create_field($this->card_1); // Field with cardinality 2. - $this->card_2 = entity_create('field_entity', array( + $this->card_2 = array( 'field_name' => 'card_2', 'type' => 'list_integer', 'cardinality' => 2, @@ -83,19 +54,19 @@ function setUp() { // Make sure that 0 works as an option. 'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some & unescaped markup'), ), - )); - $this->card_2->save(); + ); + $this->card_2 = field_create_field($this->card_2); // Boolean field. - $this->bool = entity_create('field_entity', array( + $this->bool = array( 'field_name' => 'bool', 'type' => 'list_boolean', 'cardinality' => 1, 'settings' => array( 'allowed_values' => array(0 => 'Zero', 1 => 'Some & unescaped markup'), ), - )); - $this->bool->save(); + ); + $this->bool = field_create_field($this->bool); // Create a web user. $this->web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content')); @@ -107,14 +78,14 @@ function setUp() { */ function testRadioButtons() { // Create an instance of the 'single value' field. - $instance = entity_create('field_instance', array( - 'field_name' => $this->card_1->id(), + $instance = array( + 'field_name' => $this->card_1['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - )); - $instance->save(); + ); + $instance = field_create_instance($instance); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->card_1->id(), array( + ->setComponent($this->card_1['field_name'], array( 'type' => 'options_buttons', )) ->save(); @@ -153,10 +124,10 @@ function testRadioButtons() { $this->assertFieldValues($entity_init, 'card_1', $langcode, array()); // Check that required radios with one option is auto-selected. - $this->card_1->settings['allowed_values'] = array(99 => 'Only allowed value'); - $this->card_1->save(); - $instance->required = TRUE; - $instance->save(); + $this->card_1['settings']['allowed_values'] = array(99 => 'Only allowed value'); + field_update_field($this->card_1); + $instance['required'] = TRUE; + field_update_instance($instance); $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); $this->assertFieldChecked("edit-card-1-$langcode-99"); } @@ -166,14 +137,14 @@ function testRadioButtons() { */ function testCheckBoxes() { // Create an instance of the 'multiple values' field. - $instance = entity_create('field_instance', array( - 'field_name' => $this->card_2->id(), + $instance = array( + 'field_name' => $this->card_2['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - )); - $instance->save(); + ); + $instance = field_create_instance($instance); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->card_2->id(), array( + ->setComponent($this->card_2['field_name'], array( 'type' => 'options_buttons', )) ->save(); @@ -245,10 +216,10 @@ function testCheckBoxes() { $this->assertFieldValues($entity_init, 'card_2', $langcode, array()); // Required checkbox with one option is auto-selected. - $this->card_2->settings['allowed_values'] = array(99 => 'Only allowed value'); - $this->card_2->save(); - $instance->required = TRUE; - $instance->save(); + $this->card_2['settings']['allowed_values'] = array(99 => 'Only allowed value'); + field_update_field($this->card_2); + $instance['required'] = TRUE; + field_update_instance($instance); $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); $this->assertFieldChecked("edit-card-2-$langcode-99"); } @@ -258,15 +229,15 @@ function testCheckBoxes() { */ function testSelectListSingle() { // Create an instance of the 'single value' field. - $instance = entity_create('field_instance', array( - 'field_name' => $this->card_1->id(), + $instance = array( + 'field_name' => $this->card_1['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'required' => TRUE, - )); - $instance->save(); + ); + $instance = field_create_instance($instance); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->card_1->id(), array( + ->setComponent($this->card_1['field_name'], array( 'type' => 'options_select', )) ->save(); @@ -312,8 +283,8 @@ function testSelectListSingle() { $this->assertNoOptionSelected("edit-card-1-$langcode", 2); // Make the field non required. - $instance->required = FALSE; - $instance->save(); + $instance['required'] = FALSE; + field_update_instance($instance); // Display form. $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); @@ -328,7 +299,7 @@ function testSelectListSingle() { $this->card_1['settings']['allowed_values'] = array(); $this->card_1['settings']['allowed_values_function'] = 'options_test_allowed_values_callback'; - $this->card_1->save(); + field_update_field($this->card_1); // Display form: with no field data, nothing is selected $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); @@ -360,14 +331,14 @@ function testSelectListSingle() { */ function testSelectListMultiple() { // Create an instance of the 'multiple values' field. - $instance = entity_create('field_instance', array( - 'field_name' => $this->card_2->id(), + $instance = array( + 'field_name' => $this->card_2['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - )); - $instance->save(); + ); + $instance = field_create_instance($instance); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->card_2->id(), array( + ->setComponent($this->card_2['field_name'], array( 'type' => 'options_select', )) ->save(); @@ -435,8 +406,8 @@ function testSelectListMultiple() { $this->assertFieldValues($entity_init, 'card_2', $langcode, array()); // A required select list does not have an empty key. - $instance->required = TRUE; - $instance->save(); + $instance['required'] = TRUE; + field_update_instance($instance); $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), 'A required select list does not have an empty key.'); @@ -446,11 +417,11 @@ function testSelectListMultiple() { // Test optgroups. // Use a callback function defining optgroups. - $this->card_2->settings['allowed_values'] = array(); - $this->card_2->settings['allowed_values_function'] = 'options_test_allowed_values_callback'; - $this->card_2->save(); - $instance->required = FALSE; - $instance->save(); + $this->card_2['settings']['allowed_values'] = array(); + $this->card_2['settings']['allowed_values_function'] = 'options_test_allowed_values_callback'; + field_update_field($this->card_2); + $instance['required'] = FALSE; + field_update_instance($instance); // Display form: with no field data, nothing is selected. $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); @@ -482,13 +453,14 @@ function testSelectListMultiple() { */ function testOnOffCheckbox() { // Create an instance of the 'boolean' field. - entity_create('field_instance', array( - 'field_name' => $this->bool->id(), + $instance = array( + 'field_name' => $this->bool['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ))->save(); + ); + $instance = field_create_instance($instance); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->bool->id(), array( + ->setComponent($this->bool['field_name'], array( 'type' => 'options_onoff', )) ->save(); @@ -536,12 +508,13 @@ function testOnOffCheckbox() { // Create a test field instance. $fieldUpdate = $this->bool; $fieldUpdate['settings']['allowed_values'] = array(0 => 0, 1 => 'MyOnValue'); - $fieldUpdate->save(); - entity_create('field_instance', array( + field_update_field($fieldUpdate); + $instance = array( 'field_name' => $this->bool['field_name'], 'entity_type' => 'node', 'bundle' => 'page', - ))->save(); + ); + field_create_instance($instance); entity_get_form_display('node', 'page', 'default') ->setComponent($this->bool['field_name'], array( diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php index 82eb211..320126c 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php @@ -107,15 +107,17 @@ function testAttributesInMarkupFile() { $bundle_name = "article"; $field_name = 'file_test'; - entity_create('field_entity', array( + $field = array( 'field_name' => $field_name, 'type' => 'file', - ))->save(); - entity_create('field_instance', array( + ); + field_create_field($field); + $instance = array( 'field_name' => $field_name, 'entity_type' => 'node', 'bundle' => $bundle_name, - ))->save(); + ); + field_create_instance($instance); entity_get_form_display('node', $bundle_name, 'default') ->setComponent($field_name, array( diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php index f35b254..e9526d8 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php @@ -49,8 +49,8 @@ function setUp() { // Make the body field translatable. // The parent class has already created the article and page content types. $field = field_info_field('body'); - $field->translatable = TRUE; - $field->save(); + $field['translatable'] = TRUE; + field_update_field($field); // Create a few page nodes with multilingual body values. $default_format = filter_default_format(); diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php index 48d0293..dfbb7ba 100644 --- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php +++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php @@ -34,20 +34,22 @@ protected function setUp() { parent::setUp(); // Create the test field. - entity_create('field_entity', array( + $field = array( 'settings' => array( 'target_type' => 'entity_test_mulrev', ), 'field_name' => 'field_test_entity_reference', 'type' => 'entity_reference', - ))->save(); + ); + field_create_field($field); // Create the test field instance. - entity_create('field_instance', array( + $instance = array( 'entity_type' => 'entity_test_mulrev', 'field_name' => 'field_test_entity_reference', 'bundle' => 'entity_test_mulrev', - ))->save(); + ); + field_create_instance($instance); } /** diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php b/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php index 74fa8d9..1d9bff6 100644 --- a/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php +++ b/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php @@ -26,13 +26,13 @@ protected function setUp() { $this->installConfig(array('field')); // Auto-create a field for testing. - entity_create('field_entity', array( + field_create_field(array( 'field_name' => 'field_test_text', 'type' => 'text', 'cardinality' => 1, 'translatable' => FALSE, - ))->save(); - entity_create('field_instance', array( + )); + $instance = array( 'entity_type' => 'entity_test_mulrev', 'field_name' => 'field_test_text', 'bundle' => 'entity_test_mulrev', @@ -41,7 +41,7 @@ protected function setUp() { 'type' => 'text_textfield', 'weight' => 0, ), - ))->save(); + ); + field_create_instance($instance); } - } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php index 4615b39..b2eed63 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php @@ -231,16 +231,17 @@ function testEnableModulesFixedList() { 'bundle' => 'entity_test', 'mode' => 'default', )); - $field = entity_create('field_entity', array( + $field = array( 'field_name' => 'test_field', 'type' => 'test_field' - )); - $field->save(); - entity_create('field_instance', array( - 'field_name' => $field->id(), + ); + field_create_field($field); + $instance = array( + 'field_name' => $field['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ))->save(); + ); + field_create_instance($instance); } /** diff --git a/core/modules/syslog/syslog.module b/core/modules/syslog/syslog.module index fe781c3..8af77c1 100644 --- a/core/modules/syslog/syslog.module +++ b/core/modules/syslog/syslog.module @@ -33,7 +33,7 @@ function syslog_help($path, $arg) { $output .= '
LOG_LOCAL0
through LOG_LOCAL7
. For information on Syslog facilities, severity levels, and how to set up syslog.conf or rsyslog.conf, see the syslog.conf or rsyslog.conf manual page on your command line.') . 'LOG_LOCAL0
through LOG_LOCAL7
. For information on Syslog facilities, severity levels, and how to set up syslog.conf, see the syslog.conf manual page on your command line.') . 'LOG_USER
.') . 'The requested URL "@path" was not found on this server.
'; +#$conf['system.performance]['fast_404']['exclude_paths'] = '/\/(?:styles)\//'; +#$conf['system.performance]['fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; +#$conf['system.performance]['fast_404']['html'] = 'The requested URL "@path" was not found on this server.
'; /** * Load local development override configuration, if available.