diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index 411a3bd..ba4e3ed 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -288,7 +288,7 @@ public function build(ContainerBuilder $container) { $container->register('exception_controller', 'Drupal\Core\ExceptionController') ->addArgument(new Reference('content_negotiation')) ->addMethodCall('setContainer', array(new Reference('service_container'))); - $container->register('exception_listener', 'Symfony\Component\HttpKernel\EventListener\ExceptionListener') + $container->register('exception_listener', 'Drupal\Core\EventSubscriber\ExceptionListener') ->addTag('event_subscriber') ->addArgument(array(new Reference('exception_controller'), 'execute')); diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php index e18edbd..e8998f8 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php @@ -96,8 +96,6 @@ public function __construct($entityType) { */ public function create(array $values) { // We have to determine the bundle first. - // @todo Throw an exception if no bundle is passed and we have a bundle key - // defined. $bundle = $this->bundleKey ? $values[$this->bundleKey] : FALSE; $entity = new $this->entityClass(array(), $this->entityType, $bundle); @@ -156,7 +154,7 @@ protected function attachLoad(&$queried_entities, $load_revision = FALSE) { // Map the loaded stdclass records into entity objects and according fields. $queried_entities = $this->mapFromStorageRecords($queried_entities, $load_revision); - // Activate backward-compatibility mode to attach fields. + // Attach fields. if ($this->entityInfo['fieldable']) { // Prepare BC compatible entities before passing them to the field API. $bc_entities = array(); @@ -253,10 +251,7 @@ protected function attachPropertyData(array &$entities, $load_revision = FALSE) foreach ($field_definition as $name => $definition) { // Set translatable properties only. if (isset($data_fields[$name]) && !empty($definition['translatable'])) { - // @todo Figure out how to determine which property has to be set. - // Currently it's guessing, and guessing is evil! - $property_definition = $translation->{$name}->getPropertyDefinitions(); - $translation->{$name}->{key($property_definition)} = $values[$name]; + $translation->{$name}->value = $values[$name]; } // Avoid initializing configurable fields before loading them. elseif (!empty($definition['configurable'])) { @@ -275,12 +270,6 @@ protected function attachPropertyData(array &$entities, $load_revision = FALSE) public function save(EntityInterface $entity) { $transaction = db_transaction(); try { - // Ensure we are dealing with the actual entity. - $entity = $entity->getOriginalEntity(); - - // Sync the changes made in the fields array to the internal values array. - $entity->updateOriginalValues(); - // Load the stored entity, if any. if (!$entity->isNew() && !isset($entity->original)) { $entity->original = entity_load_unchanged($this->entityType, $entity->id()); @@ -290,7 +279,7 @@ public function save(EntityInterface $entity) { $this->invokeHook('presave', $entity); // Create the storage record to be saved. - $record = $this->mapToStorageRecord($entity); + $record = $this->maptoStorageRecord($entity); if (!$entity->isNew()) { if ($entity->isDefaultRevision()) { @@ -457,9 +446,7 @@ protected function mapToStorageRecord(EntityInterface $entity) { protected function mapToRevisionStorageRecord(EntityInterface $entity) { $record = new \stdClass(); foreach ($this->entityInfo['schema_fields_sql']['revision_table'] as $name) { - if (isset($entity->$name->value)) { - $record->$name = $entity->$name->value; - } + $record->$name = $entity->$name->value; } return $record; } @@ -502,11 +489,6 @@ public function delete(array $entities) { $transaction = db_transaction(); try { - // Ensure we are dealing with the actual entities. - foreach ($entities as $id => $entity) { - $entities[$id] = $entity->getOriginalEntity(); - } - $this->preDelete($entities); foreach ($entities as $id => $entity) { $this->invokeHook('predelete', $entity); diff --git a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php index a23f7e4..57215cb 100644 --- a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php +++ b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php @@ -46,23 +46,13 @@ class EntityBCDecorator implements IteratorAggregate, EntityInterface { protected $decorated; /** - * Local cache for field definitions. - * - * @var array - */ - protected $definitions; - - /** * Constructs a Drupal\Core\Entity\EntityCompatibilityDecorator object. * * @param \Drupal\Core\Entity\EntityInterface $decorated * The decorated entity. - * @param array &$definitions - * An array of field definitions. */ - function __construct(EntityNG $decorated, array &$definitions) { + function __construct(EntityNG $decorated) { $this->decorated = $decorated; - $this->definitions = &$definitions; } /** @@ -85,11 +75,6 @@ public function getBCEntity() { * Directly accesses the plain field values, as done in Drupal 7. */ public function &__get($name) { - // Directly return the original property. - if ($name == 'original') { - return $this->decorated->values[$name]; - } - // We access the protected 'values' and 'fields' properties of the decorated // entity via the magic getter - which returns them by reference for us. We // do so, as providing references to these arrays would make $entity->values @@ -103,10 +88,7 @@ public function &__get($name) { // the field objects managed by the entity, thus we need to ensure // $this->decorated->values reflects the latest values first. foreach ($this->decorated->fields[$name] as $langcode => $field) { - // Only set if it's not empty, otherwise there can be ghost values. - if (!$field->isEmpty()) { - $this->decorated->values[$name][$langcode] = $field->getValue(); - } + $this->decorated->values[$name][$langcode] = $field->getValue(); } // The returned values might be changed by reference, so we need to remove // the field object to avoid the field object and the value getting out of @@ -114,39 +96,21 @@ public function &__get($name) { // receive the possibly updated value. unset($this->decorated->fields[$name]); } - // When accessing values for entity properties that have been converted to - // an entity field, provide direct access to the plain value. This makes it - // possible to use the BC-decorator with properties; e.g., $node->title. - if (isset($this->definitions[$name]) && empty($this->definitions[$name]['configurable'])) { - if (!isset($this->decorated->values[$name][LANGUAGE_DEFAULT])) { - $this->decorated->values[$name][LANGUAGE_DEFAULT][0]['value'] = NULL; - } - if (is_array($this->decorated->values[$name][LANGUAGE_DEFAULT])) { - // This will work with all defined properties that have a single value. - // We need to ensure the key doesn't matter. Mostly it's 'value' but - // e.g. EntityReferenceItem uses target_id. - if (isset($this->decorated->values[$name][LANGUAGE_DEFAULT][0]) && count($this->decorated->values[$name][LANGUAGE_DEFAULT][0]) == 1) { - return $this->decorated->values[$name][LANGUAGE_DEFAULT][0][key($this->decorated->values[$name][LANGUAGE_DEFAULT][0])]; - } + // Allow accessing field values in entity default language other than + // LANGUAGE_DEFAULT by mapping the values to LANGUAGE_DEFAULT. This is + // necessary as EntityNG does key values in default language always with + // LANGUAGE_DEFAULT while field API expects them to be keyed by langcode. + $langcode = $this->decorated->language()->langcode; + if ($langcode != LANGUAGE_DEFAULT && isset($this->decorated->values[$name]) && is_array($this->decorated->values[$name])) { + if (isset($this->decorated->values[$name][LANGUAGE_DEFAULT]) && !isset($this->decorated->values[$name][$langcode])) { + $this->decorated->values[$name][$langcode] = &$this->decorated->values[$name][LANGUAGE_DEFAULT]; } - return $this->decorated->values[$name][LANGUAGE_DEFAULT]; } - else { - // Allow accessing field values in an entity default language other than - // LANGUAGE_DEFAULT by mapping the values to LANGUAGE_DEFAULT. This is - // necessary as EntityNG always keys default language values with - // LANGUAGE_DEFAULT while field API expects them to be keyed by langcode. - $langcode = $this->decorated->language()->langcode; - if ($langcode != LANGUAGE_DEFAULT && isset($this->decorated->values[$name]) && is_array($this->decorated->values[$name])) { - if (isset($this->decorated->values[$name][LANGUAGE_DEFAULT]) && !isset($this->decorated->values[$name][$langcode])) { - $this->decorated->values[$name][$langcode] = &$this->decorated->values[$name][LANGUAGE_DEFAULT]; - } - } - if (!isset($this->decorated->values[$name])) { - $this->decorated->values[$name] = NULL; - } - return $this->decorated->values[$name]; + + if (!isset($this->decorated->values[$name])) { + $this->decorated->values[$name] = NULL; } + return $this->decorated->values[$name]; } /** @@ -155,29 +119,20 @@ public function &__get($name) { * Directly writes to the plain field values, as done by Drupal 7. */ public function __set($name, $value) { - $defined = isset($this->definitions[$name]); - // When updating values for entity properties that have been converted to - // an entity field, directly write to the plain value. This makes it - // possible to use the BC-decorator with properties; e.g., $node->title. - if ($defined && empty($this->definitions[$name]['configurable'])) { - $this->decorated->values[$name][LANGUAGE_DEFAULT] = $value; - } - else { - if ($defined && is_array($value)) { - // If field API sets a value with a langcode in entity language, move it - // to LANGUAGE_DEFAULT. - // This is necessary as EntityNG always keys default language values - // with LANGUAGE_DEFAULT while field API expects them to be keyed by - // langcode. - foreach ($value as $langcode => $data) { - if ($langcode != LANGUAGE_DEFAULT && $langcode == $this->decorated->language()->langcode) { - $value[LANGUAGE_DEFAULT] = $data; - unset($value[$langcode]); - } + if (is_array($value) && $definition = $this->decorated->getPropertyDefinition($name)) { + // If field API sets a value with a langcode in entity language, move it + // to LANGUAGE_DEFAULT. + // This is necessary as EntityNG does key values in default language always + // with LANGUAGE_DEFAULT while field API expects them to be keyed by + // langcode. + foreach ($value as $langcode => $data) { + if ($langcode != LANGUAGE_DEFAULT && $langcode == $this->decorated->language()->langcode) { + $value[LANGUAGE_DEFAULT] = $data; + unset($value[$langcode]); } } - $this->decorated->values[$name] = $value; } + $this->decorated->values[$name] = $value; // Remove the field object to avoid the field object and the value getting // out of sync. That way, the next field object instantiated by EntityNG // will hold the updated value. @@ -196,9 +151,8 @@ public function __isset($name) { * Implements the magic method for unset(). */ public function __unset($name) { - // Set the value to NULL. $value = &$this->__get($name); - $value = NULL; + $value = array(); } /** @@ -219,10 +173,6 @@ public function access($operation = 'view', \Drupal\user\Plugin\Core\Entity\User * Forwards the call to the decorated entity. */ public function get($property_name) { - // Ensure this works with not yet defined fields. - if (!isset($this->definitions[$property_name])) { - return $this->__get($property_name); - } return $this->decorated->get($property_name); } @@ -230,10 +180,6 @@ public function get($property_name) { * Forwards the call to the decorated entity. */ public function set($property_name, $value) { - // Ensure this works with not yet defined fields. - if (!isset($this->definitions[$property_name])) { - return $this->__set($property_name, $value); - } return $this->decorated->set($property_name, $value); } diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index 70ac362..8763f6d 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -81,11 +81,6 @@ public function __construct(array $values, $entity_type, $bundle = FALSE) { $this->entityType = $entity_type; $this->bundle = $bundle ? $bundle : $this->entityType; foreach ($values as $key => $value) { - // If the key matches an existing property set the value to the property - // to ensure non converted properties have the correct value. - if (property_exists($this, $key) && isset($value[LANGUAGE_DEFAULT])) { - $this->$key = $value[LANGUAGE_DEFAULT]; - } $this->values[$key] = $value; } $this->init(); @@ -274,7 +269,7 @@ public function language() { if ($this->getPropertyDefinition('langcode')) { $language = $this->get('langcode')->language; } - if (empty($language)) { + if (!isset($language)) { // Make sure we return a proper language object. $language = new Language(array('langcode' => LANGUAGE_NOT_SPECIFIED)); } @@ -372,9 +367,7 @@ public function translations() { */ public function getBCEntity() { if (!isset($this->bcEntity)) { - // Initialize field definitions so that we can pass them by reference. - $this->getPropertyDefinitions(); - $this->bcEntity = new EntityBCDecorator($this, $this->fieldDefinitions); + $this->bcEntity = new EntityBCDecorator($this); } return $this->bcEntity; } @@ -490,12 +483,6 @@ public function createDuplicate() { $uuid = new Uuid(); $duplicate->{$entity_info['entity_keys']['uuid']}->value = $uuid->generate(); } - - // Check whether the entity type supports revisions and initialize it if so. - if (!empty($entity_info['entity_keys']['revision'])) { - $duplicate->{$entity_info['entity_keys']['revision']}->value = NULL; - } - return $duplicate; } diff --git a/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php b/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php index 62edc8d..4159f04 100644 --- a/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php @@ -37,15 +37,6 @@ protected $properties = array(); /** - * Holds any non-property values that get set on the object. - * - * @todo: Remove or refactor once EntityNG conversion is complete. - * - * @var array - */ - protected $extraValues = array(); - - /** * Overrides ContextAwareTypedData::__construct(). */ public function __construct(array $definition, $name = NULL, ContextAwareInterface $parent = NULL) { @@ -77,7 +68,7 @@ public function getValue() { foreach ($this->getProperties() as $name => $property) { $values[$name] = $property->getValue(); } - return $values + $this->extraValues; + return $values; } /** @@ -101,11 +92,9 @@ public function setValue($values) { else { $property->setValue(NULL); } - unset($values[$name]); } // @todo: Throw an exception for invalid values once conversion is // totally completed. - $this->extraValues = $values; } /** @@ -140,13 +129,7 @@ public function set($property_name, $value) { * Implements \Drupal\Core\Entity\Field\FieldItemInterface::__get(). */ public function __get($name) { - if (isset($this->properties[$name])) { - return $this->properties[$name]->getValue(); - } - // The property is unknown, so try to get it from the extra values. - elseif (isset($this->extraValues[$name])) { - return $this->extraValues[$name]; - } + return $this->get($name)->getValue(); } /** @@ -157,13 +140,7 @@ public function __set($name, $value) { if ($value instanceof TypedDataInterface) { $value = $value->getValue(); } - if (isset($this->properties[$name])) { - $this->properties[$name]->setValue($value); - } - else { - // The property is unknown, so set it to the extra values. - $this->extraValues[$name] = $value; - } + $this->get($name)->setValue($value); } /** diff --git a/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php b/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php index 695a7ca..496a720 100644 --- a/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php @@ -86,34 +86,10 @@ public function setValue($values) { } /** - * Overrides \Drupal\Core\Entity\Field\FieldItemBase::__set(). - */ - public function __set($name, $value) { - parent::__set($name, $value); - } - - /** - * Overrides \Drupal\Core\Entity\Field\FieldItemBase::__get(). - */ - public function __get($name) { - $name = ($name == 'value') ? 'target_id' : $name; - return parent::__get($name); - } - - /** * Overrides \Drupal\Core\Entity\Field\FieldItemBase::get(). */ public function get($property_name) { $property_name = ($property_name == 'value') ? 'target_id' : $property_name; return parent::get($property_name); } - - /** - * Implements \Drupal\Core\Entity\Field\FieldItemInterface::__isset(). - */ - public function __isset($property_name) { - $property_name = ($property_name == 'value') ? 'target_id' : $property_name; - return parent::__isset($property_name); - } - } diff --git a/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php b/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php index fdd4d38..691868d 100644 --- a/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php +++ b/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php @@ -54,13 +54,6 @@ class EntityWrapper extends ContextAwareTypedData implements IteratorAggregate, protected $id; /** - * If set, a new entity to create and reference. - * - * @var \Drupal\Core\Entity\EntityInterface - */ - protected $newEntity; - - /** * Overrides ContextAwareTypedData::__construct(). */ public function __construct(array $definition, $name = NULL, ContextAwareInterface $parent = NULL) { @@ -72,9 +65,6 @@ public function __construct(array $definition, $name = NULL, ContextAwareInterfa * Overrides \Drupal\Core\TypedData\TypedData::getValue(). */ public function getValue() { - if (isset($this->newEntity)) { - return $this->newEntity; - } $source = $this->getIdSource(); $id = $source ? $source->getValue() : $this->id; return $id ? entity_load($this->entityType, $id) : NULL; @@ -95,17 +85,10 @@ protected function getIdSource() { * Both the entity ID and the entity object may be passed as value. */ public function setValue($value) { - // Support passing in the entity object. If it's not yet saved we have - // to store the whole entity such that it could be saved later on. - if ($value instanceof EntityInterface && $value->isNew()) { - $this->newEntity = $value; - $this->entityType = $value->entityType(); - $value = FALSE; - } - elseif ($value instanceof EntityInterface) { + // Support passing in the entity object. + if ($value instanceof EntityInterface) { $this->entityType = $value->entityType(); $value = $value->id(); - unset($this->newEntity); } elseif (isset($value) && !(is_scalar($value) && !empty($this->definition['constraints']['EntityType']))) { throw new InvalidArgumentException('Value is not a valid entity.'); diff --git a/core/lib/Drupal/Core/EventSubscriber/ExceptionListener.php b/core/lib/Drupal/Core/EventSubscriber/ExceptionListener.php new file mode 100644 index 0000000..f71b351 --- /dev/null +++ b/core/lib/Drupal/Core/EventSubscriber/ExceptionListener.php @@ -0,0 +1,83 @@ +controller = $controller; + } + + public function onKernelException(GetResponseForExceptionEvent $event) { + static $handling; + + if ($handling) { + return FALSE; + } + + $handling = TRUE; + + $exception = $event->getException(); + $request = $event->getRequest(); + // Do not put a line in the server logs for every HTTP error. + if (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) { + error_log(sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine())); + } + + $attributes = array( + '_controller' => $this->controller, + 'exception' => FlattenException::create($exception), + 'logger' => NULL, + 'format' => $request->getRequestFormat(), + ); + + $request = $request->duplicate(NULL, NULL, $attributes); + $request->setMethod('GET'); + + try { + $response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, TRUE); + } + catch (\Exception $e) { + $message = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage()); + error_log($message); + // Set handling to false otherwise it won't be able to handle further + // exceptions. + $handling = FALSE; + return; + } + + $event->setResponse($response); + $handling = FALSE; + } + + public static function getSubscribedEvents() { + return array( + KernelEvents::EXCEPTION => array('onKernelException', -128), + ); + } +} diff --git a/core/lib/Drupal/Core/ExceptionController.php b/core/lib/Drupal/Core/ExceptionController.php index 48bb6a1..c8c6a34 100644 --- a/core/lib/Drupal/Core/ExceptionController.php +++ b/core/lib/Drupal/Core/ExceptionController.php @@ -13,6 +13,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Exception\FlattenException; +use Drupal\Core\EventSubscriber\ExceptionListener; /** * This controller handles HTTP errors generated by the routing system. @@ -137,13 +138,13 @@ public function on404Html(FlattenException $exception, Request $request) { watchdog('page not found', check_plain($request->attributes->get('system_path')), NULL, WATCHDOG_WARNING); // Check for and return a fast 404 page if configured. - $config = config('system.performance'); + $config = config('system.fast_404'); - $exclude_paths = $config->get('fast_404.exclude_paths'); - if ($config->get('fast_404.enabled') && $exclude_paths && !preg_match($exclude_paths, $request->getPathInfo())) { - $fast_paths = $config->get('fast_404.paths'); + $exclude_paths = $config->get('exclude_paths'); + if ($config->get('enabled') && $exclude_paths && !preg_match($exclude_paths, $request->getPathInfo())) { + $fast_paths = $config->get('paths'); if ($fast_paths && preg_match($fast_paths, $request->getPathInfo())) { - $fast_404_html = $config->get('fast_404.html'); + $fast_404_html = $config->get('html'); $fast_404_html = strtr($fast_404_html, array('@path' => check_plain($request->getUri()))); return new Response($fast_404_html, 404); } diff --git a/core/lib/Drupal/Core/TypedData/Type/Language.php b/core/lib/Drupal/Core/TypedData/Type/Language.php index 2226a7e..ac84070 100644 --- a/core/lib/Drupal/Core/TypedData/Type/Language.php +++ b/core/lib/Drupal/Core/TypedData/Type/Language.php @@ -8,7 +8,6 @@ namespace Drupal\Core\TypedData\Type; use InvalidArgumentException; -use Drupal\Core\Language\Language as LanguageObject; use Drupal\Core\TypedData\ContextAwareTypedData; /** @@ -41,8 +40,7 @@ public function getValue() { $source = $this->getLanguageCodeSource(); $langcode = $source ? $source->getValue() : $this->langcode; if ($langcode) { - $language = language_load($langcode); - return $language ?: new LanguageObject(array('langcode' => $this->langcode)); + return language_load($langcode); } } diff --git a/core/modules/book/book.admin.inc b/core/modules/book/book.admin.inc index ff5dac8..3ffaf55 100644 --- a/core/modules/book/book.admin.inc +++ b/core/modules/book/book.admin.inc @@ -5,7 +5,7 @@ * Administration page callbacks for the Book module. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; /** * Page callback: Returns an administrative overview of all books. @@ -45,7 +45,7 @@ function book_admin_overview() { /** * Form constructor for administering a single book's hierarchy. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node of the top-level page in the book. * * @see book_menu() @@ -53,7 +53,7 @@ function book_admin_overview() { * @see book_admin_edit_submit() * @ingroup forms */ -function book_admin_edit($form, $form_state, EntityInterface $node) { +function book_admin_edit($form, $form_state, Node $node) { drupal_set_title($node->label()); $form['#node'] = $node; _book_admin_table($node, $form); @@ -136,14 +136,14 @@ function book_admin_edit_submit($form, &$form_state) { /** * Builds the table portion of the form for the book administration page. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node of the top-level page in the book. * @param $form * The form that is being modified, passed by reference. * * @see book_admin_edit() */ -function _book_admin_table(EntityInterface $node, &$form) { +function _book_admin_table(Node $node, &$form) { $form['table'] = array( '#theme' => 'book_admin_table', '#tree' => TRUE, diff --git a/core/modules/book/book.install b/core/modules/book/book.install index 7d70a02..700421e 100644 --- a/core/modules/book/book.install +++ b/core/modules/book/book.install @@ -99,12 +99,18 @@ function book_update_8000() { )); $allowed_types = update_variable_get('book_allowed_types', FALSE); if ($allowed_types) { - // Ensure consistent ordering of allowed_types. - // @see book_admin_settings_submit() - sort($allowed_types); - + // In Drupal 7 the variable book_allowed_types was stored like this: + // array( + // 0 => 'book', + // 1 => 'article', + // ) + // In Drupal 8 book.settings:allowed_types should be stored like this: + // array( + // 'book' => 'book', + // 'article' => 'article', + // ) config('book.settings') - ->set('allowed_types', $allowed_types) + ->set('allowed_types', drupal_map_assoc($allowed_types)) ->save(); } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 26f324e..f6c0208 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -5,7 +5,7 @@ * Allows users to create and organize related content in an outline. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\entity\Plugin\Core\Entity\EntityDisplay; use Drupal\Core\Template\Attribute; use Drupal\menu_link\Plugin\Core\Entity\MenuLink; @@ -89,12 +89,12 @@ function book_permission() { /** * Adds relevant book links to the node's links. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The book page node to add links to. * @param $view_mode * The view mode of the node. */ -function book_node_view_link(EntityInterface $node, $view_mode) { +function book_node_view_link(Node $node, $view_mode) { $links = array(); if (isset($node->book['depth'])) { @@ -199,10 +199,10 @@ function book_menu() { /** * Access callback: Determines if the book export page is accessible. * - * @param \Drupal\node\Plugin\Core\Entity\EntityInterface $node + * @param \Drupal\node\Plugin\Core\Entity\Node $node * The node whose export page is to be viewed. */ -function book_export_access(EntityInterface $node) { +function book_export_access(Node $node) { return user_access('access printer-friendly version') && node_access('view', $node); } @@ -213,24 +213,24 @@ function book_export_access(EntityInterface $node) { * - admin/content/book/%node * - node/%node/outline * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node whose outline tab is to be viewed. * * @see book_menu() */ -function _book_outline_access(EntityInterface $node) { +function _book_outline_access(Node $node) { return user_access('administer book outlines') && node_access('view', $node); } /** * Access callback: Determines if the user can remove nodes from the outline. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node to remove from the outline. * * @see book_menu() */ -function _book_outline_remove_access(EntityInterface $node) { +function _book_outline_remove_access(Node $node) { return _book_node_is_removable($node) && _book_outline_access($node); } @@ -240,10 +240,10 @@ function _book_outline_remove_access(EntityInterface $node) { * A node can be removed from a book if it is actually in a book and it either * is not a top-level page or is a top-level page with no children. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node to remove from the outline. */ -function _book_node_is_removable(EntityInterface $node) { +function _book_node_is_removable($node) { return (!empty($node->book['bid']) && (($node->book['bid'] != $node->nid) || !$node->book['has_children'])); } @@ -420,10 +420,10 @@ function _book_parent_select($book_link) { /** * Builds the common elements of the book form for the node and outline forms. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node whose form is being viewed. */ -function _book_add_form_elements(&$form, &$form_state, EntityInterface $node) { +function _book_add_form_elements(&$form, &$form_state, Node $node) { // If the form is being processed during the Ajax callback of our book bid // dropdown, then $form_state will hold the value that was selected. if (isset($form_state['values']['book'])) { @@ -523,13 +523,13 @@ function book_form_update($form, $form_state) { * outline through node addition, node editing, node deletion, or the outline * tab. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that is being saved, added, deleted, or moved. * * @return * TRUE if the menu link was saved; FALSE otherwise. */ -function _book_update_outline(EntityInterface $node) { +function _book_update_outline(Node $node) { if (empty($node->book['bid'])) { return FALSE; } @@ -788,7 +788,7 @@ function book_node_load($nodes, $types) { /** * Implements hook_node_view(). */ -function book_node_view(EntityInterface $node, EntityDisplay $display, $view_mode) { +function book_node_view(Node $node, EntityDisplay $display, $view_mode) { if ($view_mode == 'full') { if (!empty($node->book['bid']) && empty($node->in_preview)) { $node->content['book_navigation'] = array( @@ -820,7 +820,7 @@ function book_page_alter(&$page) { /** * Implements hook_node_presave(). */ -function book_node_presave(EntityInterface $node) { +function book_node_presave(Node $node) { // Always save a revision for non-administrators. if (!empty($node->book['bid']) && !user_access('administer nodes')) { $node->setNewRevision(); @@ -834,7 +834,7 @@ function book_node_presave(EntityInterface $node) { /** * Implements hook_node_insert(). */ -function book_node_insert(EntityInterface $node) { +function book_node_insert(Node $node) { if (!empty($node->book['bid'])) { if ($node->book['bid'] == 'new') { // New nodes that are their own book. @@ -849,7 +849,7 @@ function book_node_insert(EntityInterface $node) { /** * Implements hook_node_update(). */ -function book_node_update(EntityInterface $node) { +function book_node_update(Node $node) { if (!empty($node->book['bid'])) { if ($node->book['bid'] == 'new') { // New nodes that are their own book. @@ -864,7 +864,7 @@ function book_node_update(EntityInterface $node) { /** * Implements hook_node_predelete(). */ -function book_node_predelete(EntityInterface $node) { +function book_node_predelete(Node $node) { if (!empty($node->book['bid'])) { if ($node->nid == $node->book['bid']) { // Handle deletion of a top-level post. @@ -888,7 +888,7 @@ function book_node_predelete(EntityInterface $node) { /** * Implements hook_node_prepare(). */ -function book_node_prepare(EntityInterface $node) { +function book_node_prepare(Node $node) { // Prepare defaults for the add/edit form. if (empty($node->book) && (user_access('add content to books') || user_access('administer book outlines'))) { $node->book = array(); @@ -1184,7 +1184,7 @@ function book_export_traverse($tree, $visit_func) { /** * Generates printer-friendly HTML for a node. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that will be output. * @param $children * (optional) All the rendered child nodes within the current node. Defaults @@ -1195,7 +1195,7 @@ function book_export_traverse($tree, $visit_func) { * * @see book_export_traverse() */ -function book_node_export(EntityInterface $node, $children = '') { +function book_node_export(Node $node, $children = '') { $build = node_view($node, 'print'); unset($build['#theme']); // @todo Rendering should happen in the template using render(). @@ -1230,28 +1230,27 @@ function template_preprocess_book_node_export_html(&$variables) { * A Boolean TRUE if the node type can be included in books; otherwise, FALSE. */ function book_type_is_allowed($type) { - return in_array($type, config('book.settings')->get('allowed_types')); + $allowed_types = config('book.settings')->get('allowed_types'); + return isset($allowed_types[$type]); } /** * Implements hook_node_type_update(). * - * Updates book.settings configuration object if the machine-readable name of a - * node type is changed. + * Updates the Book module's persistent variables if the machine-readable name + * of a node type is changed. */ function book_node_type_update($type) { if (!empty($type->old_type) && $type->old_type != $type->type) { $config = config('book.settings'); // Update the list of node types that are allowed to be added to books. $allowed_types = $config->get('allowed_types'); - $old_key = array_search($type->old_type, $allowed_types); - if ($old_key !== FALSE) { + + if (isset($allowed_types[$type->old_type])) { // Replace the old machine-readable name with the new machine-readable // name. - $allowed_types[$old_key] = $type->type; - // Ensure that the allowed_types array is sorted consistently. - // @see book_admin_settings_submit() - sort($allowed_types); + $allowed_types[$type->type] = $type->type; + unset($allowed_types[$type->old_type]); $config->set('allowed_types', $allowed_types); } diff --git a/core/modules/book/book.pages.inc b/core/modules/book/book.pages.inc index 2418591..a971aa6 100644 --- a/core/modules/book/book.pages.inc +++ b/core/modules/book/book.pages.inc @@ -5,7 +5,7 @@ * User page callbacks for the book module. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -39,7 +39,7 @@ function book_render() { * currently supported in book module: * - html: Printer-friendly HTML. * Other types may be supported in contributed modules. - * @param \Drupal\node\Plugin\Core\Entity\EntityInterface $node + * @param \Drupal\node\Plugin\Core\Entity\Node $node * The node to export. * * @return @@ -50,7 +50,7 @@ function book_render() { * * @see book_menu() */ -function book_export($type, EntityInterface $node) { +function book_export($type, Node $node) { $type = drupal_strtolower($type); $export_function = 'book_export_' . $type; @@ -84,7 +84,7 @@ function book_export($type, EntityInterface $node) { * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ -function book_export_html(EntityInterface $node) { +function book_export_html(Node $node) { if (user_access('access printer-friendly version')) { if (isset($node->book)) { $tree = book_menu_subtree_data($node->book); @@ -103,7 +103,7 @@ function book_export_html(EntityInterface $node) { /** * Page callback: Shows the outline form for a single node. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The book node for which to show the outline. * * @return string @@ -111,7 +111,7 @@ function book_export_html(EntityInterface $node) { * * @see book_menu() */ -function book_outline(EntityInterface $node) { +function book_outline(Node $node) { drupal_set_title($node->label()); return drupal_get_form('book_outline_form', $node); } @@ -121,14 +121,14 @@ function book_outline(EntityInterface $node) { * * Allows handling of all book outline operations via the outline tab. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The book node for which to show the outline. * * @see book_outline_form_submit() * @see book_remove_button_submit() * @ingroup forms */ -function book_outline_form($form, &$form_state, EntityInterface $node) { +function book_outline_form($form, &$form_state, Node $node) { if (!isset($node->book)) { // The node is not part of any book yet - set default options. $node->book = _book_link_defaults($node->nid); @@ -208,14 +208,14 @@ function book_outline_form_submit($form, &$form_state) { /** * Form constructor to confirm removal of a node from a book. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node to delete. * * @see book_remove_form_submit() * @see book_menu() * @ingroup forms */ -function book_remove_form($form, &$form_state, EntityInterface $node) { +function book_remove_form($form, &$form_state, Node $node) { $form['#node'] = $node; $title = array('%title' => $node->label()); diff --git a/core/modules/book/config/book.settings.yml b/core/modules/book/config/book.settings.yml index fb18d6d..6a57d5d 100644 --- a/core/modules/book/config/book.settings.yml +++ b/core/modules/book/config/book.settings.yml @@ -1,5 +1,5 @@ allowed_types: - - book + book: book block: navigation: mode: 'all pages' diff --git a/core/modules/book/lib/Drupal/book/BookSettingsForm.php b/core/modules/book/lib/Drupal/book/BookSettingsForm.php index 3de9899..614f31e 100644 --- a/core/modules/book/lib/Drupal/book/BookSettingsForm.php +++ b/core/modules/book/lib/Drupal/book/BookSettingsForm.php @@ -63,14 +63,9 @@ public function validateForm(array &$form, array &$form_state) { * Implements \Drupal\Core\Form\FormInterface::submitForm(). */ public function submitForm(array &$form, array &$form_state) { - $allowed_types = array_filter($form_state['values']['book_allowed_types']); - // We need to save the allowed types in an array ordered by machine_name so - // that we can save them in the correct order if node type changes. - // @see book_node_type_update(). - sort($allowed_types); $this->configFactory->get('book.settings') - // Remove unchecked types. - ->set('allowed_types', $allowed_types) + // Remove unchecked types. + ->set('allowed_types', array_filter($form_state['values']['book_allowed_types'])) ->set('child_type', $form_state['values']['book_child_type']) ->save(); diff --git a/core/modules/book/lib/Drupal/book/Tests/BookTest.php b/core/modules/book/lib/Drupal/book/Tests/BookTest.php index 4601342..35174f8 100644 --- a/core/modules/book/lib/Drupal/book/Tests/BookTest.php +++ b/core/modules/book/lib/Drupal/book/Tests/BookTest.php @@ -7,7 +7,7 @@ namespace Drupal\book\Tests; -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\simpletest\WebTestBase; /** @@ -67,7 +67,7 @@ function setUp() { // Create users. $this->book_author = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books')); $this->web_user = $this->drupalCreateUser(array('access printer-friendly version', 'node test view')); - $this->admin_user = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'node test view', 'administer content types', 'administer site configuration')); + $this->admin_user = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'node test view', 'administer content types')); } /** @@ -145,7 +145,7 @@ function testBook() { * * Also checks the printer friendly version of the outline. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * Node to check. * @param $nodes * Nodes that should be in outline. @@ -158,7 +158,7 @@ function testBook() { * @param array $breadcrumb * The nodes that should be displayed in the breadcrumb. */ - function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = FALSE, $next = FALSE, array $breadcrumb) { + function checkBookNode(Node $node, $nodes, $previous = FALSE, $up = FALSE, $next = FALSE, array $breadcrumb) { // $number does not use drupal_static as it should not be reset // since it uniquely identifies each call to checkBookNode(). static $number = 0; @@ -405,81 +405,6 @@ function testBookNodeTypeChange() { // the new machine and the old one has been removed. $this->assertTrue(book_type_is_allowed('bar'), 'Config book.settings:allowed_types contains the updated node type machine name "bar".'); $this->assertFalse(book_type_is_allowed('book'), 'Config book.settings:allowed_types does not contain the old node type machine name "book".'); - - $edit = array( - 'name' => 'Basic page', - 'title_label' => 'Title for basic page', - 'type' => 'page', - ); - $this->drupalPost('admin/structure/types/add', $edit, t('Save content type')); - - // Add page to the allowed node types. - $edit = array( - 'book_allowed_types[page]' => 'page', - 'book_allowed_types[bar]' => 'bar', - ); - - $this->drupalPost('admin/content/book/settings', $edit, t('Save configuration')); - $this->assertTrue(book_type_is_allowed('bar'), 'Config book.settings:allowed_types contains the bar node type.'); - $this->assertTrue(book_type_is_allowed('page'), 'Config book.settings:allowed_types contains the page node type.'); - - // Test the order of the book.settings::allowed_types configuration is as - // expected. The point of this test is to prove that after changing a node - // type going to admin/content/book/settings and pressing save without - // changing anything should not alter the book.settings configuration. The - // order will be: - // @code - // array( - // 'bar', - // 'page', - // ); - // @endcode - $current_config = config('book.settings')->init()->get(); - $this->drupalPost('admin/content/book/settings', array(), t('Save configuration')); - $this->assertIdentical($current_config, config('book.settings')->init()->get()); - - // Change the name, machine name and description. - $edit = array( - 'name' => 'Zebra book', - 'type' => 'zebra', - ); - $this->drupalPost('admin/structure/types/manage/bar', $edit, t('Save content type')); - $this->assertTrue(book_type_is_allowed('zebra'), 'Config book.settings:allowed_types contains the zebra node type.'); - $this->assertTrue(book_type_is_allowed('page'), 'Config book.settings:allowed_types contains the page node type.'); - - // Test the order of the book.settings::allowed_types configuration is as - // expected. The order should be: - // @code - // array( - // 'page', - // 'zebra', - // ); - // @endcode - $current_config = config('book.settings')->init()->get(); - $this->drupalPost('admin/content/book/settings', array(), t('Save configuration')); - $this->assertIdentical($current_config, config('book.settings')->init()->get()); - - $edit = array( - 'name' => 'Animal book', - 'type' => 'zebra', - ); - $this->drupalPost('admin/structure/types/manage/zebra', $edit, t('Save content type')); - - // Test the order of the book.settings::allowed_types configuration is as - // expected. The order should be: - // @code - // array( - // 'page', - // 'zebra', - // ); - // @endcode - $current_config = config('book.settings')->init()->get(); - $this->drupalPost('admin/content/book/settings', array(), t('Save configuration')); - $this->assertIdentical($current_config, config('book.settings')->init()->get()); - - // Ensure that after all the node type changes book.settings:child_type has - // the expected value. - $this->assertEqual(config('book.settings')->get('child_type'), 'zebra'); } /** diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index dd87b29..9ee6f81 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -9,6 +9,7 @@ * book page, etc. */ +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\entity\Plugin\Core\Entity\EntityDisplay; use Drupal\file\Plugin\Core\Entity\File; use Drupal\Core\Entity\EntityInterface; @@ -490,13 +491,13 @@ function comment_get_recent($number = 10) { * Number of comments. * @param $new_replies * Number of new replies. - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The first new comment node. * * @return * "page=X" if the page number is greater than zero; empty string otherwise. */ -function comment_new_page_count($num_comments, $new_replies, EntityInterface $node) { +function comment_new_page_count($num_comments, $new_replies, Node $node) { $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED); $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50); $pagenum = NULL; @@ -574,7 +575,7 @@ function theme_comment_block($variables) { /** * Implements hook_node_view(). */ -function comment_node_view(EntityInterface $node, EntityDisplay $display, $view_mode) { +function comment_node_view(Node $node, EntityDisplay $display, $view_mode) { $links = array(); if ($node->comment != COMMENT_NODE_HIDDEN) { @@ -682,14 +683,14 @@ function comment_node_view(EntityInterface $node, EntityDisplay $display, $view_ /** * Builds the comment-related elements for node detail pages. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node entity for which to build the comment-related elements. * * @return * A renderable array representing the comment-related page elements for the * node. */ -function comment_node_page_additions(EntityInterface $node) { +function comment_node_page_additions(Node $node) { $additions = array(); // Only attempt to render comments if the node has visible comments. @@ -727,7 +728,7 @@ function comment_node_page_additions(EntityInterface $node) { /** * Returns a rendered form to comment the given node. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node entity to be commented. * @param int $pid * (optional) Some comments are replies to other comments. In those cases, @@ -736,7 +737,7 @@ function comment_node_page_additions(EntityInterface $node) { * @return array * The renderable array for the comment addition form. */ -function comment_add(EntityInterface $node, $pid = NULL) { +function comment_add(Node $node, $pid = NULL) { $values = array('nid' => $node->nid, 'pid' => $pid, 'node_type' => 'comment_node_' . $node->type); $comment = entity_create('comment', $values); return entity_get_form($comment); @@ -745,7 +746,7 @@ function comment_add(EntityInterface $node, $pid = NULL) { /** * Retrieves comments for a thread. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node whose comment(s) needs rendering. * @param $mode * The comment display mode; COMMENT_MODE_FLAT or COMMENT_MODE_THREADED. @@ -809,7 +810,7 @@ function comment_add(EntityInterface $node, $pid = NULL) { * spoil the reverse ordering, "ORDER BY thread ASC" -- here, we do not need * to consider the trailing "/" so we use a substring only. */ -function comment_get_thread(EntityInterface $node, $mode, $comments_per_page) { +function comment_get_thread(Node $node, $mode, $comments_per_page) { $query = db_select('comment', 'c') ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); $query->addField('c', 'cid'); @@ -919,13 +920,13 @@ function comment_view(Comment $comment, $view_mode = 'full', $langcode = NULL) { * * @param Drupal\comment\Comment $comment * The comment object. - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node the comment is attached to. * * @return * A structured array of links. */ -function comment_links(Comment $comment, EntityInterface $node) { +function comment_links(Comment $comment, Node $node) { $links = array(); if ($node->comment == COMMENT_NODE_OPEN) { if (user_access('administer comments') && user_access('post comments')) { @@ -1199,7 +1200,7 @@ function comment_node_load($nodes, $types) { /** * Implements hook_node_prepare(). */ -function comment_node_prepare(EntityInterface $node) { +function comment_node_prepare(Node $node) { if (!isset($node->comment)) { $node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN); } @@ -1208,7 +1209,7 @@ function comment_node_prepare(EntityInterface $node) { /** * Implements hook_node_insert(). */ -function comment_node_insert(EntityInterface $node) { +function comment_node_insert(Node $node) { // Allow bulk updates and inserts to temporarily disable the // maintenance of the {node_comment_statistics} table. if (variable_get('comment_maintain_node_statistics', TRUE)) { @@ -1228,7 +1229,7 @@ function comment_node_insert(EntityInterface $node) { /** * Implements hook_node_predelete(). */ -function comment_node_predelete(EntityInterface $node) { +function comment_node_predelete(Node $node) { $cids = db_query('SELECT cid FROM {comment} WHERE nid = :nid', array(':nid' => $node->nid))->fetchCol(); comment_delete_multiple($cids); db_delete('node_comment_statistics') @@ -1239,7 +1240,7 @@ function comment_node_predelete(EntityInterface $node) { /** * Implements hook_node_update_index(). */ -function comment_node_update_index(EntityInterface $node, $langcode) { +function comment_node_update_index(Node $node, $langcode) { $index_comments = &drupal_static(__FUNCTION__); if ($index_comments === NULL) { @@ -1288,7 +1289,7 @@ function comment_update_index() { * Formats a comment count string and returns it, for display with search * results. */ -function comment_node_search_result(EntityInterface $node) { +function comment_node_search_result(Node $node) { // Do not make a string if comments are hidden. if (user_access('access comments') && $node->comment != COMMENT_NODE_HIDDEN) { $comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->nid))->fetchField(); diff --git a/core/modules/comment/comment.pages.inc b/core/modules/comment/comment.pages.inc index be4ef3f..da359a4 100644 --- a/core/modules/comment/comment.pages.inc +++ b/core/modules/comment/comment.pages.inc @@ -5,7 +5,7 @@ * User page callbacks for the Comment module. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -21,7 +21,7 @@ * The node or comment that is being replied to must appear above the comment * form to provide the user context while authoring the comment. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * Every comment belongs to a node. This is that node. * @param $pid * (optional) Some comments are replies to other comments. In those cases, @@ -34,7 +34,7 @@ * - comment_parent: If the comment is a reply to another comment. * - comment_form: The comment form as a renderable array. */ -function comment_reply(EntityInterface $node, $pid = NULL) { +function comment_reply(Node $node, $pid = NULL) { // Set the breadcrumb trail. drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->label(), 'node/' . $node->nid))); $op = isset($_POST['op']) ? $_POST['op'] : ''; diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php index 77e441f..274b37b 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php @@ -56,7 +56,7 @@ protected function attachLoad(&$records, $load_revision = FALSE) { */ public function create(array $values) { if (empty($values['node_type']) && !empty($values['nid'])) { - $node = node_load(is_object($values['nid']) ? $values['nid']->value : $values['nid']); + $node = node_load($values['nid']); $values['node_type'] = 'comment_node_' . $node->type; } return parent::create($values); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index c023c56..e49f2f3 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -80,7 +80,7 @@ function setUp() { /** * Posts a comment. * - * @param \Drupal\Core\Entity\EntityInterface $node|null $node + * @param Drupal\node\Node|null $node * Node to post comment on or NULL to post to the previusly loaded page. * @param $comment * Comment body. diff --git a/core/modules/dblog/dblog.admin.inc b/core/modules/dblog/dblog.admin.inc index d432b5b..5988866 100644 --- a/core/modules/dblog/dblog.admin.inc +++ b/core/modules/dblog/dblog.admin.inc @@ -58,29 +58,13 @@ function dblog_overview() { ->execute(); foreach ($result as $dblog) { - // Check for required properties. - if (isset($dblog->message) && isset($dblog->variables)) { - // Messages without variables or user specified text. - if ($dblog->variables === 'N;') { - $message = $dblog->message; - } - // Message to translate with injected variables. - else { - $message = t($dblog->message, unserialize($dblog->variables)); - } - if (isset($dblog->wid)) { - // Truncate link_text to 56 chars of message. - $log_text = truncate_utf8(filter_xss($message, array()), 56, TRUE, TRUE); - $message = l($log_text, 'admin/reports/event/' . $dblog->wid, array('html' => TRUE)); - } - } $rows[] = array('data' => array( // Cells array('class' => array('icon')), t($dblog->type), format_date($dblog->timestamp, 'short'), - $message, + theme('dblog_message', array('event' => $dblog, 'link' => TRUE)), theme('username', array('account' => $dblog)), filter_xss($dblog->link), ), @@ -141,18 +125,7 @@ function dblog_top($type) { $rows = array(); foreach ($result as $dblog) { - // Check for required properties. - if (isset($dblog->message) && isset($dblog->variables)) { - // Messages without variables or user specified text. - if ($dblog->variables === 'N;') { - $message = $dblog->message; - } - // Message to translate with injected variables. - else { - $message = t($dblog->message, unserialize($dblog->variables)); - } - } - $rows[] = array($dblog->count, $message); + $rows[] = array($dblog->count, theme('dblog_message', array('event' => $dblog))); } $build['dblog_top_table'] = array( @@ -182,17 +155,6 @@ function dblog_event($id) { $severity = watchdog_severity_levels(); $result = db_query('SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid WHERE w.wid = :id', array(':id' => $id))->fetchObject(); if ($dblog = $result) { - // Check for required properties. - if (isset($dblog->message) && isset($dblog->variables)) { - // Messages without variables or user specified text. - if ($dblog->variables === 'N;') { - $message = $dblog->message; - } - // Message to translate with injected variables. - else { - $message = t($dblog->message, unserialize($dblog->variables)); - } - } $rows = array( array( array('data' => t('Type'), 'header' => TRUE), @@ -216,7 +178,7 @@ function dblog_event($id) { ), array( array('data' => t('Message'), 'header' => TRUE), - $message, + theme('dblog_message', array('event' => $dblog)), ), array( array('data' => t('Severity'), 'header' => TRUE), @@ -312,6 +274,38 @@ function dblog_filters() { } /** + * Returns HTML for a log message. + * + * @param array $variables + * An associative array containing: + * - event: An object with at least the message and variables properties. + * - link: (optional) Format message as link, event->wid is required. + * + * @ingroup themeable + */ +function theme_dblog_message($variables) { + $output = ''; + $event = $variables['event']; + // Check for required properties. + if (isset($event->message) && isset($event->variables)) { + // Messages without variables or user specified text. + if ($event->variables === 'N;') { + $output = $event->message; + } + // Message to translate with injected variables. + else { + $output = t($event->message, unserialize($event->variables)); + } + if ($variables['link'] && isset($event->wid)) { + // Truncate message to 56 chars. + $output = truncate_utf8(filter_xss($output, array()), 56, TRUE, TRUE); + $output = l($output, 'admin/reports/event/' . $event->wid, array('html' => TRUE)); + } + } + return $output; +} + +/** * Form constructor for the database logging filter form. * * @see dblog_filter_form_validate() diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module index 3a3d142..a0afcd4 100644 --- a/core/modules/dblog/dblog.module +++ b/core/modules/dblog/dblog.module @@ -184,3 +184,15 @@ function dblog_form_system_logging_settings_alter(&$form, $form_state) { function dblog_logging_settings_submit($form, &$form_state) { config('dblog.settings')->set('row_limit', $form_state['values']['dblog_row_limit'])->save(); } + +/** + * Implements hook_theme(). + */ +function dblog_theme() { + return array( + 'dblog_message' => array( + 'variables' => array('event' => NULL, 'link' => FALSE), + 'file' => 'dblog.admin.inc', + ), + ); +} diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditorLoadingTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditorLoadingTest.php index c0731cc..d1fe41e 100644 --- a/core/modules/editor/lib/Drupal/editor/Tests/EditorLoadingTest.php +++ b/core/modules/editor/lib/Drupal/editor/Tests/EditorLoadingTest.php @@ -134,9 +134,9 @@ function testLoading() { // to let the untrusted user edit it. $this->drupalCreateNode(array( 'type' => 'article', - 'body' => array( - array('value' => $this->randomName(32), 'format' => 'full_html') - ), + 'body' => array(LANGUAGE_NOT_SPECIFIED => array( + 0 => array('value' => $this->randomName(32), 'format' => 'full_html') + )), )); // The untrusted user tries to edit content that is written in a text format diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index 3566121..f5e968c 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -35,32 +35,24 @@ function entity_reference_field_info() { } /** - * Implements hook_entity_field_info_alter(). + * Implements hook_entity_field_info(). * * Set the "target_type" property definition for entity reference fields. * * @see \Drupal\Core\Entity\Field\Type\EntityReferenceItem::getPropertyDefinitions() - * - * @param array $info - * The property info array as returned by hook_entity_field_info(). - * @param string $entity_type - * The entity type for which entity properties are defined. */ -function entity_reference_entity_field_info_alter(&$info, $entity_type) { +function entity_reference_entity_field_info($entity_type) { + $property_info = array(); foreach (field_info_instances($entity_type) as $bundle_name => $instances) { foreach ($instances as $field_name => $instance) { $field = field_info_field($field_name); if ($field['type'] != 'entity_reference') { continue; } - if (isset($info['definitions'][$field_name])) { - $info['definitions'][$field_name]['settings']['target_type'] = $field['settings']['target_type']; - } - elseif (isset($info['optional'][$field_name])) { - $info['optional'][$field_name]['settings']['target_type'] = $field['settings']['target_type']; - } + $property_info['definitions'][$field_name]['settings']['target_type'] = $field['settings']['target_type']; } } + return $property_info; } /** diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php index d3245e0..cc768e2 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php @@ -88,8 +88,10 @@ public function testSort() { 'title' => 'Node published1 (<&>)', 'uid' => 1, 'field_text' => array( - array( - 'value' => 1, + LANGUAGE_NOT_SPECIFIED => array( + array( + 'value' => 1, + ), ), ), ), @@ -99,8 +101,10 @@ public function testSort() { 'title' => 'Node published2 (<&>)', 'uid' => 1, 'field_text' => array( - array( - 'value' => 2, + LANGUAGE_NOT_SPECIFIED => array( + array( + 'value' => 2, + ), ), ), ), diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index 1cf252d..16b0143 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -1086,7 +1086,7 @@ function hook_field_attach_view_alter(&$output, $context) { $element = &$output[$field_name]; if ($element['#field_type'] == 'entity_reference' && $element['#formatter'] == 'entity_reference_label') { foreach ($element['#items'] as $delta => $item) { - $term = $item['entity']; + $term = $item['taxonomy_term']; if (!empty($term->rdf_mapping['rdftype'])) { $element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype']; } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 11cd9bb..6cdd628 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -944,10 +944,7 @@ function field_view_field(EntityInterface $entity, $field_name, $display_options if ($formatter) { $display_langcode = field_language($entity, $field_name, $langcode); - $items = array(); - if (isset($entity->{$field_name}[$display_langcode])) { - $items = $entity->{$field_name}[$display_langcode]; - } + $items = $entity->{$field_name}[$display_langcode]; // Invoke prepare_view steps if needed. if (empty($entity->_field_view_prepared)) { @@ -959,10 +956,7 @@ function field_view_field(EntityInterface $entity, $field_name, $display_options _field_invoke_multiple('prepare_view', $entity->entityType(), array($id => $entity), $null, $null, $options); // Then let the formatter do its own specific massaging. - $items_multi = array($id => array()); - if (isset($entity->{$field_name}[$display_langcode])) { - $items_multi[$id] = $entity->{$field_name}[$display_langcode]; - } + $items_multi = array($id => $entity->{$field_name}[$display_langcode]); $formatter->prepareView(array($id => $entity), $display_langcode, $items_multi); $items = $items_multi[$id]; } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php index 86f1f34..bc1a380 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php @@ -64,7 +64,7 @@ function setUp() { $settings = array(); $settings['type'] = $this->content_type; $settings['title'] = 'Field view access test'; - $settings['test_view_field'] = array(array('value' => $this->test_view_field_value)); + $settings['test_view_field'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->test_view_field_value))); $this->node = $this->drupalCreateNode($settings); } diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php b/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php index 62b7b27..1652caf 100644 --- a/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php @@ -28,6 +28,8 @@ public static function getInfo() { function setUp() { parent::setUp(); + $langcode = LANGUAGE_NOT_SPECIFIED; + $field_names = $this->setUpFields(); // The first one will be attached to nodes only. @@ -63,8 +65,9 @@ function setUp() { // Now create some example nodes/users for the view result. for ($i = 0; $i < 5; $i++) { $edit = array( - 'field_name_0' => array((array('value' => $this->randomName()))), - 'field_name_2' => array((array('value' => $this->randomName()))), + // @TODO Write a helper method to create such values. + 'field_name_0' => array($langcode => array((array('value' => $this->randomName())))), + 'field_name_2' => array($langcode => array((array('value' => $this->randomName())))), ); $this->nodes[] = $this->drupalCreateNode($edit); } diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php index 5e50b88..1c8d3f5 100644 --- a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php @@ -59,13 +59,13 @@ protected function setUp() { for ($key = 0; $key < 3; $key++) { $field = $this->fields[$key]; - $edit[$field['field_name']][0]['value'] = $this->randomName(8); + $edit[$field['field_name']][LANGUAGE_NOT_SPECIFIED][0]['value'] = $this->randomName(8); } for ($j = 0; $j < 5; $j++) { - $edit[$this->fields[3]['field_name']][$j]['value'] = $this->randomName(8); + $edit[$this->fields[3]['field_name']][LANGUAGE_NOT_SPECIFIED][$j]['value'] = $this->randomName(8); } // Set this field to be empty. - $edit[$this->fields[4]['field_name']] = array(array('value' => NULL)); + $edit[$this->fields[4]['field_name']] = array(LANGUAGE_NOT_SPECIFIED => array(0 => array('value' => NULL))); $this->nodes[$i] = $this->drupalCreateNode($edit); } 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 4ca882b..45de66e 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 @@ -7,7 +7,7 @@ namespace Drupal\field_ui\Tests; -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; /** * Tests the functionality of the 'Manage display' screens. @@ -111,7 +111,7 @@ function testViewModeCustom() { $value = 12345; $settings = array( 'type' => $this->type, - 'field_test' => array(array('value' => $value)), + 'field_test' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $value))), ); $node = $this->drupalCreateNode($settings); @@ -216,7 +216,7 @@ function testNoFieldsDisplayOverview() { /** * Asserts that a string is found in the rendered node in a view mode. * - * @param EntityInterface $node + * @param Node $node * The node. * @param $view_mode * The view mode in which the node should be displayed. @@ -228,14 +228,14 @@ function testNoFieldsDisplayOverview() { * @return * TRUE on pass, FALSE on fail. */ - function assertNodeViewText(EntityInterface $node, $view_mode, $text, $message) { + function assertNodeViewText(Node $node, $view_mode, $text, $message) { return $this->assertNodeViewTextHelper($node, $view_mode, $text, $message, FALSE); } /** * Asserts that a string is not found in the rendered node in a view mode. * - * @param EntityInterface $node + * @param Node $node * The node. * @param $view_mode * The view mode in which the node should be displayed. @@ -246,7 +246,7 @@ function assertNodeViewText(EntityInterface $node, $view_mode, $text, $message) * @return * TRUE on pass, FALSE on fail. */ - function assertNodeViewNoText(EntityInterface $node, $view_mode, $text, $message) { + function assertNodeViewNoText(Node $node, $view_mode, $text, $message) { return $this->assertNodeViewTextHelper($node, $view_mode, $text, $message, TRUE); } @@ -256,7 +256,7 @@ function assertNodeViewNoText(EntityInterface $node, $view_mode, $text, $message * This helper function is used by assertNodeViewText() and * assertNodeViewNoText(). * - * @param EntityInterface $node + * @param Node $node * The node. * @param $view_mode * The view mode in which the node should be displayed. @@ -270,7 +270,7 @@ function assertNodeViewNoText(EntityInterface $node, $view_mode, $text, $message * @return * TRUE on pass, FALSE on fail. */ - function assertNodeViewTextHelper(EntityInterface $node, $view_mode, $text, $message, $not_exists) { + function assertNodeViewTextHelper(Node $node, $view_mode, $text, $message, $not_exists) { // Make sure caches on the tester side are refreshed after changes // submitted on the tested side. field_info_cache_clear(); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php index c2d922d..52df6f2 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php @@ -141,8 +141,7 @@ function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, $node = $this->drupalCreateNode($extras); $nid = $node->nid; // Save at least one revision to better simulate a real site. - $node->setNewRevision(); - $node->save(); + $this->drupalCreateNode(get_object_vars($node)); $node = node_load($nid, TRUE); $this->assertNotEqual($nid, $node->vid, t('Node revision exists.')); } diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 574d536..8b35c3e 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -6,6 +6,7 @@ */ use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\entity\Plugin\Core\Entity\EntityDisplay; use Drupal\taxonomy\Plugin\Core\Entity\Term; @@ -240,13 +241,13 @@ function forum_uri($forum) { /** * Checks whether a node can be used in a forum, based on its content type. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity. * * @return * Boolean indicating if the node can be assigned to a forum. */ -function _forum_node_check_node_type(EntityInterface $node) { +function _forum_node_check_node_type(Node $node) { // Fetch information about the forum field. $instance = field_info_instance('node', 'taxonomy_forums', $node->type); return !empty($instance); @@ -255,7 +256,7 @@ function _forum_node_check_node_type(EntityInterface $node) { /** * Implements hook_node_view(). */ -function forum_node_view(EntityInterface $node, EntityDisplay $display, $view_mode) { +function forum_node_view(Node $node, EntityDisplay $display, $view_mode) { $vid = config('forum.settings')->get('vocabulary'); $vocabulary = taxonomy_vocabulary_load($vid); if (_forum_node_check_node_type($node)) { @@ -281,7 +282,7 @@ function forum_node_view(EntityInterface $node, EntityDisplay $display, $view_mo * Checks in particular that the node is assigned only a "leaf" term in the * forum taxonomy. */ -function forum_node_validate(EntityInterface $node, $form) { +function forum_node_validate(Node $node, $form) { if (_forum_node_check_node_type($node)) { $langcode = $form['taxonomy_forums']['#language']; // vocabulary is selected, not a "container" term. @@ -317,7 +318,7 @@ function forum_node_validate(EntityInterface $node, $form) { * * Assigns the forum taxonomy when adding a topic from within a forum. */ -function forum_node_presave(EntityInterface $node) { +function forum_node_presave(Node $node) { if (_forum_node_check_node_type($node)) { // Make sure all fields are set properly: $node->icon = !empty($node->icon) ? $node->icon : ''; @@ -337,7 +338,7 @@ function forum_node_presave(EntityInterface $node) { /** * Implements hook_node_update(). */ -function forum_node_update(EntityInterface $node) { +function forum_node_update(Node $node) { if (_forum_node_check_node_type($node)) { // If this is not a new revision and does exist, update the forum record, // otherwise insert a new one. @@ -387,7 +388,7 @@ function forum_node_update(EntityInterface $node) { /** * Implements hook_node_insert(). */ -function forum_node_insert(EntityInterface $node) { +function forum_node_insert(Node $node) { if (_forum_node_check_node_type($node)) { if (!empty($node->forum_tid)) { $nid = db_insert('forum') @@ -404,7 +405,7 @@ function forum_node_insert(EntityInterface $node) { /** * Implements hook_node_predelete(). */ -function forum_node_predelete(EntityInterface $node) { +function forum_node_predelete(Node $node) { if (_forum_node_check_node_type($node)) { db_delete('forum') ->condition('nid', $node->nid) @@ -521,17 +522,18 @@ function forum_comment_delete($comment) { function forum_field_storage_pre_insert(EntityInterface $entity, &$skip_fields) { if ($entity->entityType() == 'node' && $entity->status && _forum_node_check_node_type($entity)) { $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp')); - foreach ($entity->getTranslationLanguages() as $langcode => $language) { - $translation = $entity->getTranslation($langcode, FALSE); - $query->values(array( - 'nid' => $entity->id(), - 'title' => $translation->title->value, - 'tid' => $translation->taxonomy_forums->tid, - 'sticky' => $entity->sticky, - 'created' => $entity->created, - 'comment_count' => 0, - 'last_comment_timestamp' => $entity->created, - )); + foreach ($entity->taxonomy_forums as $language) { + foreach ($language as $item) { + $query->values(array( + 'nid' => $entity->nid, + 'title' => $entity->title, + 'tid' => $item['tid'], + 'sticky' => $entity->sticky, + 'created' => $entity->created, + 'comment_count' => 0, + 'last_comment_timestamp' => $entity->created, + )); + } } $query->execute(); } @@ -654,7 +656,7 @@ function forum_block_view_pre_render($elements) { /** * Implements hook_form(). */ -function forum_form(EntityInterface $node, &$form_state) { +function forum_form(Node $node, &$form_state) { $type = node_type_load($node->type); $form['title'] = array( '#type' => 'textfield', diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index c08ce70..5070396 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -7,7 +7,7 @@ namespace Drupal\forum\Tests; -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\simpletest\WebTestBase; /** @@ -540,14 +540,14 @@ function createForumTopic($forum, $container = FALSE) { * * @param $node_user * The user who creates the node. - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node being checked. * @param $admin * Boolean to indicate whether the user can 'access administration pages'. * @param $response * The exptected HTTP response code. */ - private function verifyForums($node_user, EntityInterface $node, $admin, $response = 200) { + private function verifyForums($node_user, Node $node, $admin, $response = 200) { $response2 = ($admin) ? 200 : 403; // View forum help node. diff --git a/core/modules/history/history.module b/core/modules/history/history.module index 84abade..45027fe 100644 --- a/core/modules/history/history.module +++ b/core/modules/history/history.module @@ -9,7 +9,7 @@ * - Generic helper for node_mark(). */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; /** * Entities changed before this time are always shown as read. @@ -79,7 +79,7 @@ function history_cron() { /** * Implements hook_node_delete(). */ -function history_node_delete(EntityInterface $node) { +function history_node_delete(Node $node) { db_delete('history') ->condition('nid', $node->nid) ->execute(); diff --git a/core/modules/image/config/image.settings.yml b/core/modules/image/config/image.settings.yml index f0f123f..2da8551 100644 --- a/core/modules/image/config/image.settings.yml +++ b/core/modules/image/config/image.settings.yml @@ -1,2 +1,3 @@ preview_image: core/modules/image/sample.png allow_insecure_derivatives: false +jpeg_quality: 75 diff --git a/core/modules/image/config/schema/image.schema.yml b/core/modules/image/config/schema/image.schema.yml index 0bb8d5d..f4c8fd0 100644 --- a/core/modules/image/config/schema/image.schema.yml +++ b/core/modules/image/config/schema/image.schema.yml @@ -4,53 +4,53 @@ image.size: type: mapping mapping: - width: + "width": type: integer - label: 'Width' - height: + label: "Width" + "height": type: integer - label: 'Height' + label: "Height" # Image styles (multiple). # Plugin \Drupal\image\Plugin\Core\Entity\ImageStyle image.style.*: type: mapping - label: 'Image style' + label: "Image style" mapping: - name: + "name": type: string - label: + "label": type: label - effects: + "effects": type: sequence sequence: - type: mapping mapping: - name: + "name": type: string - data: + "data": type: image.effect.[%parent.name] - weight: + "weight": type: integer - ieid: + "ieid": type: string # Image effects plugins: image.effect.% # These are used in image styles. image.effect.image_crop: type: image.size - label: 'Image crop' + label: "Image crop" mapping: - anchor: - label: 'Anchor' + "anchor": + label: "Anchor" image.effect.image_resize: type: image.size - label: 'Image resize' + label: "Image resize" image.effect.image_rotate: type: mapping - label: 'Image rotate' + label: "Image rotate" mapping: degrees: type: integer @@ -63,20 +63,20 @@ image.effect.image_rotate: image.effect.image_scale: type: image.size - label: 'Image scale' + label: "Image scale" mapping: - upscale: + "upscale": type: boolean - label: 'Upscale' + label: "Upscale" image.effect.image_scale_and_crop: type: image.size - label: 'Image scale and crop' + label: "Image scale and crop" # Schema for configuration files of image module. image.settings: type: mapping mapping: - preview_image: + "preview_image": type: string - label: 'Preview image' + label: "Preview image" diff --git a/core/modules/image/image.install b/core/modules/image/image.install index e4e77d8..a000eb2 100644 --- a/core/modules/image/image.install +++ b/core/modules/image/image.install @@ -176,5 +176,6 @@ function image_update_8001() { function image_update_8002() { update_variables_to_config('image.settings', array( 'image_style_preview_image' => 'preview_image', + 'image_jpeg_quality' => 'jpeg_quality', )); } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php index d69d083..a4768ac 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php @@ -115,7 +115,7 @@ function testContentTypeLanguageConfiguration() { $edit = array( 'type' => $type2->type, 'title' => $node_title, - 'body' => array(array('value' => $node_body)), + 'body' => array($langcode => array(array('value' => $node_body))), 'langcode' => $langcode, ); $node = $this->drupalCreateNode($edit); diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index a4a6718..46d6ead 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -11,7 +11,7 @@ * URLs to be added to the main site navigation menu. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\block\Plugin\Core\Entity\Block; use Drupal\system\Plugin\Core\Entity\Menu; use Drupal\system\Plugin\block\block\SystemMenuBlock; @@ -424,21 +424,21 @@ function menu_block_view_alter(array &$build, Block $block) { /** * Implements hook_node_insert(). */ -function menu_node_insert(EntityInterface $node) { +function menu_node_insert(Node $node) { menu_node_save($node); } /** * Implements hook_node_update(). */ -function menu_node_update(EntityInterface $node) { +function menu_node_update(Node $node) { menu_node_save($node); } /** * Helper for hook_node_insert() and hook_node_update(). */ -function menu_node_save(EntityInterface $node) { +function menu_node_save(Node $node) { if (isset($node->menu)) { $link = &$node->menu; if (empty($link['enabled'])) { @@ -467,7 +467,7 @@ function menu_node_save(EntityInterface $node) { /** * Implements hook_node_predelete(). */ -function menu_node_predelete(EntityInterface $node) { +function menu_node_predelete(Node $node) { // Delete all menu module links that point to this node. $query = entity_query('menu_link') ->condition('link_path', 'node/' . $node->nid) @@ -482,7 +482,7 @@ function menu_node_predelete(EntityInterface $node) { /** * Implements hook_node_prepare(). */ -function menu_node_prepare(EntityInterface $node) { +function menu_node_prepare(Node $node) { if (empty($node->menu)) { // Prepare the node for the edit form so that $node->menu always exists. $menu_name = strtok(variable_get('menu_parent_' . $node->type, 'main:0'), ':'); @@ -645,7 +645,7 @@ function menu_form_node_form_alter(&$form, $form_state) { * * @see menu_form_node_form_alter() */ -function menu_node_submit(EntityInterface $node, $form, $form_state) { +function menu_node_submit(Node $node, $form, $form_state) { $node->menu = entity_create('menu_link', $form_state['values']['menu']); // Decompose the selected menu parent option into 'menu_name' and 'plid', if // the form used the default parent selection widget. diff --git a/core/modules/node/lib/Drupal/node/NodeStorageController.php b/core/modules/node/lib/Drupal/node/NodeStorageController.php index c9e832e..d855384 100644 --- a/core/modules/node/lib/Drupal/node/NodeStorageController.php +++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php @@ -7,7 +7,7 @@ namespace Drupal\node; -use Drupal\Core\Entity\DatabaseStorageControllerNG; +use Drupal\Core\Entity\DatabaseStorageController; use Drupal\Core\Entity\EntityInterface; /** @@ -16,40 +16,31 @@ * This extends the Drupal\Core\Entity\DatabaseStorageController class, adding * required special handling for node entities. */ -class NodeStorageController extends DatabaseStorageControllerNG { +class NodeStorageController extends DatabaseStorageController { /** * Overrides Drupal\Core\Entity\DatabaseStorageController::create(). */ public function create(array $values) { - // @todo Handle this through property defaults. - if (empty($values['created'])) { - $values['created'] = REQUEST_TIME; + $node = parent::create($values); + + // Set the created time to now. + if (empty($node->created)) { + $node->created = REQUEST_TIME; } - return parent::create($values)->getBCEntity(); + + return $node; } /** - * Overrides Drupal\Core\Entity\DatabaseStorageControllerNG::attachLoad(). + * Overrides Drupal\Core\Entity\DatabaseStorageController::attachLoad(). */ - protected function attachLoad(&$queried_entities, $load_revision = FALSE) { - $nodes = $this->mapFromStorageRecords($queried_entities, $load_revision); - + protected function attachLoad(&$nodes, $load_revision = FALSE) { // Create an array of nodes for each content type and pass this to the - // object type specific callback. To preserve backward-compatibility we - // pass on BC decorators to node-specific hooks, while we pass on the - // regular entity objects else. + // object type specific callback. $typed_nodes = array(); - foreach ($nodes as $id => $node) { - $queried_entities[$id] = $node->getBCEntity(); - $typed_nodes[$node->bundle()][$id] = $queried_entities[$id]; - } - - if ($load_revision) { - field_attach_load_revision($this->entityType, $queried_entities); - } - else { - field_attach_load($this->entityType, $queried_entities); + foreach ($nodes as $id => $entity) { + $typed_nodes[$entity->type][$id] = $entity; } // Call object type specific callbacks on each typed array of nodes. @@ -64,19 +55,7 @@ protected function attachLoad(&$queried_entities, $load_revision = FALSE) { // hook_node_load(), containing a list of node types that were loaded. $argument = array_keys($typed_nodes); $this->hookLoadArguments = array($argument); - - // Call hook_entity_load(). - foreach (module_implements('entity_load') as $module) { - $function = $module . '_entity_load'; - $function($queried_entities, $this->entityType); - } - // Call hook_TYPE_load(). The first argument for hook_TYPE_load() are - // always the queried entities, followed by additional arguments set in - // $this->hookLoadArguments. - $args = array_merge(array($queried_entities), $this->hookLoadArguments); - foreach (module_implements($this->entityType . '_load') as $module) { - call_user_func_array($module . '_' . $this->entityType . '_load', $args); - } + parent::attachLoad($nodes, $load_revision); } /** @@ -98,8 +77,6 @@ protected function buildQuery($ids, $revision_id = FALSE) { * Overrides Drupal\Core\Entity\DatabaseStorageController::invokeHook(). */ protected function invokeHook($hook, EntityInterface $node) { - $node = $node->getBCEntity(); - if ($hook == 'insert' || $hook == 'update') { node_invoke($node, $hook); } @@ -109,23 +86,7 @@ protected function invokeHook($hook, EntityInterface $node) { node_invoke($node, 'delete'); } - // Inline parent::invokeHook() to pass on BC-entities to node-specific - // hooks. - - $function = 'field_attach_' . $hook; - // @todo: field_attach_delete_revision() is named the wrong way round, - // consider renaming it. - if ($function == 'field_attach_revision_delete') { - $function = 'field_attach_delete_revision'; - } - if (!empty($this->entityInfo['fieldable']) && function_exists($function)) { - $function($node); - } - - // Invoke the hook. - module_invoke_all($this->entityType . '_' . $hook, $node); - // Invoke the respective entity-level hook. - module_invoke_all('entity_' . $hook, $node, $this->entityType); + parent::invokeHook($hook, $node); } /** @@ -133,7 +94,7 @@ protected function invokeHook($hook, EntityInterface $node) { */ protected function preSave(EntityInterface $node) { // Before saving the node, set changed and revision times. - $node->changed->value = REQUEST_TIME; + $node->changed = REQUEST_TIME; } /** @@ -165,29 +126,28 @@ protected function preSaveRevision(\stdClass $record, EntityInterface $entity) { if ($entity->isNewRevision()) { $record->timestamp = REQUEST_TIME; - $record->uid = isset($entity->revision_uid->value) ? $entity->revision_uid->value : $GLOBALS['user']->uid; + $record->uid = isset($record->revision_uid) ? $record->revision_uid : $GLOBALS['user']->uid; } } /** * Overrides Drupal\Core\Entity\DatabaseStorageController::postSave(). */ - public function postSave(EntityInterface $node, $update) { + function postSave(EntityInterface $node, $update) { // Update the node access table for this node, but only if it is the // default revision. There's no need to delete existing records if the node // is new. if ($node->isDefaultRevision()) { - node_access_acquire_grants($node->getBCEntity(), $update); + node_access_acquire_grants($node, $update); } } - /** * Overrides Drupal\Core\Entity\DatabaseStorageController::preDelete(). */ - public function preDelete($entities) { + function preDelete($entities) { if (module_exists('search')) { foreach ($entities as $id => $entity) { - search_reindex($entity->nid->value, 'node'); + search_reindex($entity->nid, 'node'); } } } @@ -203,110 +163,4 @@ protected function postDelete($nodes) { ->condition('nid', $ids, 'IN') ->execute(); } - - /** - * Overrides \Drupal\Core\Entity\DataBaseStorageControllerNG::basePropertyDefinitions(). - */ - public function baseFieldDefinitions() { - $properties['nid'] = array( - 'label' => t('Node ID'), - 'description' => t('The node ID.'), - 'type' => 'integer_field', - 'read-only' => TRUE, - ); - $properties['uuid'] = array( - 'label' => t('UUID'), - 'description' => t('The node UUID.'), - 'type' => 'string_field', - 'read-only' => TRUE, - ); - $properties['vid'] = array( - 'label' => t('Revision ID'), - 'description' => t('The node revision ID.'), - 'type' => 'integer_field', - 'read-only' => TRUE, - ); - $properties['type'] = array( - 'label' => t('Type'), - 'description' => t('The node type.'), - 'type' => 'string_field', - 'read-only' => TRUE, - ); - $properties['langcode'] = array( - 'label' => t('Language code'), - 'description' => t('The node language code.'), - 'type' => 'language_field', - ); - $properties['title'] = array( - 'label' => t('Title'), - 'description' => t('The title of this node, always treated as non-markup plain text.'), - 'type' => 'string_field', - ); - $properties['uid'] = array( - 'label' => t('User ID'), - 'description' => t('The user ID of the node author.'), - 'type' => 'entity_reference_field', - 'settings' => array('target_type' => 'user'), - ); - $properties['status'] = array( - 'label' => t('Publishing status'), - 'description' => t('A boolean indicating whether the node is published.'), - 'type' => 'boolean_field', - ); - $properties['created'] = array( - 'label' => t('Created'), - 'description' => t('The time that the node was created.'), - 'type' => 'integer_field', - ); - $properties['changed'] = array( - 'label' => t('Changed'), - 'description' => t('The time that the node was last edited.'), - 'type' => 'integer_field', - ); - $properties['comment'] = array( - 'label' => t('Comment'), - 'description' => t('Whether comments are allowed on this node: 0 = no, 1 = closed (read only), 2 = open (read/write).'), - 'type' => 'integer_field', - ); - $properties['promote'] = array( - 'label' => t('Promote'), - 'description' => t('A boolean indicating whether the node should be displayed on the front page.'), - 'type' => 'boolean_field', - ); - $properties['sticky'] = array( - 'label' => t('Sticky'), - 'description' => t('A boolean indicating whether the node should be displayed at the top of lists in which it appears.'), - 'type' => 'boolean_field', - ); - $properties['tnid'] = array( - 'label' => t('Translation set ID'), - 'description' => t('The translation set id for this node, which equals the node id of the source post in each set.'), - 'type' => 'integer_field', - ); - $properties['translate'] = array( - 'label' => t('Translate'), - 'description' => t('A boolean indicating whether this translation page needs to be updated.'), - 'type' => 'boolean_field', - ); - $properties['revision_timestamp'] = array( - 'label' => t('Revision timestamp'), - 'description' => t('The time that the current revision was created.'), - 'type' => 'integer_field', - 'queryable' => FALSE, - ); - $properties['revision_uid'] = array( - 'label' => t('Revision user ID'), - 'description' => t('The user ID of the author of the current revision.'), - 'type' => 'entity_reference_field', - 'settings' => array('target_type' => 'user'), - 'queryable' => FALSE, - ); - $properties['log'] = array( - 'label' => t('Log'), - 'description' => t('The log entry explaining the changes in this version.'), - 'type' => 'string_field', - ); - return $properties; - } - } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php index 32c61ca..61882b9 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php @@ -8,7 +8,7 @@ namespace Drupal\node\Plugin\Core\Entity; use Drupal\Core\Entity\ContentEntityInterface; -use Drupal\Core\Entity\EntityNG; +use Drupal\Core\Entity\Entity; use Drupal\Component\Annotation\Plugin; use Drupal\Core\Annotation\Translation; @@ -43,54 +43,64 @@ * permission_granularity = "bundle" * ) */ -class Node extends EntityNG implements ContentEntityInterface { +class Node extends Entity implements ContentEntityInterface { /** * The node ID. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $nid; /** * The node revision ID. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $vid; /** + * Indicates whether this is the default node revision. + * + * The default revision of a node is the one loaded when no specific revision + * has been specified. Only default revisions are saved to the node table. + * + * @var boolean + */ + public $isDefaultRevision = TRUE; + + /** * The node UUID. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var string */ public $uuid; /** * The node content type (bundle). * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var string */ public $type; /** * The node language code. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var string */ - public $langcode; + public $langcode = LANGUAGE_NOT_SPECIFIED; /** * The node title. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var string */ public $title; /** * The node owner's user ID. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $uid; @@ -100,21 +110,21 @@ class Node extends EntityNG implements ContentEntityInterface { * Unpublished nodes are only visible to their authors and to administrators. * The value is either NODE_PUBLISHED or NODE_NOT_PUBLISHED. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $status; /** * The node creation timestamp. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $created; /** * The node modification timestamp. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $changed; @@ -125,7 +135,7 @@ class Node extends EntityNG implements ContentEntityInterface { * COMMENT_NODE_CLOSED => comments are read-only * COMMENT_NODE_OPEN => open (read/write) * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $comment; @@ -135,7 +145,7 @@ class Node extends EntityNG implements ContentEntityInterface { * Promoted nodes should be displayed on the front page of the site. The value * is either NODE_PROMOTED or NODE_NOT_PROMOTED. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $promote; @@ -145,7 +155,7 @@ class Node extends EntityNG implements ContentEntityInterface { * Sticky nodes should be displayed at the top of lists in which they appear. * The value is either NODE_STICKY or NODE_NOT_STICKY. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $sticky; @@ -155,7 +165,7 @@ class Node extends EntityNG implements ContentEntityInterface { * Translations sets are based on the ID of the node containing the source * text for the translation set. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $tnid; @@ -164,61 +174,52 @@ class Node extends EntityNG implements ContentEntityInterface { * * If the translation page needs to be updated, the value is 1; otherwise 0. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $translate; /** * The node revision creation timestamp. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $revision_timestamp; /** * The node revision author's user ID. * - * @var \Drupal\Core\Entity\Field\FieldInterface + * @var integer */ public $revision_uid; /** - * Overrides \Drupal\Core\Entity\EntityNG::init(). - */ - protected function init() { - parent::init(); - // We unset all defined properties, so magic getters apply. - unset($this->nid); - unset($this->vid); - unset($this->uuid); - unset($this->type); - unset($this->title); - unset($this->uid); - unset($this->status); - unset($this->created); - unset($this->changed); - unset($this->comment); - unset($this->promote); - unset($this->sticky); - unset($this->tnid); - unset($this->translate); - unset($this->revision_timestamp); - unset($this->revision_uid); - unset($this->log); + * Implements Drupal\Core\Entity\EntityInterface::id(). + */ + public function id() { + return $this->nid; + } + + /** + * Implements Drupal\Core\Entity\EntityInterface::bundle(). + */ + public function bundle() { + return $this->type; } /** - * Implements Drupal\Core\Entity\EntityInterface::id(). + * Overrides Drupal\Core\Entity\Entity::createDuplicate(). */ - public function id() { - return $this->get('nid')->value; + public function createDuplicate() { + $duplicate = parent::createDuplicate(); + $duplicate->vid = NULL; + return $duplicate; } /** * Overrides Drupal\Core\Entity\Entity::getRevisionId(). */ public function getRevisionId() { - return $this->get('vid')->value; + return $this->vid; } } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php index 0db0bda..433c6bb 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php @@ -57,7 +57,7 @@ function testNodeAccessAdministerField() { // Create a page node. $langcode = LANGUAGE_NOT_SPECIFIED; $field_data = array(); - $value = $field_data[0]['value'] = $this->randomName(); + $value = $field_data[$langcode][0]['value'] = $this->randomName(); $node = $this->drupalCreateNode(array($this->field_name => $field_data)); // Log in as the administrator and confirm that the field value is present. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php index ae2aee4..85fcafc 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php @@ -64,7 +64,7 @@ function testNodeAccess() { // Tests the default access provided for a published Hungarian node. $web_user = $this->drupalCreateUser(array('access content')); - $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu')); + $node = $this->drupalCreateNode(array('body' => array('hu' => array(array())), 'langcode' => 'hu')); $this->assertTrue($node->langcode == 'hu', 'Node created as Hungarian.'); $expected_node_access = array('view' => TRUE, 'update' => FALSE, 'delete' => FALSE); $this->assertNodeAccess($expected_node_access, $node, $web_user); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php index a9ae1c3..de24f45 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php @@ -86,7 +86,9 @@ public function testForumPager() { 'nid' => NULL, 'type' => 'forum', 'taxonomy_forums' => array( - array('tid' => $tid) + LANGUAGE_NOT_SPECIFIED => array( + array('tid' => $tid, 'vid' => $vid), + ), ), )); } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php index 9cc80f7..2333dd9 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php @@ -50,7 +50,7 @@ function setUp() { 'value' => 'A' . $this->randomName(32), 'format' => filter_default_format(), ); - $settings['body'][0] = $body; + $settings['body'][LANGUAGE_NOT_SPECIFIED][0] = $body; $this->drupalCreateNode($settings); } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php index f382457..6ea519a 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php @@ -82,30 +82,33 @@ function testMultilingualNodeForm() { $this->drupalPost('node/add/page', $edit, t('Save')); // Check that the node exists in the database. - $node = $this->drupalGetNodeByTitle($edit[$title_key])->getOriginalEntity(); + $node = $this->drupalGetNodeByTitle($edit[$title_key]); $this->assertTrue($node, 'Node found in database.'); - $this->assertTrue($node->language()->langcode == $langcode && $node->body->value == $body_value, 'Field language correctly set.'); + + $assert = isset($node->body['en']) && !isset($node->body[LANGUAGE_NOT_SPECIFIED]) && $node->body['en'][0]['value'] == $body_value; + $this->assertTrue($assert, 'Field language correctly set.'); // Change node language. - $langcode = 'it'; - $this->drupalGet("node/{$node->id()}/edit"); + $this->drupalGet("node/$node->nid/edit"); $edit = array( $title_key => $this->randomName(8), - 'langcode' => $langcode, + 'langcode' => 'it' ); $this->drupalPost(NULL, $edit, t('Save')); - $node = $this->drupalGetNodeByTitle($edit[$title_key], TRUE)->getOriginalEntity(); + $node = $this->drupalGetNodeByTitle($edit[$title_key], TRUE); $this->assertTrue($node, 'Node found in database.'); - $this->assertTrue($node->language()->langcode == $langcode && $node->body->value == $body_value, 'Field language correctly changed.'); + + $assert = isset($node->body['it']) && !isset($node->body['en']) && $node->body['it'][0]['value'] == $body_value; + $this->assertTrue($assert, 'Field language correctly changed.'); // Enable content language URL detection. language_negotiation_set(LANGUAGE_TYPE_CONTENT, array(LANGUAGE_NEGOTIATION_URL => 0)); // Test multilingual field language fallback logic. - $this->drupalGet("it/node/{$node->id()}"); + $this->drupalGet("it/node/$node->nid"); $this->assertRaw($body_value, 'Body correctly displayed using Italian as requested language'); - $this->drupalGet("node/{$node->id()}"); + $this->drupalGet("node/$node->nid"); $this->assertRaw($body_value, 'Body correctly displayed using English as requested language'); } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionPermissionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionPermissionsTest.php index dfdccdf..53b9d94 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionPermissionsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionPermissionsTest.php @@ -49,7 +49,7 @@ function setUp() { for ($i = 0; $i < 3; $i++) { // Create a revision for the same nid and settings with a random log. $revision = clone $nodes[$type]; - $revision->setNewRevision(); + $revision->revision = 1; $revision->log = $this->randomName(32); node_save($revision); $this->node_revisions[$type][] = $revision; diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php index 90a7305..655c4c1 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php @@ -48,24 +48,18 @@ function setUp() { $logs = array(); // Get the original node. - $nodes[] = clone $node; + $nodes[] = $node; // Create three revisions. $revision_count = 3; for ($i = 0; $i < $revision_count; $i++) { - $logs[] = $node->log = $this->randomName(32); + $logs[] = $settings['log'] = $this->randomName(32); // Create revision with a random title and body and update variables. - $node->title = $this->randomName(); - $node->body[$node->language()->langcode][0] = array( - 'value' => $this->randomName(32), - 'format' => filter_default_format(), - ); - $node->setNewRevision(); - $node->save(); - - $node = node_load($node->nid, TRUE); // Make sure we get revision information. - $nodes[] = clone $node; + $this->drupalCreateNode($settings); + $node = node_load($node->nid); // Make sure we get revision information. + $settings = get_object_vars($node); + $nodes[] = $node; } $this->nodes = $nodes; @@ -116,7 +110,7 @@ function testRevisions() { '%revision-date' => format_date($nodes[1]->revision_timestamp) )), 'Revision reverted.'); - $reverted_node = node_load($node->nid, TRUE); + $reverted_node = node_load($node->nid); $this->assertTrue(($nodes[1]->body[LANGUAGE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[LANGUAGE_NOT_SPECIFIED][0]['value']), t('Node reverted correctly.')); // Confirm that this is not the current version. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php index 46244b8..d5ea7b5 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php @@ -48,24 +48,20 @@ function setUp() { $logs = array(); // Get original node. - $nodes[] = clone $node; + $nodes[] = $node; // Create three revisions. $revision_count = 3; for ($i = 0; $i < $revision_count; $i++) { - $logs[] = $node->log = $this->randomName(32); - - // Create revision with a random title and body and update variables. - $node->title = $this->randomName(); - $node->body[$node->language()->langcode][0] = array( - 'value' => $this->randomName(32), - 'format' => filter_default_format(), - ); - $node->setNewRevision(); - $node->save(); + $logs[] = $settings['log'] = $this->randomName(32); + // Create revision with random title and body and update variables. + $this->drupalCreateNode($settings); $node = node_load($node->nid); // Make sure we get revision information. - $nodes[] = clone $node; + $settings = get_object_vars($node); + $settings['isDefaultRevision'] = TRUE; + + $nodes[] = $node; } $this->nodes = $nodes; @@ -100,7 +96,7 @@ function testRevisions() { $this->assertRaw(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => 'Basic page', '%title' => $nodes[1]->label(), '%revision-date' => format_date($nodes[1]->revision_timestamp))), 'Revision reverted.'); - $reverted_node = node_load($node->nid, TRUE); + $reverted_node = node_load($node->nid); $this->assertTrue(($nodes[1]->body[LANGUAGE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[LANGUAGE_NOT_SPECIFIED][0]['value']), 'Node reverted correctly.'); // Confirm that this is not the default version. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php index e2f5f29..f86bc52 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php @@ -51,13 +51,13 @@ function testImport() { $title = $this->randomName(8); $node = array( 'title' => $title, - 'body' => array(array('value' => $this->randomName(32))), + 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32)))), 'uid' => $this->web_user->uid, 'type' => 'article', 'nid' => $test_nid, + 'enforceIsNew' => TRUE, ); $node = node_submit(entity_create('node', $node)); - $node->enforceIsNew(); // Verify that node_submit did not overwrite the user ID. $this->assertEqual($node->uid, $this->web_user->uid, 'Function node_submit() preserves user ID'); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php index d17de34..452f0f4 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php @@ -35,7 +35,7 @@ function testNodeTokenReplacement() { 'type' => 'article', 'uid' => $account->uid, 'title' => 'Blinking Text', - 'body' => array(array('value' => $this->randomName(32), 'summary' => $this->randomName(16))), + 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32), 'summary' => $this->randomName(16)))), ); $node = $this->drupalCreateNode($settings); @@ -83,7 +83,7 @@ function testNodeTokenReplacement() { } // Repeat for a node without a summary. - $settings['body'] = array(array('value' => $this->randomName(32), 'summary' => '')); + $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32), 'summary' => ''))); $node = $this->drupalCreateNode($settings); // Load node (without summary) so that the body and summary fields are diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php index 3965ca4..8a744ec 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php @@ -7,7 +7,6 @@ namespace Drupal\node\Tests; -use Drupal\Core\Entity\EntityInterface; use Drupal\translation_entity\Tests\EntityTranslationUITest; /** @@ -68,10 +67,7 @@ protected function getNewEntityValues($langcode) { /** * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getFormSubmitAction(). */ - protected function getFormSubmitAction(EntityInterface $entity) { - if ($entity->status) { - return t('Save and unpublish'); - } + protected function getFormSubmitAction() { return t('Save and keep unpublished'); } @@ -128,7 +124,7 @@ protected function assertAuthoringInfo() { 'date[date]' => format_date($values[$langcode]['created'], 'custom', 'Y-m-d'), 'date[time]' => format_date($values[$langcode]['created'], 'custom', 'H:i:s'), ); - $this->drupalPost($path, $edit, $this->getFormSubmitAction($entity), array('language' => $languages[$langcode])); + $this->drupalPost($path, $edit, $this->getFormSubmitAction(), array('language' => $languages[$langcode])); } $entity = entity_load($this->entityType, $this->entityId, TRUE); diff --git a/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php b/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php index e627c6e..ee6ebe5 100644 --- a/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php @@ -25,7 +25,7 @@ public static function getInfo() { function testSummaryLength() { // Create a node to view. $settings = array( - 'body' => array(array('value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae arcu at leo cursus laoreet. Curabitur dui tortor, adipiscing malesuada tempor in, bibendum ac diam. Cras non tellus a libero pellentesque condimentum. What is a Drupalism? Suspendisse ac lacus libero. Ut non est vel nisl faucibus interdum nec sed leo. Pellentesque sem risus, vulputate eu semper eget, auctor in libero. Ut fermentum est vitae metus convallis scelerisque. Phasellus pellentesque rhoncus tellus, eu dignissim purus posuere id. Quisque eu fringilla ligula. Morbi ullamcorper, lorem et mattis egestas, tortor neque pretium velit, eget eleifend odio turpis eu purus. Donec vitae metus quis leo pretium tincidunt a pulvinar sem. Morbi adipiscing laoreet mauris vel placerat. Nullam elementum, nisl sit amet scelerisque malesuada, dolor nunc hendrerit quam, eu ultrices erat est in orci. Curabitur feugiat egestas nisl sed accumsan.')), + 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae arcu at leo cursus laoreet. Curabitur dui tortor, adipiscing malesuada tempor in, bibendum ac diam. Cras non tellus a libero pellentesque condimentum. What is a Drupalism? Suspendisse ac lacus libero. Ut non est vel nisl faucibus interdum nec sed leo. Pellentesque sem risus, vulputate eu semper eget, auctor in libero. Ut fermentum est vitae metus convallis scelerisque. Phasellus pellentesque rhoncus tellus, eu dignissim purus posuere id. Quisque eu fringilla ligula. Morbi ullamcorper, lorem et mattis egestas, tortor neque pretium velit, eget eleifend odio turpis eu purus. Donec vitae metus quis leo pretium tincidunt a pulvinar sem. Morbi adipiscing laoreet mauris vel placerat. Nullam elementum, nisl sit amet scelerisque malesuada, dolor nunc hendrerit quam, eu ultrices erat est in orci. Curabitur feugiat egestas nisl sed accumsan.'))), 'promote' => 1, ); $node = $this->drupalCreateNode($settings); diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index d5e396c..1207238 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -256,7 +256,7 @@ function hook_node_grants($account, $op) { * * Note: a deny all grant is not written to the database; denies are implicit. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that has just been saved. * * @return @@ -266,7 +266,7 @@ function hook_node_grants($account, $op) { * @see hook_node_access_records_alter() * @ingroup node_access */ -function hook_node_access_records(\Drupal\Core\Entity\EntityInterface $node) { +function hook_node_access_records(Drupal\node\Node $node) { // We only care about the node if it has been marked private. If not, it is // treated just like any other node and we completely ignore it. if ($node->private) { @@ -317,7 +317,7 @@ function hook_node_access_records(\Drupal\Core\Entity\EntityInterface $node) { * * @param $grants * The $grants array returned by hook_node_access_records(). - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node for which the grants were acquired. * * The preferred use of this hook is in a module that bridges multiple node @@ -329,7 +329,7 @@ function hook_node_access_records(\Drupal\Core\Entity\EntityInterface $node) { * @see hook_node_grants_alter() * @ingroup node_access */ -function hook_node_access_records_alter(&$grants, Drupal\Core\Entity\EntityInterface $node) { +function hook_node_access_records_alter(&$grants, Drupal\node\Node $node) { // Our module allows editors to mark specific articles with the 'is_preview' // field. If the node being saved has a TRUE value for that field, then only // our grants are retained, and other grants are removed. Doing so ensures @@ -459,14 +459,14 @@ function hook_node_operations() { * field_attach_delete() are called, and before the node is removed from the * node table in the database. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that is about to be deleted. * * @see hook_node_predelete() * @see node_delete_multiple() * @ingroup node_api_hooks */ -function hook_node_predelete(\Drupal\Core\Entity\EntityInterface $node) { +function hook_node_predelete(Drupal\node\Node $node) { db_delete('mytable') ->condition('nid', $node->nid) ->execute(); @@ -478,14 +478,14 @@ function hook_node_predelete(\Drupal\Core\Entity\EntityInterface $node) { * This hook is invoked from node_delete_multiple() after field_attach_delete() * has been called and after the node has been removed from the database. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that has been deleted. * * @see hook_node_predelete() * @see node_delete_multiple() * @ingroup node_api_hooks */ -function hook_node_delete(\Drupal\Core\Entity\EntityInterface $node) { +function hook_node_delete(Drupal\node\Node $node) { drupal_set_message(t('Node: @title has been deleted', array('@title' => $node->label()))); } @@ -496,12 +496,12 @@ function hook_node_delete(\Drupal\Core\Entity\EntityInterface $node) { * removed from the node_revision table, and before * field_attach_delete_revision() is called. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node revision (node object) that is being deleted. * * @ingroup node_api_hooks */ -function hook_node_revision_delete(\Drupal\Core\Entity\EntityInterface $node) { +function hook_node_revision_delete(Drupal\node\Node $node) { db_delete('mytable') ->condition('vid', $node->vid) ->execute(); @@ -523,12 +523,12 @@ function hook_node_revision_delete(\Drupal\Core\Entity\EntityInterface $node) { * write/update database queries executed from this hook are also not committed * immediately. Check node_save() and db_transaction() for more info. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that is being created. * * @ingroup node_api_hooks */ -function hook_node_insert(\Drupal\Core\Entity\EntityInterface $node) { +function hook_node_insert(Drupal\node\Node $node) { db_insert('mytable') ->fields(array( 'nid' => $node->nid, @@ -543,12 +543,12 @@ function hook_node_insert(\Drupal\Core\Entity\EntityInterface $node) { * This hook runs after a new node object has just been instantiated. It can be * used to set initial values, e.g. to provide defaults. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param \Drupal\node\Plugin\Core\Entity\Node $node * The node object. * * @ingroup node_api_hooks */ -function hook_node_create(\Drupal\Core\Entity\EntityInterface $node) { +function hook_node_create(\Drupal\node\Plugin\Core\Entity\Node $node) { if (!isset($node->foo)) { $node->foo = 'some_initial_value'; } @@ -615,7 +615,7 @@ function hook_node_load($nodes, $types) { * the default home page at path 'node', a recent content block, etc.) See * @link node_access Node access rights @endlink for a full explanation. * - * @param Drupal\Core\Entity\EntityInterface|string $node + * @param Drupal\node\Node|string $node * Either a node entity or the machine name of the content type on which to * perform the access check. * @param string $op @@ -669,12 +669,12 @@ function hook_node_access($node, $op, $account, $langcode) { * This hook is invoked from NodeFormController::prepareEntity() after the * type-specific hook_prepare() is invoked. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that is about to be shown on the add/edit form. * * @ingroup node_api_hooks */ -function hook_node_prepare(\Drupal\Core\Entity\EntityInterface $node) { +function hook_node_prepare(Drupal\node\Node $node) { if (!isset($node->comment)) { $node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN); } @@ -686,7 +686,7 @@ function hook_node_prepare(\Drupal\Core\Entity\EntityInterface $node) { * This hook is invoked from node_search_execute(), after node_load() and * node_view() have been called. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node being displayed in a search result. * @param $langcode * Language code of result being displayed. @@ -702,7 +702,7 @@ function hook_node_prepare(\Drupal\Core\Entity\EntityInterface $node) { * * @ingroup node_api_hooks */ -function hook_node_search_result(\Drupal\Core\Entity\EntityInterface $node, $langcode) { +function hook_node_search_result(Drupal\node\Node $node, $langcode) { $comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->nid))->fetchField(); return array('comment' => format_plural($comments, '1 comment', '@count comments')); } @@ -713,12 +713,12 @@ function hook_node_search_result(\Drupal\Core\Entity\EntityInterface $node, $lan * This hook is invoked from node_save() before the node is saved to the * database. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that is being inserted or updated. * * @ingroup node_api_hooks */ -function hook_node_presave(\Drupal\Core\Entity\EntityInterface $node) { +function hook_node_presave(Drupal\node\Node $node) { if ($node->nid && $node->moderate) { // Reset votes when node is updated: $node->score = 0; @@ -743,12 +743,12 @@ function hook_node_presave(\Drupal\Core\Entity\EntityInterface $node) { * write/update database queries executed from this hook are also not committed * immediately. Check node_save() and db_transaction() for more info. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that is being updated. * * @ingroup node_api_hooks */ -function hook_node_update(\Drupal\Core\Entity\EntityInterface $node) { +function hook_node_update(Drupal\node\Node $node) { db_update('mytable') ->fields(array('extra' => $node->extra)) ->condition('nid', $node->nid) @@ -761,7 +761,7 @@ function hook_node_update(\Drupal\Core\Entity\EntityInterface $node) { * This hook is invoked during search indexing, after node_load(), and after the * result of node_view() is added as $node->rendered to the node object. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node being indexed. * @param $langcode * Language code of the variant of the node being indexed. @@ -771,7 +771,7 @@ function hook_node_update(\Drupal\Core\Entity\EntityInterface $node) { * * @ingroup node_api_hooks */ -function hook_node_update_index(\Drupal\Core\Entity\EntityInterface $node, $langcode) { +function hook_node_update_index(Drupal\node\Node $node, $langcode) { $text = ''; $comments = db_query('SELECT subject, comment, format FROM {comment} WHERE nid = :nid AND status = :status', array(':nid' => $node->nid, ':status' => COMMENT_PUBLISHED)); foreach ($comments as $comment) { @@ -795,7 +795,7 @@ function hook_node_update_index(\Drupal\Core\Entity\EntityInterface $node, $lang * hook_node_presave() instead. If it is really necessary to change the node at * the validate stage, you can use form_set_value(). * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node being validated. * @param $form * The form being used to edit the node. @@ -804,7 +804,7 @@ function hook_node_update_index(\Drupal\Core\Entity\EntityInterface $node, $lang * * @ingroup node_api_hooks */ -function hook_node_validate(\Drupal\Core\Entity\EntityInterface $node, $form, &$form_state) { +function hook_node_validate(Drupal\node\Node $node, $form, &$form_state) { if (isset($node->end) && isset($node->start)) { if ($node->start > $node->end) { form_set_error('time', t('An event may not end before it starts.')); @@ -823,7 +823,7 @@ function hook_node_validate(\Drupal\Core\Entity\EntityInterface $node, $form, &$ * properties. See hook_field_attach_extract_form_values() for customizing * field-related properties. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node entity being updated in response to a form submission. * @param $form * The form being used to edit the node. @@ -832,7 +832,7 @@ function hook_node_validate(\Drupal\Core\Entity\EntityInterface $node, $form, &$ * * @ingroup node_api_hooks */ -function hook_node_submit(\Drupal\Core\Entity\EntityInterface $node, $form, &$form_state) { +function hook_node_submit(Drupal\node\Node $node, $form, &$form_state) { // Decompose the selected menu parent option into 'menu_name' and 'plid', if // the form used the default parent selection widget. if (!empty($form_state['values']['menu']['parent'])) { @@ -852,7 +852,7 @@ function hook_node_submit(\Drupal\Core\Entity\EntityInterface $node, $form, &$fo * the RSS item generated for this node. * For details on how this is used, see node_feed(). * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param \Drupal\node\Plugin\Core\Entity\Node $node * The node that is being assembled for rendering. * @param \Drupal\entity\Plugin\Core\Entity\EntityDisplay $display * The entity_display object holding the display options configured for the @@ -868,7 +868,7 @@ function hook_node_submit(\Drupal\Core\Entity\EntityInterface $node, $form, &$fo * * @ingroup node_api_hooks */ -function hook_node_view(\Drupal\Core\Entity\EntityInterface $node, \Drupal\entity\Plugin\Core\Entity\EntityDisplay $display, $view_mode, $langcode) { +function hook_node_view(\Drupal\node\Plugin\Core\Entity\Node $node, \Drupal\entity\Plugin\Core\Entity\EntityDisplay $display, $view_mode, $langcode) { // Only do the extra work if the component is configured to be displayed. // This assumes a 'mymodule_addition' extra field has been defined for the // node type in hook_field_extra_fields(). @@ -895,7 +895,7 @@ function hook_node_view(\Drupal\Core\Entity\EntityInterface $node, \Drupal\entit * * @param $build * A renderable array representing the node content. - * @param \Drupal\Core\Entity\EntityInterface $node + * @param \Drupal\node\Plugin\Core\Entity\Node $node * The node being rendered. * @param \Drupal\entity\Plugin\Core\Entity\EntityDisplay $display * The entity_display object holding the display options configured for the @@ -906,7 +906,7 @@ function hook_node_view(\Drupal\Core\Entity\EntityInterface $node, \Drupal\entit * * @ingroup node_api_hooks */ -function hook_node_view_alter(&$build, \Drupal\Core\Entity\EntityInterface $node, \Drupal\entity\Plugin\Core\Entity\EntityDisplay $display) { +function hook_node_view_alter(&$build, \Drupal\node\Plugin\Core\Entity\Node $node, \Drupal\entity\Plugin\Core\Entity\EntityDisplay $display) { if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) { // Change its weight. $build['an_additional_field']['#weight'] = -10; @@ -1088,12 +1088,12 @@ function hook_node_type_delete($info) { * removed from the node table in the database, before hook_node_delete() is * invoked, and before field_attach_delete() is called. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that is being deleted. * * @ingroup node_api_hooks */ -function hook_delete(\Drupal\Core\Entity\EntityInterface $node) { +function hook_delete(Drupal\node\Node $node) { db_delete('mytable') ->condition('nid', $node->nid) ->execute(); @@ -1108,12 +1108,12 @@ function hook_delete(\Drupal\Core\Entity\EntityInterface $node) { * This hook is invoked from NodeFormController::prepareEntity() before the * general hook_node_prepare() is invoked. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that is about to be shown on the add/edit form. * * @ingroup node_api_hooks */ -function hook_prepare(\Drupal\Core\Entity\EntityInterface $node) { +function hook_prepare(Drupal\node\Node $node) { if ($file = file_check_upload($field_name)) { $file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE)); if ($file) { @@ -1144,7 +1144,7 @@ function hook_prepare(\Drupal\Core\Entity\EntityInterface $node) { * displayed automatically by the node module. This hook just needs to * return the node title and form editing fields specific to the node type. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node being added or edited. * @param $form_state * The form state array. @@ -1155,7 +1155,7 @@ function hook_prepare(\Drupal\Core\Entity\EntityInterface $node) { * * @ingroup node_api_hooks */ -function hook_form(\Drupal\Core\Entity\EntityInterface $node, &$form_state) { +function hook_form(Drupal\node\Node $node, &$form_state) { $type = node_type_load($node->type); $form['title'] = array( @@ -1196,12 +1196,12 @@ function hook_form(\Drupal\Core\Entity\EntityInterface $node, &$form_state) { * node table in the database, before field_attach_insert() is called, and * before hook_node_insert() is invoked. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that is being created. * * @ingroup node_api_hooks */ -function hook_insert(\Drupal\Core\Entity\EntityInterface $node) { +function hook_insert(Drupal\node\Node $node) { db_insert('mytable') ->fields(array( 'nid' => $node->nid, @@ -1255,12 +1255,12 @@ function hook_load($nodes) { * node table in the database, before field_attach_update() is called, and * before hook_node_update() is invoked. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node that is being updated. * * @ingroup node_api_hooks */ -function hook_update(\Drupal\Core\Entity\EntityInterface $node) { +function hook_update(Drupal\node\Node $node) { db_update('mytable') ->fields(array('extra' => $node->extra)) ->condition('nid', $node->nid) @@ -1284,7 +1284,7 @@ function hook_update(\Drupal\Core\Entity\EntityInterface $node) { * have no effect. The preferred method to change a node's content is to use * hook_node_presave() instead. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node being validated. * @param $form * The form being used to edit the node. @@ -1293,7 +1293,7 @@ function hook_update(\Drupal\Core\Entity\EntityInterface $node) { * * @ingroup node_api_hooks */ -function hook_validate(\Drupal\Core\Entity\EntityInterface $node, $form, &$form_state) { +function hook_validate(Drupal\node\Node $node, $form, &$form_state) { if (isset($node->end) && isset($node->start)) { if ($node->start > $node->end) { form_set_error('time', t('An event may not end before it starts.')); @@ -1311,7 +1311,7 @@ function hook_validate(\Drupal\Core\Entity\EntityInterface $node, $form, &$form_ * that the node type module can define a custom method for display, or add to * the default display. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param \Drupal\node\Plugin\Core\Entity\Node $node * The node to be displayed, as returned by node_load(). * @param \Drupal\entity\Plugin\Core\Entity\EntityDisplay $display * The entity_display object holding the display options configured for the @@ -1332,7 +1332,7 @@ function hook_validate(\Drupal\Core\Entity\EntityInterface $node, $form, &$form_ * * @ingroup node_api_hooks */ -function hook_view(\Drupal\Core\Entity\EntityInterface $node, \Drupal\entity\Plugin\Core\Entity\EntityDisplay $display, $view_mode) { +function hook_view(\Drupal\node\Plugin\Core\Entity\Node $node, \Drupal\entity\Plugin\Core\Entity\EntityDisplay $display, $view_mode) { if ($view_mode == 'full' && node_is_page($node)) { $breadcrumb = array(); $breadcrumb[] = l(t('Home'), NULL); diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 6ce0874..0123692 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -15,10 +15,11 @@ use Drupal\Core\Database\Query\SelectExtender; use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Datetime\DrupalDateTime; -use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Template\Attribute; -use Drupal\entity\Plugin\Core\Entity\EntityDisplay; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\file\Plugin\Core\Entity\File; +use Drupal\Core\Entity\EntityInterface; +use Drupal\entity\Plugin\Core\Entity\EntityDisplay; /** * Denotes that the node is not published. @@ -254,15 +255,15 @@ function node_entity_display_alter(EntityDisplay $display, $context) { /** * Entity URI callback. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity. * * @return array * An array with 'path' as the key and the path to the node as its value. */ -function node_uri(EntityInterface $node) { +function node_uri(Node $node) { return array( - 'path' => 'node/' . $node->nid->value, + 'path' => 'node/' . $node->nid, ); } @@ -411,13 +412,13 @@ function node_type_get_label($name) { /** * Returns the node type label for the passed node. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity to return the node type's label for. * * @return string|false * The node type label or FALSE if the node type is not found. */ -function node_get_type_label(EntityInterface $node) { +function node_get_type_label($node) { $types = _node_types_build()->names; return isset($types[$node->type]) ? $types[$node->type] : FALSE; } @@ -910,7 +911,7 @@ function node_hook($type, $hook) { /** * Invokes a node hook. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A Node entity. * @param $hook * A string containing the name of the hook. @@ -921,7 +922,7 @@ function node_hook($type, $hook) { * @return * The returned value of the invoked hook. */ -function node_invoke(EntityInterface $node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) { +function node_invoke($node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) { if ($function = node_hook($node->type, $hook)) { return $function($node, $a2, $a3, $a4); } @@ -947,12 +948,7 @@ function node_invoke(EntityInterface $node, $hook, $a2 = NULL, $a3 = NULL, $a4 = * @see Drupal\Core\Entity\Query\EntityQueryInterface */ function node_load_multiple(array $nids = NULL, $reset = FALSE) { - $entities = entity_load_multiple('node', $nids, $reset); - // Return BC-entities. - foreach ($entities as $id => $entity) { - $entities[$id] = $entity->getBCEntity(); - } - return $entities; + return entity_load_multiple('node', $nids, $reset); } /** @@ -968,8 +964,7 @@ function node_load_multiple(array $nids = NULL, $reset = FALSE) { * A fully-populated node entity, or FALSE if the node is not found. */ function node_load($nid = NULL, $reset = FALSE) { - $entity = entity_load('node', $nid, $reset); - return $entity ? $entity->getBCEntity() : FALSE; + return entity_load('node', $nid, $reset); } /** @@ -988,13 +983,13 @@ function node_revision_load($vid = NULL) { /** * Prepares a node for saving by populating the author and creation date. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node object. * * @return Drupal\node\Node * An updated node object. */ -function node_submit(EntityInterface $node) { +function node_submit(Node $node) { global $user; // A user might assign the node author by entering a user name in the node @@ -1022,11 +1017,11 @@ function node_submit(EntityInterface $node) { /** * Saves changes to a node or adds a new node. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The $node entity to be saved. If $node->nid is * omitted (or $node->is_new is TRUE), a new node will be added. */ -function node_save(EntityInterface $node) { +function node_save(Node $node) { $node->save(); } @@ -1069,7 +1064,7 @@ function node_revision_delete($revision_id) { /** * Page callback: Generates an array which displays a node detail page. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity. * @param $message * (optional) A flag which sets a page title relevant to the revision being @@ -1080,7 +1075,7 @@ function node_revision_delete($revision_id) { * * @see node_menu() */ -function node_show(EntityInterface $node, $message = FALSE) { +function node_show(Node $node, $message = FALSE) { if ($message) { drupal_set_title(t('Revision of %title from %date', array('%title' => $node->label(), '%date' => format_date($node->revision_timestamp))), PASS_THROUGH); } @@ -1099,13 +1094,13 @@ function node_show(EntityInterface $node, $message = FALSE) { /** * Checks whether the current page is the full page view of the passed-in node. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity. * * @return * The ID of the node if this is a full page view, otherwise FALSE. */ -function node_is_page(EntityInterface $node) { +function node_is_page(Node $node) { $page_node = menu_get_object(); return (!empty($page_node) ? $page_node->nid == $node->nid : FALSE); } @@ -1413,7 +1408,7 @@ function node_search_execute($keys = NULL, $conditions = NULL) { 'type' => check_plain(node_get_type_label($node)), 'title' => $node->label($item->langcode), 'user' => theme('username', array('account' => $node)), - 'date' => $node->changed, + 'date' => $node->get('changed', $item->langcode), 'node' => $node, 'extra' => $extra, 'score' => $item->calculated_score, @@ -1544,7 +1539,7 @@ function theme_node_search_admin($variables) { /** * Access callback: Checks node revision access. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node to check. * @param $op * (optional) The specific operation being checked. Defaults to 'view.' @@ -1562,7 +1557,7 @@ function theme_node_search_admin($variables) { * * @see node_menu() */ -function _node_revision_access(EntityInterface $node, $op = 'view', $account = NULL, $langcode = NULL) { +function _node_revision_access(Node $node, $op = 'view', $account = NULL, $langcode = NULL) { $access = &drupal_static(__FUNCTION__, array()); $map = array( @@ -1844,7 +1839,7 @@ function node_type_page_title($type) { /** * Title callback: Displays the node's title. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node entity. * * @return @@ -1852,7 +1847,7 @@ function node_type_page_title($type) { * * @see node_menu() */ -function node_page_title(EntityInterface $node) { +function node_page_title(Node $node) { return $node->label(); } @@ -1872,13 +1867,13 @@ function node_last_changed($nid) { /** * Returns a list of all the existing revision numbers for the node passed in. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node entity. * * @return * An associative array keyed by node revision number. */ -function node_revision_list(EntityInterface $node) { +function node_revision_list(Node $node) { $revisions = array(); $result = db_query('SELECT r.vid, r.title, r.log, r.uid, n.vid AS current_vid, r.timestamp, u.name FROM {node_revision} r LEFT JOIN {node} n ON n.vid = r.vid INNER JOIN {users} u ON u.uid = r.uid WHERE r.nid = :nid ORDER BY r.vid DESC', array(':nid' => $node->nid)); foreach ($result as $revision) { @@ -2153,7 +2148,7 @@ function node_feed($nids = FALSE, $channel = array()) { /** * Generates an array for rendering the given node. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity. * @param $view_mode * (optional) View mode, e.g., 'full', 'teaser'... Defaults to 'full.' @@ -2164,7 +2159,7 @@ function node_feed($nids = FALSE, $channel = array()) { * @return * An array as expected by drupal_render(). */ -function node_view(EntityInterface $node, $view_mode = 'full', $langcode = NULL) { +function node_view(Node $node, $view_mode = 'full', $langcode = NULL) { return entity_view($node, $view_mode, $langcode); } @@ -2189,7 +2184,7 @@ function node_view_multiple($nodes, $view_mode = 'teaser', $langcode = NULL) { /** * Page callback: Displays a single node. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node entity. * * @return @@ -2197,7 +2192,7 @@ function node_view_multiple($nodes, $view_mode = 'teaser', $langcode = NULL) { * * @see node_menu() */ -function node_page_view(EntityInterface $node) { +function node_page_view(Node $node) { // If there is a menu link to this node, the link becomes the last part // of the active trail, and the link name becomes the page title. // Thus, we must explicitly set the page title to be the node title. @@ -2238,10 +2233,10 @@ function node_update_index() { /** * Indexes a single node. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node to index. */ -function _node_index_node(EntityInterface $node) { +function _node_index_node(Node $node) { // Save the changed time of the most recent indexed node, for the search // results half-life calculation. @@ -2497,7 +2492,7 @@ function node_form_system_themes_admin_form_submit($form, &$form_state) { * - "update" * - "delete" * - "create" - * @param Drupal\Core\Entity\EntityInterface|string|stdClass $node + * @param Drupal\node\Node|string|stdClass $node * The node entity on which the operation is to be performed, or the node type * object, or node type string (e.g., 'forum') for the 'create' operation. * @param $account @@ -2542,19 +2537,6 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) { $langcode = (is_object($node) && isset($node->nid)) ? $node->langcode : ''; } - // Fetch information from the node object if possible. - $node_status = NULL; - $node_uid = NULL; - if (is_object($node)) { - $node_status = (isset($node->status)) ? $node->status : $node_status; - $node_uid = (isset($node->uid)) ? $node->uid : $node_uid; - // If it is a proper EntityNG object, use the proper methods. - if ($node instanceof \Drupal\Core\Entity\EntityNG){ - $node_status = $node->get('status', $langcode)->value; - $node_uid = $node->get('uid', $langcode)->value ; - } - } - // If we've already checked access for this node, user and op, return from // cache. if (isset($rights[$account->uid][$cid][$langcode][$op])) { @@ -2586,14 +2568,14 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) { } // Check if authors can view their own unpublished nodes. - if ($op == 'view' && empty($node_status) && user_access('view own unpublished content', $account) && $account->uid === $node_uid && $account->uid != 0) { + if ($op == 'view' && !$node->get('status', $langcode) && user_access('view own unpublished content', $account) && $account->uid == $node->get('uid', $langcode) && $account->uid != 0) { $rights[$account->uid][$cid][$langcode][$op] = TRUE; return TRUE; } // If the module did not override the access rights, use those set in the // node_access table. - if ($op != 'create' && !empty($node->nid)) { + if ($op != 'create' && $node->nid) { if (module_implements('node_grants')) { $query = db_select('node_access'); $query->addExpression('1'); @@ -2623,7 +2605,7 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) { $rights[$account->uid][$cid][$langcode][$op] = $result; return $result; } - elseif (is_object($node) && $op == 'view' && !empty($node_status)) { + elseif (is_object($node) && $op == 'view' && $node->get('status', $langcode)) { // If no modules implement hook_node_grants(), the default behavior is to // allow all users to view published nodes, so reflect that here. $rights[$account->uid][$cid][$langcode][$op] = TRUE; @@ -2937,13 +2919,13 @@ function node_query_node_access_alter(AlterableInterface $query) { * via hook_node_access_records_alter() implementations, and saves the collected * and altered grants to the database. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The $node to acquire grants for. * @param $delete * (optional) Whether to delete existing node access records before inserting * new ones. Defaults to TRUE. */ -function node_access_acquire_grants(EntityInterface $node, $delete = TRUE) { +function node_access_acquire_grants(Node $node, $delete = TRUE) { $grants = module_invoke_all('node_access_records', $node); // Let modules alter the grants. drupal_alter('node_access_records', $grants, $node); @@ -2965,7 +2947,7 @@ function node_access_acquire_grants(EntityInterface $node, $delete = TRUE) { * Note: Don't call this function directly from a contributed module. Call * node_access_acquire_grants() instead. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node whose grants are being written. * @param $grants * A list of grants to write. Each grant is an array that must contain the @@ -2983,7 +2965,7 @@ function node_access_acquire_grants(EntityInterface $node, $delete = TRUE) { * * @see node_access_acquire_grants() */ -function _node_access_write_grants(EntityInterface $node, $grants, $realm = NULL, $delete = TRUE) { +function _node_access_write_grants(Node $node, $grants, $realm = NULL, $delete = TRUE) { if ($delete) { $query = db_delete('node_access')->condition('nid', $node->nid); if ($realm) { @@ -3186,7 +3168,7 @@ function _node_access_rebuild_batch_finished($success, $results, $operations) { /** * Implements hook_form(). */ -function node_content_form(EntityInterface $node, $form_state) { +function node_content_form(Node $node, $form_state) { // @todo It is impossible to define a content type without implementing // hook_form(). Remove this requirement. $form = array(); @@ -3282,7 +3264,7 @@ function node_action_info() { /** * Sets the status of a node to 1 (published). * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity. * @param $context * (optional) Array of additional information about what triggered the action. @@ -3290,7 +3272,7 @@ function node_action_info() { * * @ingroup actions */ -function node_publish_action(EntityInterface $node, $context = array()) { +function node_publish_action(Node $node, $context = array()) { $node->status = NODE_PUBLISHED; watchdog('action', 'Set @type %title to published.', array('@type' => node_get_type_label($node), '%title' => $node->label())); } @@ -3298,7 +3280,7 @@ function node_publish_action(EntityInterface $node, $context = array()) { /** * Sets the status of a node to 0 (unpublished). * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity. * @param $context * (optional) Array of additional information about what triggered the action. @@ -3306,7 +3288,7 @@ function node_publish_action(EntityInterface $node, $context = array()) { * * @ingroup actions */ -function node_unpublish_action(EntityInterface $node, $context = array()) { +function node_unpublish_action(Node $node, $context = array()) { $node->status = NODE_NOT_PUBLISHED; watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_get_type_label($node), '%title' => $node->label())); } @@ -3314,7 +3296,7 @@ function node_unpublish_action(EntityInterface $node, $context = array()) { /** * Sets the sticky-at-top-of-list property of a node to 1. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity. * @param $context * (optional) Array of additional information about what triggered the action. @@ -3322,7 +3304,7 @@ function node_unpublish_action(EntityInterface $node, $context = array()) { * * @ingroup actions */ -function node_make_sticky_action(EntityInterface $node, $context = array()) { +function node_make_sticky_action(Node $node, $context = array()) { $node->sticky = NODE_STICKY; watchdog('action', 'Set @type %title to sticky.', array('@type' => node_get_type_label($node), '%title' => $node->label())); } @@ -3330,7 +3312,7 @@ function node_make_sticky_action(EntityInterface $node, $context = array()) { /** * Sets the sticky-at-top-of-list property of a node to 0. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity. * @param $context * (optional) Array of additional information about what triggered the action. @@ -3338,7 +3320,7 @@ function node_make_sticky_action(EntityInterface $node, $context = array()) { * * @ingroup actions */ -function node_make_unsticky_action(EntityInterface $node, $context = array()) { +function node_make_unsticky_action(Node $node, $context = array()) { $node->sticky = NODE_NOT_STICKY; watchdog('action', 'Set @type %title to unsticky.', array('@type' => node_get_type_label($node), '%title' => $node->label())); } @@ -3346,7 +3328,7 @@ function node_make_unsticky_action(EntityInterface $node, $context = array()) { /** * Sets the promote property of a node to 1. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity. * @param $context * (optional) Array of additional information about what triggered the action. @@ -3354,7 +3336,7 @@ function node_make_unsticky_action(EntityInterface $node, $context = array()) { * * @ingroup actions */ -function node_promote_action(EntityInterface $node, $context = array()) { +function node_promote_action(Node $node, $context = array()) { $node->promote = NODE_PROMOTED; watchdog('action', 'Promoted @type %title to front page.', array('@type' => node_get_type_label($node), '%title' => $node->label())); } @@ -3362,7 +3344,7 @@ function node_promote_action(EntityInterface $node, $context = array()) { /** * Sets the promote property of a node to 0. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity. * @param $context * (optional) Array of additional information about what triggered the action. @@ -3370,7 +3352,7 @@ function node_promote_action(EntityInterface $node, $context = array()) { * * @ingroup actions */ -function node_unpromote_action(EntityInterface $node, $context = array()) { +function node_unpromote_action(Node $node, $context = array()) { $node->promote = NODE_NOT_PROMOTED; watchdog('action', 'Removed @type %title from front page.', array('@type' => node_get_type_label($node), '%title' => $node->label())); } @@ -3378,12 +3360,12 @@ function node_unpromote_action(EntityInterface $node, $context = array()) { /** * Saves a node. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node to be saved. * * @ingroup actions */ -function node_save_action(EntityInterface $node) { +function node_save_action(Node $node) { $node->save(); watchdog('action', 'Saved @type %title', array('@type' => node_get_type_label($node), '%title' => $node->label())); } @@ -3391,7 +3373,7 @@ function node_save_action(EntityInterface $node) { /** * Assigns ownership of a node to a user. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity to modify. * @param $context * Array of additional information about what triggered the action. Includes @@ -3403,7 +3385,7 @@ function node_save_action(EntityInterface $node) { * @see node_assign_owner_action_submit() * @ingroup actions */ -function node_assign_owner_action(EntityInterface $node, $context) { +function node_assign_owner_action(Node $node, $context) { $node->uid = $context['owner_uid']; $owner_name = db_query("SELECT name FROM {users} WHERE uid = :uid", array(':uid' => $context['owner_uid']))->fetchField(); watchdog('action', 'Changed owner of @type %title to uid %name.', array('@type' => node_get_type_label($node), '%title' => $node->label(), '%name' => $owner_name)); @@ -3512,7 +3494,7 @@ function node_unpublish_by_keyword_action_submit($form, $form_state) { /** * Unpublishes a node containing certain keywords. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity to modify. * @param $context * Array of additional information about what triggered the action. Includes @@ -3525,7 +3507,7 @@ function node_unpublish_by_keyword_action_submit($form, $form_state) { * * @ingroup actions */ -function node_unpublish_by_keyword_action(EntityInterface $node, $context) { +function node_unpublish_by_keyword_action(Node $node, $context) { foreach ($context['keywords'] as $keyword) { $elements = node_view(clone $node); if (strpos(drupal_render($elements), $keyword) !== FALSE || strpos($node->label(), $keyword) !== FALSE) { diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index 863babd..008ef76 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -9,7 +9,7 @@ * @see node_menu() */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; /** * Page callback: Presents the node editing form. @@ -106,7 +106,7 @@ function node_add($node_type) { 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'langcode' => $langcode ? $langcode : language_default()->langcode, - ))->getBCEntity(); + )); drupal_set_title(t('Create @name', array('@name' => $node_type->name)), PASS_THROUGH); $output = entity_get_form($node); @@ -116,7 +116,7 @@ function node_add($node_type) { /** * Generates a node preview. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The node to preview. * * @return @@ -124,7 +124,7 @@ function node_add($node_type) { * * @see node_form_build_preview() */ -function node_preview(EntityInterface $node) { +function node_preview(Node $node) { if (node_access('create', $node) || node_access('update', $node)) { _field_invoke_multiple('load', 'node', array($node->nid => $node)); // Load the user's name when needed. diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module index 66c6b59..493b486 100644 --- a/core/modules/node/tests/modules/node_access_test/node_access_test.module +++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module @@ -9,7 +9,7 @@ * a special 'node test view' permission. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_node_grants(). @@ -32,7 +32,7 @@ function node_access_test_node_grants($account, $op) { /** * Implements hook_node_access_records(). */ -function node_access_test_node_access_records(EntityInterface $node) { +function node_access_test_node_access_records(Node $node) { $grants = array(); // For NodeAccessBaseTableTestCase, only set records for private nodes. if (!state()->get('node_access_test.private') || $node->private) { @@ -207,28 +207,28 @@ function node_access_test_node_load($nodes, $types) { * Implements hook_node_predelete(). */ -function node_access_test_node_predelete(EntityInterface $node) { +function node_access_test_node_predelete(Node $node) { db_delete('node_access_test')->condition('nid', $node->nid)->execute(); } /** * Implements hook_node_insert(). */ -function node_access_test_node_insert(EntityInterface $node) { +function node_access_test_node_insert(Node $node) { _node_access_test_node_write($node); } /** * Implements hook_nodeapi_update(). */ -function node_access_test_node_update(EntityInterface $node) { +function node_access_test_node_update(Node $node) { _node_access_test_node_write($node); } /** * Helper for node insert/update. */ -function _node_access_test_node_write(EntityInterface $node) { +function _node_access_test_node_write(Node $node) { if (isset($node->private)) { db_merge('node_access_test') ->key(array('nid' => $node->nid)) diff --git a/core/modules/node/tests/modules/node_test/node_test.module b/core/modules/node/tests/modules/node_test/node_test.module index f3fd04b..6fdb3c5 100644 --- a/core/modules/node/tests/modules/node_test/node_test.module +++ b/core/modules/node/tests/modules/node_test/node_test.module @@ -8,7 +8,7 @@ * interaction with the Node module. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\entity\Plugin\Core\Entity\EntityDisplay; /** @@ -30,7 +30,7 @@ function node_test_node_load($nodes, $types) { /** * Implements hook_node_view(). */ -function node_test_node_view(EntityInterface $node, EntityDisplay $display, $view_mode) { +function node_test_node_view(Node $node, EntityDisplay $display, $view_mode) { if ($view_mode == 'rss') { // Add RSS elements and namespaces when building the RSS feed. $node->rss_elements[] = array( @@ -71,7 +71,7 @@ function node_test_node_grants($account, $op) { /** * Implements hook_node_access_records(). */ -function node_test_node_access_records(EntityInterface $node) { +function node_test_node_access_records(Node $node) { // Return nothing when testing for empty responses. if (!empty($node->disable_node_access)) { return; @@ -105,7 +105,7 @@ function node_test_node_access_records(EntityInterface $node) { /** * Implements hook_node_access_records_alter(). */ -function node_test_node_access_records_alter(&$grants, EntityInterface $node) { +function node_test_node_access_records_alter(&$grants, Node $node) { if (!empty($grants)) { foreach ($grants as $key => $grant) { // Alter grant from test_page_realm to test_alter_realm and modify the gid. @@ -128,7 +128,7 @@ function node_test_node_grants_alter(&$grants, $account, $op) { /** * Implements hook_node_presave(). */ -function node_test_node_presave(EntityInterface $node) { +function node_test_node_presave(Node $node) { if ($node->title == 'testing_node_presave') { // Sun, 19 Nov 1978 05:00:00 GMT $node->created = 280299600; @@ -146,7 +146,7 @@ function node_test_node_presave(EntityInterface $node) { /** * Implements hook_node_update(). */ -function node_test_node_update(EntityInterface $node) { +function node_test_node_update(Node $node) { // Determine changes on update. if (!empty($node->original) && $node->original->title == 'test_changes') { if ($node->original->title != $node->title) { @@ -173,7 +173,7 @@ function node_test_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\Entity * * @see \Drupal\node\Tests\NodeSaveTest::testNodeSaveOnInsert() */ -function node_test_node_insert(EntityInterface $node) { +function node_test_node_insert(Node $node) { // Set the node title to the node ID and save. if ($node->title == 'new') { $node->title = 'Node '. $node->nid; diff --git a/core/modules/node/tests/modules/node_test_exception/node_test_exception.module b/core/modules/node/tests/modules/node_test_exception/node_test_exception.module index 9eaa4f1..359af1f 100644 --- a/core/modules/node/tests/modules/node_test_exception/node_test_exception.module +++ b/core/modules/node/tests/modules/node_test_exception/node_test_exception.module @@ -5,12 +5,12 @@ * A module implementing node related hooks to test API interaction. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_node_insert(). */ -function node_test_exception_node_insert(EntityInterface $node) { +function node_test_exception_node_insert(Node $node) { if ($node->title == 'testing_transaction_exception') { throw new Exception('Test exception for rollback.'); } diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php index 5f6fcc1..3409185 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php @@ -70,7 +70,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(LANGUAGE_NOT_SPECIFIED => array(array('value' => 1))), ); $node = $this->drupalCreateNode($settings); @@ -120,7 +120,7 @@ function testOptionsAllowedValuesFloat() { // Create a node with actual data for the field. $settings = array( 'type' => $this->type, - $this->field_name => array(array('value' => .5)), + $this->field_name => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => .5))), ); $node = $this->drupalCreateNode($settings); @@ -172,7 +172,7 @@ function testOptionsAllowedValuesText() { // Create a node with actual data for the field. $settings = array( 'type' => $this->type, - $this->field_name => array(array('value' => 'One')), + $this->field_name => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'One'))), ); $node = $this->drupalCreateNode($settings); diff --git a/core/modules/path/path.module b/core/modules/path/path.module index b6a38f6..6401a8b 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -5,7 +5,7 @@ * Enables users to rename URLs. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\taxonomy\Plugin\Core\Entity\Term; @@ -186,7 +186,7 @@ function path_form_element_validate($element, &$form_state, $complete_form) { /** * Implements hook_node_insert(). */ -function path_node_insert(EntityInterface $node) { +function path_node_insert(Node $node) { if (isset($node->path)) { $alias = trim($node->path['alias']); // Only save a non-empty alias. @@ -202,7 +202,7 @@ function path_node_insert(EntityInterface $node) { /** * Implements hook_node_update(). */ -function path_node_update(EntityInterface $node) { +function path_node_update(Node $node) { if (isset($node->path)) { $path = $node->path; $alias = trim($path['alias']); @@ -223,7 +223,7 @@ function path_node_update(EntityInterface $node) { /** * Implements hook_node_predelete(). */ -function path_node_predelete(EntityInterface $node) { +function path_node_predelete(Node $node) { // Delete all aliases associated with this node. drupal_container()->get('path.crud')->delete(array('source' => 'node/' . $node->nid)); } diff --git a/core/modules/php/lib/Drupal/php/Tests/PhpTestBase.php b/core/modules/php/lib/Drupal/php/Tests/PhpTestBase.php index abb3412..596ebd8 100644 --- a/core/modules/php/lib/Drupal/php/Tests/PhpTestBase.php +++ b/core/modules/php/lib/Drupal/php/Tests/PhpTestBase.php @@ -58,6 +58,6 @@ function setUp() { * @return stdObject Node object. */ function createNodeWithCode() { - return $this->drupalCreateNode(array('body' => array(array('value' => '')))); + return $this->drupalCreateNode(array('body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => ''))))); } } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php index b78cabd..45488bd 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php @@ -7,7 +7,7 @@ namespace Drupal\rdf\Tests; -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\simpletest\WebTestBase; /** @@ -71,10 +71,10 @@ function testAttributesInTracker() { * * Tests the tracker page for RDFa markup. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Node $node * The node just created. */ - function _testBasicTrackerRdfaMarkup(EntityInterface $node) { + function _testBasicTrackerRdfaMarkup(Node $node) { $node_uri = url('node/' . $node->nid, array('absolute' => TRUE)); $user_uri = url('user/' . $node->uid, array('absolute' => TRUE)); diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 547075a..89494eb 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -787,9 +787,9 @@ function rdf_field_attach_view_alter(&$output, $context) { foreach ($element['#items'] as $delta => $item) { // This function is invoked during entity preview when taxonomy term // reference items might contain free-tagging terms that do not exist - // yet and thus have no $item['entity']. - if (isset($item['entity'])) { - $term = $item['entity']; + // yet and thus have no $item['taxonomy_term']. + if (isset($item['taxonomy_term'])) { + $term = $item['taxonomy_term']; if (!empty($term->rdf_mapping['rdftype'])) { $element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype']; } diff --git a/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php b/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php index d6973e5..a3a5c60 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php @@ -40,14 +40,14 @@ public function testCreate() { $this->enableService('entity:' . $entity_type, 'POST'); // Create a user account that has the required permissions to create - // resources via the REST API. + // resources via the web API. $account = $this->drupalCreateUser(array('restful post entity:' . $entity_type)); $this->drupalLogin($account); $entity_values = $this->entityValues($entity_type); $entity = entity_create($entity_type, $entity_values); $serialized = $serializer->serialize($entity, 'drupal_jsonld'); - // Create the entity over the REST API. + // Create the entity over the web API. $this->httpRequest('entity/' . $entity_type, 'POST', $serialized, 'application/vnd.drupal.ld+json'); $this->assertResponse(201); @@ -93,7 +93,7 @@ public function testCreate() { $this->assertResponse(403); $this->assertFalse(entity_load_multiple($entity_type, NULL, TRUE), 'No entity has been created in the database.'); - // Try to create a resource which is not REST API enabled. + // Try to create a resource which is not web API enabled. $this->enableService(FALSE); $this->drupalLogin($account); $this->httpRequest('entity/entity_test', 'POST', $serialized, 'application/vnd.drupal.ld+json'); diff --git a/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php b/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php index 9be9896..d4b9cc2 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php @@ -31,12 +31,12 @@ public static function getInfo() { public function setUp() { parent::setUp(); - // Enable REST API for the watchdog resource. + // Enable web API for the watchdog resource. $this->enableService('dblog'); } /** - * Writes a log messages and retrieves it via the REST API. + * Writes a log messages and retrieves it via the web API. */ public function testWatchdog() { // Write a log message to the DB. @@ -46,7 +46,7 @@ public function testWatchdog() { ->fetchField(); // Create a user account that has the required permissions to read - // the watchdog resource via the REST API. + // the watchdog resource via the web API. $account = $this->drupalCreateUser(array('restful get dblog')); $this->drupalLogin($account); diff --git a/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php b/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php index 2bed8ba..c29e7e6 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php @@ -38,14 +38,14 @@ public function testDelete() { foreach ($entity_types as $entity_type) { $this->enableService('entity:' . $entity_type, 'DELETE'); // Create a user account that has the required permissions to delete - // resources via the REST API. + // resources via the web API. $account = $this->drupalCreateUser(array('restful delete entity:' . $entity_type)); $this->drupalLogin($account); // Create an entity programmatically. $entity = $this->entityCreate($entity_type); $entity->save(); - // Delete it over the REST API. + // Delete it over the web API. $response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'DELETE'); // Clear the static cache with entity_load(), otherwise we won't see the // update. @@ -69,7 +69,7 @@ public function testDelete() { $this->assertResponse(403); $this->assertNotIdentical(FALSE, entity_load($entity_type, $entity->id(), TRUE), 'The ' . $entity_type . ' entity is still in the database.'); } - // Try to delete a resource which is not REST API enabled. + // Try to delete a resource which is not web API enabled. $this->enableService(FALSE); $account = $this->drupalCreateUser(); $this->drupalLogin($account); diff --git a/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php b/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php index 6cbfbd8..c428c86 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php @@ -142,7 +142,7 @@ protected function entityValues($entity_type) { 'field_test_text' => array(0 => array('value' => $this->randomString())), ); case 'node': - return array('title' => $this->randomString(), 'type' => $this->randomString()); + return array('title' => $this->randomString()); case 'user': return array('name' => $this->randomName()); default: @@ -151,10 +151,10 @@ protected function entityValues($entity_type) { } /** - * Enables the REST service interface for a specific entity type. + * Enables the web service interface for a specific entity type. * * @param string|FALSE $resource_type - * The resource type that should get REST API enabled or FALSE to disable all + * The resource type that should get web API enabled or FALSE to disable all * resource types. * @param string $method * The HTTP method to enable, e.g. GET, POST etc. @@ -162,7 +162,7 @@ protected function entityValues($entity_type) { * (Optional) The serialization format, e.g. jsonld. */ protected function enableService($resource_type, $method = 'GET', $format = NULL) { - // Enable REST API for this entity type. + // Enable web API for this entity type. $config = config('rest.settings'); $settings = array(); if ($resource_type) { @@ -176,7 +176,7 @@ protected function enableService($resource_type, $method = 'GET', $format = NULL $config->set('resources', $settings); $config->save(); - // Rebuild routing cache, so that the REST API paths are available. + // Rebuild routing cache, so that the web API paths are available. drupal_container()->get('router.builder')->rebuild(); // Reset the Simpletest permission cache, so that the new resource // permissions get picked up. diff --git a/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php b/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php index e157a2d..299bdd4 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php @@ -40,14 +40,14 @@ public function testRead() { foreach ($entity_types as $entity_type) { $this->enableService('entity:' . $entity_type, 'GET'); // Create a user account that has the required permissions to delete - // resources via the REST API. + // resources via the web API. $account = $this->drupalCreateUser(array('restful get entity:' . $entity_type)); $this->drupalLogin($account); // Create an entity programmatically. $entity = $this->entityCreate($entity_type); $entity->save(); - // Read it over the REST API. + // Read it over the web API. $response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, 'application/vnd.drupal.ld+json'); $this->assertResponse('200', 'HTTP response code is correct.'); $this->assertHeader('content-type', 'application/vnd.drupal.ld+json'); @@ -72,7 +72,7 @@ public function testRead() { $this->assertResponse(403); $this->assertNull(drupal_json_decode($response), 'No valid JSON found.'); } - // Try to read a resource which is not REST API enabled. + // Try to read a resource which is not web API enabled. $account = $this->drupalCreateUser(); $this->drupalLogin($account); $response = $this->httpRequest('entity/user/' . $account->id(), 'GET', NULL, 'application/vnd.drupal.ld+json'); diff --git a/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php b/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php index c920514..94be2bf 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php @@ -40,7 +40,7 @@ public function testPatchUpdate() { $this->enableService('entity:' . $entity_type, 'PATCH'); // Create a user account that has the required permissions to create - // resources via the REST API. + // resources via the web API. $account = $this->drupalCreateUser(array('restful patch entity:' . $entity_type)); $this->drupalLogin($account); @@ -55,7 +55,7 @@ public function testPatchUpdate() { unset($patch_entity->uuid); $serialized = $serializer->serialize($patch_entity, 'drupal_jsonld'); - // Update the entity over the REST API. + // Update the entity over the web API. $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, 'application/vnd.drupal.ld+json'); $this->assertResponse(204); @@ -68,7 +68,7 @@ public function testPatchUpdate() { $normalized['field_test_text'] = array(); $serialized = $serializer->encode($normalized, 'jsonld'); - // Update the entity over the REST API. + // Update the entity over the web API. $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, 'application/vnd.drupal.ld+json'); $this->assertResponse(204); @@ -87,7 +87,7 @@ public function testPatchUpdate() { $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, 'application/vnd.drupal.ld+json'); $this->assertResponse(403); - // Try to update a resource which is not REST API enabled. + // Try to update a resource which is not web API enabled. $this->enableService(FALSE); $this->drupalLogin($account); $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, 'application/vnd.drupal.ld+json'); @@ -105,7 +105,7 @@ public function testPutUpdate() { $this->enableService('entity:' . $entity_type, 'PUT'); // Create a user account that has the required permissions to create - // resources via the REST API. + // resources via the web API. $account = $this->drupalCreateUser(array('restful put entity:' . $entity_type)); $this->drupalLogin($account); @@ -121,7 +121,7 @@ public function testPutUpdate() { $update_entity->id->value = $entity->id(); $serialized = $serializer->serialize($update_entity, 'drupal_jsonld'); - // Update the entity over the REST API. + // Update the entity over the web API. $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PUT', $serialized, 'application/vnd.drupal.ld+json'); $this->assertResponse(204); @@ -157,7 +157,7 @@ public function testPutUpdate() { $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PUT', $serialized, 'application/vnd.drupal.ld+json'); $this->assertResponse(403); - // Try to update a resource which is not REST API enabled. + // Try to update a resource which is not web API enabled. $this->enableService(FALSE); $this->drupalLogin($account); $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PUT', $serialized, 'application/vnd.drupal.ld+json'); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php index 30073d7..4c94490 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php @@ -47,7 +47,7 @@ function setUp() { $this->searching_user = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval')); // Create initial nodes. - $node_params = array('type' => 'article', 'body' => array(array('value' => 'SearchCommentToggleTestCase'))); + $node_params = array('type' => 'article', 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'SearchCommentToggleTestCase')))); $this->searchable_nodes['1 comment'] = $this->drupalCreateNode($node_params); $this->searchable_nodes['0 comments'] = $this->drupalCreateNode($node_params); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php index 04d78a4..81db97d 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php @@ -221,7 +221,7 @@ function testAddNewComment() { $settings = array( 'type' => 'article', 'title' => 'short title', - 'body' => array(array('value' => 'short body text')), + 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'short body text'))), ); $user = $this->drupalCreateUser(array('search content', 'create article content', 'access content')); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchExactTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchExactTest.php index c52549f..7d3ba42 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchExactTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchExactTest.php @@ -32,12 +32,12 @@ function testExactQuery() { ); // Create nodes with exact phrase. for ($i = 0; $i <= 17; $i++) { - $settings['body'] = array(array('value' => 'love pizza')); + $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'love pizza'))); $this->drupalCreateNode($settings); } // Create nodes containing keywords. for ($i = 0; $i <= 17; $i++) { - $settings['body'] = array(array('value' => 'love cheesy pizza')); + $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'love cheesy pizza'))); $this->drupalCreateNode($settings); } diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php index e9526d8..e534971 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php @@ -57,35 +57,33 @@ function setUp() { $nodes = array( array( 'type' => 'page', - 'body' => array(array('value' => $this->randomName(32), 'format' => $default_format)), + 'body' => array( + 'en' => array(array('value' => $this->randomName(32), 'format' => $default_format)), + ), 'langcode' => 'en', ), array( 'type' => 'page', - 'body' => array(array('value' => $this->randomName(32), 'format' => $default_format)), + 'body' => array( + 'en' => array(array('value' => $this->randomName(32), 'format' => $default_format)), + 'hu' => array(array('value' => $this->randomName(32), 'format' => $default_format)), + ), 'langcode' => 'en', ), array( 'type' => 'page', - 'body' => array(array('value' => $this->randomName(32), 'format' => $default_format)), + 'body' => array( + 'en' => array(array('value' => $this->randomName(32), 'format' => $default_format)), + 'hu' => array(array('value' => $this->randomName(32), 'format' => $default_format)), + 'sv' => array(array('value' => $this->randomName(32), 'format' => $default_format)), + ), 'langcode' => 'en', ), ); $this->searchable_nodes = array(); - foreach ($nodes as $setting) { - $this->searchable_nodes[] = $this->drupalCreateNode($setting); + foreach ($nodes as $node) { + $this->searchable_nodes[] = $this->drupalCreateNode($node); } - // Add a single translation to the second node. - $translation = $this->searchable_nodes[1]->getTranslation('hu'); - $translation->body->value = $this->randomName(32); - $this->searchable_nodes[1]->save(); - - // Add two translations to the third node. - $translation = $this->searchable_nodes[2]->getTranslation('hu'); - $translation->body->value = $this->randomName(32); - $translation = $this->searchable_nodes[2]->getTranslation('sv'); - $translation->body->value = $this->randomName(32); - $this->searchable_nodes[2]->save(); } /** diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php index 67706cf..19c94cb 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php @@ -42,7 +42,7 @@ function setUp() { * Tests that search returns results with punctuation in the search phrase. */ function testPhraseSearchPunctuation() { - $node = $this->drupalCreateNode(array('body' => array(array('value' => "The bunny's ears were fluffy.")))); + $node = $this->drupalCreateNode(array('body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => "The bunny's ears were fluffy."))))); // Update the search index. module_invoke_all('update_index'); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php index 1e3bf78..540526b 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php @@ -45,7 +45,7 @@ function setUp() { foreach ($this->numbers as $num) { $info = array( - 'body' => array(array('value' => $num)), + 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $num))), 'type' => 'page', 'language' => LANGUAGE_NOT_SPECIFIED, ); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php index 6e81e5e..7d1a463 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php @@ -51,7 +51,7 @@ function setUp() { foreach ($this->numbers as $doc => $num) { $info = array( - 'body' => array(array('value' => $num)), + 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $num))), 'type' => 'page', 'language' => LANGUAGE_NOT_SPECIFIED, 'title' => $doc . ' number', diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchPreprocessLangcodeTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchPreprocessLangcodeTest.php index a8c2e61..c5d2451 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchPreprocessLangcodeTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchPreprocessLangcodeTest.php @@ -43,7 +43,7 @@ function setUp() { */ function testPreprocessLangcode() { // Create a node. - $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'en')); + $node = $this->drupalCreateNode(array('body' => array('en' => array(array())), 'langcode' => 'en')); // First update the index. This does the initial processing. node_update_index(); @@ -68,7 +68,7 @@ function testPreprocessStemming() { // Create a node. $node = $this->drupalCreateNode(array( 'title' => 'we are testing', - 'body' => array(array()), + 'body' => array('en' => array(array())), 'langcode' => 'en', )); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php index b029032..4987b56 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php @@ -36,7 +36,7 @@ function testRankings() { $settings = array( 'type' => 'page', 'title' => 'Drupal rocks', - 'body' => array(array('value' => "Drupal's search rocks")), + 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => "Drupal's search rocks"))), ); foreach (array(0, 1) as $num) { if ($num == 1) { @@ -46,7 +46,7 @@ function testRankings() { $settings[$node_rank] = 1; break; case 'relevance': - $settings['body'][0]['value'] .= " really rocks"; + $settings['body'][LANGUAGE_NOT_SPECIFIED][0]['value'] .= " really rocks"; break; case 'recent': $settings['created'] = REQUEST_TIME + 3600; @@ -128,13 +128,13 @@ function testHTMLRankings() { foreach ($shuffled_tags as $tag) { switch ($tag) { case 'a': - $settings['body'] = array(array('value' => l('Drupal Rocks', 'node'), 'format' => 'full_html')); + $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => l('Drupal Rocks', 'node'), 'format' => 'full_html'))); break; case 'notag': - $settings['body'] = array(array('value' => 'Drupal Rocks')); + $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'Drupal Rocks'))); break; default: - $settings['body'] = array(array('value' => "<$tag>Drupal Rocks", 'format' => 'full_html')); + $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => "<$tag>Drupal Rocks", 'format' => 'full_html'))); break; } $nodes[$tag] = $this->drupalCreateNode($settings); @@ -167,7 +167,7 @@ function testHTMLRankings() { // Test tags with the same weight against the sorted tags. $unsorted_tags = array('u', 'b', 'i', 'strong', 'em'); foreach ($unsorted_tags as $tag) { - $settings['body'] = array(array('value' => "<$tag>Drupal Rocks", 'format' => 'full_html')); + $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => "<$tag>Drupal Rocks", 'format' => 'full_html'))); $node = $this->drupalCreateNode($settings); // Update the search index. @@ -203,7 +203,7 @@ function testDoubleRankings() { $settings = array( 'type' => 'page', 'title' => 'Drupal rocks', - 'body' => array(array('value' => "Drupal's search rocks")), + 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => "Drupal's search rocks"))), 'sticky' => 1, ); diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 85e58d3..375c43f 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -5,7 +5,7 @@ * Enables site-wide keyword searching. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; /** * Matches all 'N' Unicode character classes (numbers) @@ -792,7 +792,7 @@ function search_touch_node($nid) { /** * Implements hook_node_update_index(). */ -function search_node_update_index(EntityInterface $node) { +function search_node_update_index(Node $node) { // Transplant links to a node into the target node. $result = db_query("SELECT caption FROM {search_node_links} WHERE nid = :nid", array(':nid' => $node->nid), array('target' => 'slave')); $output = array(); @@ -807,7 +807,7 @@ function search_node_update_index(EntityInterface $node) { /** * Implements hook_node_update(). */ -function search_node_update(EntityInterface $node) { +function search_node_update(Node $node) { // Reindex the node when it is updated. The node is automatically indexed // when it is added, simply by being added to the node table. search_touch_node($node->nid); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 9e8b097..44e29c2 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -172,7 +172,7 @@ function __construct($test_id = NULL) { * @param $reset * (optional) Whether to reset the entity cache. * - * @return \Drupal\Core\Entity\EntityInterface + * @return \Drupal\node\Plugin\Core\Entity\Node * A node entity matching $title. */ function drupalGetNodeByTitle($title, $reset = FALSE) { @@ -201,7 +201,7 @@ function drupalGetNodeByTitle($title, $reset = FALSE) { * The following defaults are provided: * - body: Random string using the default filter format: * @code - * $settings['body'][0] = array( + * $settings['body'][LANGUAGE_NOT_SPECIFIED][0] = array( * 'value' => $this->randomName(32), * 'format' => filter_default_format(), * ); @@ -214,7 +214,10 @@ function drupalGetNodeByTitle($title, $reset = FALSE) { * - status: NODE_PUBLISHED. * - sticky: NODE_NOT_STICKY. * - type: 'page'. - * - langcode: LANGUAGE_NOT_SPECIFIED. + * - langcode: LANGUAGE_NOT_SPECIFIED. (If a 'langcode' key is provided in + * the array, this language code will also be used for a randomly + * generated body field for that language, and the body for + * LANGUAGE_NOT_SPECIFIED will remain empty.) * - uid: The currently logged in user, or the user running test. * - revision: 1. (Backwards-compatible binary flag indicating whether a * new revision should be created; use 1 to specify a new revision.) @@ -225,7 +228,7 @@ function drupalGetNodeByTitle($title, $reset = FALSE) { protected function drupalCreateNode(array $settings = array()) { // Populate defaults array. $settings += array( - 'body' => array(array()), + 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array())), 'title' => $this->randomName(8), 'changed' => REQUEST_TIME, 'promote' => NODE_NOT_PROMOTED, @@ -262,10 +265,14 @@ protected function drupalCreateNode(array $settings = array()) { } // Merge body field value and format separately. - $settings['body'][0] += array( + $body = array( 'value' => $this->randomName(32), 'format' => filter_default_format(), ); + if (empty($settings['body'][$settings['langcode']])) { + $settings['body'][$settings['langcode']][0] = array(); + } + $settings['body'][$settings['langcode']][0] += $body; $node = entity_create('node', $settings); if (!empty($settings['revision'])) { diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index 66842a5..6510818 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -5,7 +5,7 @@ * Logs and displays content statistics for a site. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\entity\Plugin\Core\Entity\EntityDisplay; /** @@ -47,7 +47,7 @@ function statistics_permission() { /** * Implements hook_node_view(). */ -function statistics_node_view(EntityInterface $node, EntityDisplay $display, $view_mode) { +function statistics_node_view(Node $node, EntityDisplay $display, $view_mode) { if (!empty($node->nid) && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) { $node->content['#attached']['library'][] = array('statistics', 'drupal.statistics'); $settings = array('data' => array('nid' => $node->nid), 'url' => url(drupal_get_path('module', 'statistics') . '/statistics.php')); @@ -197,7 +197,7 @@ function _statistics_format_item($title, $path) { /** * Implements hook_node_predelete(). */ -function statistics_node_predelete(EntityInterface $node) { +function statistics_node_predelete(Node $node) { // clean up statistics table when node is deleted db_delete('node_counter') ->condition('nid', $node->nid) diff --git a/core/modules/system/config/system.fast_404.yml b/core/modules/system/config/system.fast_404.yml new file mode 100644 index 0000000..731c8bb --- /dev/null +++ b/core/modules/system/config/system.fast_404.yml @@ -0,0 +1,4 @@ +enabled: '1' +paths: '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i' +exclude_paths: '/\/(?:styles)\//' +html: '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

' diff --git a/core/modules/system/config/system.performance.yml b/core/modules/system/config/system.performance.yml index 0188032..80f349a 100644 --- a/core/modules/system/config/system.performance.yml +++ b/core/modules/system/config/system.performance.yml @@ -5,11 +5,6 @@ cache: css: preprocess: '0' gzip: '1' -fast_404: - enabled: '1' - paths: '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i' - exclude_paths: '/\/(?:styles|imagecache)\//' - html: '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

' js: preprocess: '0' gzip: '1' @@ -17,3 +12,4 @@ response: gzip: '0' stale_file_threshold: '2592000' theme_link: '1' + diff --git a/core/modules/system/image.gd.inc b/core/modules/system/image.gd.inc index 0d2f228..779117d 100644 --- a/core/modules/system/image.gd.inc +++ b/core/modules/system/image.gd.inc @@ -37,7 +37,7 @@ function image_gd_settings() { '#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'), '#min' => 0, '#max' => 100, - '#default_value' => variable_get('image_jpeg_quality', 75), + '#default_value' => config('image.settings')->get('jpeg_quality'), '#field_suffix' => t('%'), ); @@ -296,7 +296,8 @@ function image_gd_save(stdClass $image, $destination) { return FALSE; } if ($extension == 'jpeg') { - $success = $function($image->resource, $destination, variable_get('image_jpeg_quality', 75)); + $quality = config('image.settings')->get('jpeg_quality'); + $success = $function($image->resource, $destination, $quality); } else { // Always save PNG images with full transparency. diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php index 5e107e3..30cf24e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php @@ -134,9 +134,11 @@ function testRenderInlineFullPage() { $settings = array( 'type' => 'page', 'body' => array( - array( - 'value' => t('This tests the inline CSS!') . "", - 'format' => $php_format_id, + LANGUAGE_NOT_SPECIFIED => array( + array( + 'value' => t('This tests the inline CSS!') . "", + 'format' => $php_format_id, + ), ), ), 'promote' => 1, diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityBCDecoratorTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityBCDecoratorTest.php deleted file mode 100644 index 892fd18..0000000 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityBCDecoratorTest.php +++ /dev/null @@ -1,78 +0,0 @@ - 'Entity Backward Compatibility Decorator', - 'description' => 'Tests the Entity Backward Compatibility Decorator', - 'group' => 'Entity API', - ); - } - - public function setUp() { - parent::setUp(); - $this->installSchema('user', array('users_roles', 'users_data', 'role_permission')); - $this->installSchema('node', array('node', 'node_revision', 'node_type', 'node_access')); - $this->installSchema('comment', array('comment', 'node_comment_statistics')); - } - - /** - * Tests using the entity BC decorator with entity properties. - * - * @see \Drupal\Core\Entity\EntityBCDecorator - */ - public function testBCDecorator() { - // Test using comment subject via the BC decorator. - $this->createUser(); - $node = entity_create('node', array( - 'type' => 'page', - 'uid' => 1, - )); - $node->save(); - $comment = entity_create('comment', array( - 'nid' => $node->nid, - 'subject' => 'old-value', - )); - $comment->save(); - $bc_entity = $comment->getBCEntity(); - - // Test reading of a defined property. - $this->assertEqual($bc_entity->subject, 'old-value', 'Accessing entity property via BC decorator.'); - // Test writing of a defined property via the decorator. - $bc_entity->subject = 'new'; - $this->assertEqual($bc_entity->subject, 'new', 'Updated defined entity property via BC decorator.'); - $this->assertEqual($comment->subject->value, 'new', 'Updated defined entity property via BC decorator.'); - - // Test writing of a defined property. - $comment->subject->value = 'newer'; - $this->assertEqual($bc_entity->subject, 'newer', 'Updated defined entity property via default entity class.'); - $this->assertEqual($comment->subject->value, 'newer', 'Updated defined entity property via default entity class.'); - - // Test handling of an undefined property. - $this->assertFalse(isset($bc_entity->foo), 'Checking if isset() on undefnied property.'); - $bc_entity->foo = 'bar'; - $this->assertEqual($bc_entity->foo, 'bar', 'Accessing undefined entity property via BC decorator.'); - $this->assertEqual($comment->foo, 'bar', 'Accessing undefined entity property via default entity class.'); - $this->assertTrue(isset($bc_entity->foo), 'Checking if isset() on undefnied property.'); - } -} diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUUIDTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUUIDTest.php index 0168bb3..d7ca38d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUUIDTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUUIDTest.php @@ -99,12 +99,6 @@ protected function assertCRUD($entity_type) { $this->assertNotNull($entity->id()); $this->assertNotEqual($entity_duplicate->id(), $entity->id()); break; - case 'revision_id': - $this->assertNull($entity_duplicate->getRevisionId()); - $this->assertNotNull($entity->getRevisionId()); - $this->assertNotEqual($entity_duplicate->getRevisionId(), $entity->getRevisionId()); - $this->assertNotEqual($entity_duplicate->{$property}->getValue(), $entity->{$property}->getValue()); - break; default: $this->assertEqual($entity_duplicate->{$property}->getValue(), $entity->{$property}->getValue()); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/ContextPluginTest.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/ContextPluginTest.php index 882ae96..c22f222 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/ContextPluginTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/ContextPluginTest.php @@ -40,7 +40,7 @@ function testContext() { $manager = new MockBlockManager(); $plugin = $manager->createInstance('user_name'); // Create a node, add it as context, catch the exception. - $node = entity_create('node', array('title' => $name, 'type' => 'page')); + $node = entity_create('node', array('title' => $name)); // Try to get a valid context that has not been set. try { diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php index 7b8aa9a..c927f7e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php @@ -89,7 +89,7 @@ public function setUp() { 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockComplexContextBlock', 'context' => array( 'user' => array('class' => 'Drupal\user\Plugin\Core\Entity\User'), - 'node' => array('class' => 'Drupal\Core\Entity\EntityBCDecorator'), + 'node' => array('class' => 'Drupal\node\Plugin\Core\Entity\Node'), ), ), ); diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php index 1f0f2ee..3545553 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php @@ -102,7 +102,7 @@ function setUp() { 'title' => $this->xss_label, 'type' => 'article', 'promote' => NODE_PROMOTED, - 'field_tags' => array(array('tid' => $this->term->tid)), + 'field_tags' => array(LANGUAGE_NOT_SPECIFIED => array(array('tid' => $this->term->tid))), )); // Create a test comment on the test node. @@ -111,7 +111,7 @@ function setUp() { 'node_type' => $this->node->type, 'status' => COMMENT_PUBLISHED, 'subject' => $this->xss_label, - 'comment_body' => array($this->randomName()), + 'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())), )); comment_save($this->comment); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php index 471e2d8..30399d6 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php @@ -55,12 +55,6 @@ public function testVariableUpgrade() { 'response.gzip' => '1', 'js.preprocess' => '1', 'css.preprocess' => '1', - 'fast_404' => array( - 'enabled' => '1', - 'paths' => '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|aspi|pdf)$/i', - 'exclude_paths' => '/\/(?:styles|imagecache)\//', - 'html' => 'Page Not Found

Page Not Found

The requested URL "@path" was not found on this server.

', - ), ); $expected_config['system.rss'] = array( @@ -147,9 +141,9 @@ public function testVariableUpgrade() { $expected_config['book.settings'] = array( 'allowed_types' => array( - 'book', + 'book' => 'book', // Content type does not have to exist. - 'test', + 'test' => 'test', ), 'block' => array( 'navigation' => array( diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 08a9fd9..2d23527 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2003,10 +2003,10 @@ function system_update_8043() { * @ingroup config_upgrade */ function system_update_8044() { - update_variables_to_config('system.performance', array( - 'fast_404_html' => 'fast_404.html', - 'fast_404_paths' => 'fast_404.paths', - 'fast_404_paths_exclude' => 'fast_404.exclude_paths', + update_variables_to_config('system.fast_404', array( + '404_fast_html' => 'html', + '404_fast_paths' => 'paths', + '404_fast_paths_exclude' => 'exclude_paths', )); } @@ -2195,6 +2195,38 @@ function system_update_8051() { } /** + * Update variables to $settings. + */ +function system_update_8052() { + $upgrade = array( + 'proxy_server', + 'proxy_port', + 'proxy_username', + 'proxy_password', + 'proxy_user_agent', + 'proxy_exceptions', + 'reverse_proxy', + 'reverse_proxy_addresses', + 'reverse_proxy_header', + 'omit_vary_cookie', + ); + + foreach ($upgrade as $variable_name) { + $variable = update_variable_get($variable_name, ''); + if ($variable) { + $settings['settings'][$variable_name] = (object) array( + 'value' => $variable, + 'required' => TRUE, + ); + } + } + + if (!empty($settings)) { + drupal_rewrite_settings($settings); + } +} + +/** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000. */ diff --git a/core/modules/system/tests/modules/paramconverter_test/lib/Drupal/paramconverter_test/TestControllers.php b/core/modules/system/tests/modules/paramconverter_test/lib/Drupal/paramconverter_test/TestControllers.php index ca95200..ddb4833 100644 --- a/core/modules/system/tests/modules/paramconverter_test/lib/Drupal/paramconverter_test/TestControllers.php +++ b/core/modules/system/tests/modules/paramconverter_test/lib/Drupal/paramconverter_test/TestControllers.php @@ -7,7 +7,7 @@ namespace Drupal\paramconverter_test; -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; /** * Controller routine for testing the paramconverter. @@ -21,7 +21,7 @@ public function testUserNodeFoo($user, $node, $foo) { return $retval; } - public function testNodeSetParent(EntityInterface $node, EntityInterface $parent) { + public function testNodeSetParent(Node $node, Node $parent) { return "Setting '{$parent->title}' as parent of '{$node->title}'."; } } diff --git a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/MockBlockManager.php b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/MockBlockManager.php index 157e583..7e29259 100644 --- a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/MockBlockManager.php +++ b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/MockBlockManager.php @@ -91,7 +91,7 @@ public function __construct() { 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockComplexContextBlock', 'context' => array( 'user' => array('class' => 'Drupal\user\Plugin\Core\Entity\User'), - 'node' => array('class' => 'Drupal\Core\Entity\EntityBCDecorator'), + 'node' => array('class' => 'Drupal\node\Plugin\Core\Entity\Node'), ), )); diff --git a/core/modules/system/tests/upgrade/drupal-7.system.database.php b/core/modules/system/tests/upgrade/drupal-7.system.database.php index e8502cc..5bf6f29 100644 --- a/core/modules/system/tests/upgrade/drupal-7.system.database.php +++ b/core/modules/system/tests/upgrade/drupal-7.system.database.php @@ -123,18 +123,6 @@ 'name' => 'mail_system', 'value' => 'a:2:{s:14:"default-system";s:17:"DefaultMailSystem";s:7:"maillog";s:17:"MaillogMailSystem";}', )) - ->values(array( - 'name' => 'fast_404_paths', - 'value' => 's:74:"/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|aspi|pdf)$/i";', - )) - ->values(array( - 'name' => 'fast_404_excluded_paths', - 'value' => 's:27:"/\/(?:styles|imagecache)\//";', - )) - ->values(array( - 'name' => 'fast_404_html', - 'value' => 's:168:"Page Not Found

Page Not Found

The requested URL "@path" was not found on this server.

";', - )) ->execute(); db_update('variable') @@ -150,7 +138,7 @@ ->condition('name', 'filter_fallback_format') ->execute(); db_update('variable') - ->fields(array('value' => 'a:2:{i:0;s:4:"test";i:1;s:4:"book";}')) + ->fields(array('value' => 'a:2:{i:0;s:4:"book";i:1;s:4:"test";}')) ->condition('name', 'book_allowed_types') ->execute(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php index 3457126..1789d0e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php @@ -73,7 +73,7 @@ public function formElement(array $items, $delta, array $element, $langcode, arr public function massageFormValues(array $values, array $form, array &$form_state) { // Autocomplete widgets do not send their tids in the form, so we must detect // them here and process them independently. - $items = array(); + $terms = array(); $field = $this->field; // Collect candidate vocabularies. @@ -89,20 +89,19 @@ public function massageFormValues(array $values, array $form, array &$form_state // otherwise, create a new 'autocreate' term for insert/update. if ($possibilities = entity_load_multiple_by_properties('taxonomy_term', array('name' => trim($value), 'vid' => array_keys($vocabularies)))) { $term = array_pop($possibilities); - $item = array('tid' => $term->tid); } else { $vocabulary = reset($vocabularies); - $term = entity_create('taxonomy_term', array( + $term = array( + 'tid' => 'autocreate', 'vid' => $vocabulary->id(), 'name' => $value, - )); - $item = array('tid' => FALSE, 'entity' => $term); + ); } - $items[] = $item; + $terms[] = (array)$term; } - return $items; + return $terms; } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php index 5f98990..ec91070 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php @@ -54,8 +54,8 @@ function setUp() { $node = array(); $node['type'] = 'article'; - $node['field_views_testing_tags'][]['tid'] = $this->term1->tid; - $node['field_views_testing_tags'][]['tid'] = $this->term2->tid; + $node['field_views_testing_tags'][LANGUAGE_NOT_SPECIFIED][]['tid'] = $this->term1->tid; + $node['field_views_testing_tags'][LANGUAGE_NOT_SPECIFIED][]['tid'] = $this->term2->tid; $this->nodes[] = $this->drupalCreateNode($node); $this->nodes[] = $this->drupalCreateNode($node); } diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 43d2ac8..f894d6c 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -1067,7 +1067,10 @@ function taxonomy_field_validate(EntityInterface $entity = NULL, $field, $instan * Implements hook_field_is_empty(). */ function taxonomy_field_is_empty($item, $field) { - return !is_array($item) || (empty($item['tid']) && empty($item['entity'])); + if (!is_array($item) || (empty($item['tid']) && (string) $item['tid'] !== '0')) { + return TRUE; + } + return FALSE; } /** @@ -1096,8 +1099,9 @@ function taxonomy_field_formatter_info() { function taxonomy_field_formatter_view(EntityInterface $entity, $field, $instance, $langcode, $items, $display) { $element = array(); - // Terms whose tid is 'autocreate' do not exist yet and $item['entity'] is not - // set. Theme such terms as just their name. + // Terms whose tid is 'autocreate' do not exist + // yet and $item['taxonomy_term'] is not set. Theme such terms as + // just their name. switch ($display['type']) { case 'taxonomy_term_reference_link': @@ -1108,7 +1112,7 @@ function taxonomy_field_formatter_view(EntityInterface $entity, $field, $instanc ); } else { - $term = $item['entity']; + $term = $item['taxonomy_term']; $uri = $term->uri(); $element[$delta] = array( '#type' => 'link', @@ -1122,7 +1126,7 @@ function taxonomy_field_formatter_view(EntityInterface $entity, $field, $instanc case 'taxonomy_term_reference_plain': foreach ($items as $delta => $item) { - $name = ($item['tid'] != 'autocreate' ? $item['entity']->label() : $item['name']); + $name = ($item['tid'] != 'autocreate' ? $item['taxonomy_term']->label() : $item['name']); $element[$delta] = array( '#markup' => check_plain($name), ); @@ -1133,7 +1137,7 @@ function taxonomy_field_formatter_view(EntityInterface $entity, $field, $instanc foreach ($items as $delta => $item) { $entity->rss_elements[] = array( 'key' => 'category', - 'value' => $item['tid'] != 'autocreate' ? $item['entity']->label() : $item['name'], + 'value' => $item['tid'] != 'autocreate' ? $item['taxonomy_term']->label() : $item['name'], 'attributes' => array( 'domain' => $item['tid'] != 'autocreate' ? url('taxonomy/term/' . $item['tid'], array('absolute' => TRUE)) : '', ), @@ -1188,7 +1192,7 @@ function taxonomy_field_formatter_prepare_view($entity_type, $entities, $field, foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { // Force the array key to prevent duplicates. - if ($item['tid'] != 'autocreate' && $item['tid'] !== FALSE) { + if ($item['tid'] != 'autocreate') { $tids[$item['tid']] = $item['tid']; } } @@ -1204,7 +1208,7 @@ function taxonomy_field_formatter_prepare_view($entity_type, $entities, $field, // Check whether the taxonomy term field instance value could be loaded. if (isset($terms[$item['tid']])) { // Replace the instance value with the term data. - $items[$id][$delta]['entity'] = $terms[$item['tid']]; + $items[$id][$delta]['taxonomy_term'] = $terms[$item['tid']]; } // Terms to be created are not in $terms, but are still legitimate. elseif ($item['tid'] == 'autocreate') { @@ -1354,10 +1358,12 @@ function taxonomy_rdf_mapping() { */ function taxonomy_field_presave(EntityInterface $entity, $field, $instance, $langcode, &$items) { foreach ($items as $delta => $item) { - if (!$item['tid'] && isset($item['entity'])) { + if ($item['tid'] == 'autocreate') { unset($item['tid']); - taxonomy_term_save($item['entity']); - $items[$delta]['tid'] = $item['entity']->tid; + $term = entity_create('taxonomy_term', $item); + $term->langcode = $langcode; + taxonomy_term_save($term); + $items[$delta]['tid'] = $term->tid; } } } @@ -1365,7 +1371,7 @@ function taxonomy_field_presave(EntityInterface $entity, $field, $instance, $lan /** * Implements hook_node_insert(). */ -function taxonomy_node_insert(EntityInterface $node) { +function taxonomy_node_insert(Node $node) { // Add taxonomy index entries for the node. taxonomy_build_node_index($node); } @@ -1442,7 +1448,7 @@ function taxonomy_build_node_index($node) { /** * Implements hook_node_update(). */ -function taxonomy_node_update(EntityInterface $node) { +function taxonomy_node_update(Node $node) { // Always rebuild the node's taxonomy index entries on node save. taxonomy_delete_node_index($node); taxonomy_build_node_index($node); @@ -1451,7 +1457,7 @@ function taxonomy_node_update(EntityInterface $node) { /** * Implements hook_node_predelete(). */ -function taxonomy_node_predelete(EntityInterface $node) { +function taxonomy_node_predelete(Node $node) { // Clean up the {taxonomy_index} table when nodes are deleted. taxonomy_delete_node_index($node); } @@ -1459,10 +1465,10 @@ function taxonomy_node_predelete(EntityInterface $node) { /** * Deletes taxonomy index entries for a given node. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Plugin\Core\Entity\Node $node * The node entity. */ -function taxonomy_delete_node_index(EntityInterface $node) { +function taxonomy_delete_node_index(Node $node) { if (config('taxonomy.settings')->get('maintain_index_table')) { db_delete('taxonomy_index')->condition('nid', $node->nid)->execute(); } diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index 125b5da..30a0dbb 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -5,7 +5,7 @@ * Tracks recent content posted by a user or users. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_help(). @@ -193,7 +193,7 @@ function _tracker_user_access($account) { * * Adds new tracking information for this node since it's new. */ -function tracker_node_insert(EntityInterface $node, $arg = 0) { +function tracker_node_insert(Node $node, $arg = 0) { _tracker_add($node->nid, $node->uid, $node->changed); } @@ -202,7 +202,7 @@ function tracker_node_insert(EntityInterface $node, $arg = 0) { * * Adds tracking information for this node since it's been updated. */ -function tracker_node_update(EntityInterface $node, $arg = 0) { +function tracker_node_update(Node $node, $arg = 0) { _tracker_add($node->nid, $node->uid, $node->changed); } @@ -211,7 +211,7 @@ function tracker_node_update(EntityInterface $node, $arg = 0) { * * Deletes tracking information for a node. */ -function tracker_node_predelete(EntityInterface $node, $arg = 0) { +function tracker_node_predelete(Node $node, $arg = 0) { db_delete('tracker_node') ->condition('nid', $node->nid) ->execute(); diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc index a801ad7..853f50d 100644 --- a/core/modules/tracker/tracker.pages.inc +++ b/core/modules/tracker/tracker.pages.inc @@ -37,7 +37,7 @@ function tracker_page($account = NULL, $set_title = FALSE) { // This array acts as a placeholder for the data selected later // while keeping the correct order. - $tracker_data = $query + $nodes = $query ->addTag('node_access') ->addMetaData('base_table', 'tracker_node') ->fields('t', array('nid', 'changed')) @@ -48,14 +48,12 @@ function tracker_page($account = NULL, $set_title = FALSE) { ->fetchAllAssoc('nid'); $rows = array(); - if (!empty($tracker_data)) { - $nids = array_keys($tracker_data); - $nodes = entity_load_multiple('node', $nids); + if (!empty($nodes)) { // Now, get the data and put into the placeholder array. - $result = db_query('SELECT n.nid, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid WHERE n.nid IN (:nids)', array(':nids' => $nids), array('target' => 'slave'))->fetchAllKeyed(); - foreach ($result as $nid => $comment_count) { - $nodes[$nid]->last_activity = $tracker_data[$nid]->changed; - $nodes[$nid]->comment_count = $comment_count; + $result = db_query('SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid WHERE n.nid IN (:nids)', array(':nids' => array_keys($nodes)), array('target' => 'slave')); + foreach ($result as $node) { + $node->last_activity = $nodes[$node->nid]->changed; + $nodes[$node->nid] = $node; } // Display the data. diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php index df2c386..6e3dccf 100644 --- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php +++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php @@ -7,7 +7,7 @@ namespace Drupal\translation\Tests; -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\simpletest\WebTestBase; /** @@ -362,7 +362,7 @@ function createPage($title, $body, $langcode = NULL) { /** * Creates a translation for a basic page in the specified language. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * The basic page to create the translation for. * @param $title * The title of a basic page in the specified language. @@ -374,7 +374,7 @@ function createPage($title, $body, $langcode = NULL) { * @return * Translation object. */ - function createTranslation(EntityInterface $node, $title, $body, $langcode) { + function createTranslation(Node $node, $title, $body, $langcode) { $this->drupalGet('node/add/page', array('query' => array('translation' => $node->nid, 'target' => $langcode))); $field_langcode = LANGUAGE_NOT_SPECIFIED; diff --git a/core/modules/translation/tests/translation_test.module b/core/modules/translation/tests/translation_test.module index 3b7fe76..d5db14d 100644 --- a/core/modules/translation/tests/translation_test.module +++ b/core/modules/translation/tests/translation_test.module @@ -5,11 +5,11 @@ * Mock module for content translation tests. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_node_insert(). */ -function translation_test_node_insert(EntityInterface $node) { - $node->save(); +function translation_test_node_insert(Node $node) { + drupal_write_record('node', $node, 'nid'); } diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module index 41d8e83..a864120 100644 --- a/core/modules/translation/translation.module +++ b/core/modules/translation/translation.module @@ -19,7 +19,7 @@ * date (0) or needs to be updated (1). */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\entity\Plugin\Core\Entity\EntityDisplay; /** @@ -248,7 +248,7 @@ function translation_form_node_form_alter(&$form, &$form_state) { * translation set. If no language provider is enabled, "fall back" to simple * links built through the result of translation_node_get_translations(). */ -function translation_node_view(EntityInterface $node, EntityDisplay $display, $view_mode) { +function translation_node_view(Node $node, EntityDisplay $display, $view_mode) { // If the site has no translations or is not multilingual we have no content // translation links to display. if (isset($node->tnid) && language_multilingual() && $translations = translation_node_get_translations($node->tnid)) { @@ -302,7 +302,7 @@ function translation_node_view(EntityInterface $node, EntityDisplay $display, $v /** * Implements hook_node_prepare(). */ -function translation_node_prepare(EntityInterface $node) { +function translation_node_prepare(Node $node) { // Only act if we are dealing with a content type supporting translations. if (translation_supported_type($node->type) && // And it's a new node. @@ -344,7 +344,7 @@ function translation_node_prepare(EntityInterface $node) { /** * Implements hook_node_insert(). */ -function translation_node_insert(EntityInterface $node) { +function translation_node_insert(Node $node) { // Only act if we are dealing with a content type supporting translations. if (translation_supported_type($node->type)) { if (!empty($node->translation_source)) { @@ -379,7 +379,7 @@ function translation_node_insert(EntityInterface $node) { /** * Implements hook_node_update(). */ -function translation_node_update(EntityInterface $node) { +function translation_node_update(Node $node) { // Only act if we are dealing with a content type supporting translations. if (translation_supported_type($node->type)) { if (isset($node->translation) && $node->translation && !empty($node->langcode) && $node->tnid) { @@ -408,7 +408,7 @@ function translation_node_update(EntityInterface $node) { * * Ensures that duplicate translations can't be created for the same source. */ -function translation_node_validate(EntityInterface $node, $form, &$form_state) { +function translation_node_validate(Node $node, $form, &$form_state) { // Only act on translatable nodes with a tnid or translation_source. $form_node = $form_state['controller']->getEntity($form_state); if (translation_supported_type($node->type) && (!empty($node->tnid) || !empty($form_node->translation_source->nid))) { @@ -423,7 +423,7 @@ function translation_node_validate(EntityInterface $node, $form, &$form_state) { /** * Implements hook_node_predelete(). */ -function translation_node_predelete(EntityInterface $node) { +function translation_node_predelete(Node $node) { // Only act if we are dealing with a content type supporting translations. if (translation_supported_type($node->type)) { translation_remove_from_set($node); diff --git a/core/modules/translation/translation.pages.inc b/core/modules/translation/translation.pages.inc index 5412d2f..181b6c8 100644 --- a/core/modules/translation/translation.pages.inc +++ b/core/modules/translation/translation.pages.inc @@ -6,12 +6,12 @@ */ use Drupal\Component\Utility\NestedArray; -use Drupal\Core\Entity\EntityInterface; +use Drupal\node\Plugin\Core\Entity\Node; /** * Page callback: Displays a list of a node's translations. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param Drupal\node\Node $node * A node entity. * * @return @@ -19,7 +19,7 @@ * * @see translation_menu() */ -function translation_node_overview(EntityInterface $node) { +function translation_node_overview(Node $node) { include_once DRUPAL_ROOT . '/core/includes/language.inc'; if ($node->tnid) { diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php index 16eb88b..3a9e15b 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php +++ b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php @@ -66,7 +66,7 @@ protected function assertBasicTranslation() { $base_path = $this->controller->getBasePath($entity); $path = $langcode . '/' . $base_path . '/translations/add/' . $default_langcode . '/' . $langcode; - $this->drupalPost($path, $this->getEditValues($values, $langcode), $this->getFormSubmitAction($entity)); + $this->drupalPost($path, $this->getEditValues($values, $langcode), $this->getFormSubmitAction()); if ($this->testLanguageSelector) { $this->assertNoFieldByXPath('//select[@id="edit-langcode"]', NULL, 'Language selector correclty disabled on translations.'); } @@ -83,7 +83,7 @@ protected function assertBasicTranslation() { // Add another translation and mark the other ones as outdated. $values[$langcode] = $this->getNewEntityValues($langcode); $edit = $this->getEditValues($values, $langcode) + array('translation_entity[retranslate]' => TRUE); - $this->drupalPost($path, $edit, $this->getFormSubmitAction($entity)); + $this->drupalPost($path, $edit, $this->getFormSubmitAction()); $entity = entity_load($this->entityType, $this->entityId, TRUE); // Check that the entered values have been correctly stored. @@ -108,7 +108,7 @@ protected function assertOutdatedStatus() { // Mark translations as outdated. $edit = array('translation_entity[retranslate]' => TRUE); - $this->drupalPost($langcode . '/' . $this->controller->getEditPath($entity), $edit, $this->getFormSubmitAction($entity)); + $this->drupalPost($langcode . '/' . $this->controller->getEditPath($entity), $edit, $this->getFormSubmitAction()); $entity = entity_load($this->entityType, $this->entityId, TRUE); // Check that every translation has the correct "outdated" status. @@ -122,7 +122,7 @@ protected function assertOutdatedStatus() { else { $this->assertFieldByXPath('//input[@name="translation_entity[outdated]"]', TRUE, 'The translate flag is checked by default.'); $edit = array('translation_entity[outdated]' => FALSE); - $this->drupalPost($path, $edit, $this->getFormSubmitAction($entity)); + $this->drupalPost($path, $edit, $this->getFormSubmitAction()); $this->drupalGet($path); $this->assertFieldByXPath('//input[@name="translation_entity[retranslate]"]', FALSE, 'The retranslate flag is now shown.'); $entity = entity_load($this->entityType, $this->entityId, TRUE); @@ -142,7 +142,7 @@ protected function assertPublishedStatus() { foreach ($this->langcodes as $index => $langcode) { if ($index > 0) { $edit = array('translation_entity[status]' => FALSE); - $this->drupalPost($langcode . '/' . $path, $edit, $this->getFormSubmitAction($entity)); + $this->drupalPost($langcode . '/' . $path, $edit, $this->getFormSubmitAction()); $entity = entity_load($this->entityType, $this->entityId, TRUE); $this->assertFalse($entity->translation[$langcode]['status'], 'The translation has been correctly unpublished.'); } @@ -173,7 +173,7 @@ protected function assertAuthoringInfo() { 'translation_entity[created]' => format_date($values[$langcode]['created'], 'custom', 'Y-m-d H:i:s O'), ); $prefix = $index > 0 ? $langcode . '/' : ''; - $this->drupalPost($prefix . $path, $edit, $this->getFormSubmitAction($entity)); + $this->drupalPost($prefix . $path, $edit, $this->getFormSubmitAction()); } $entity = entity_load($this->entityType, $this->entityId, TRUE); @@ -189,7 +189,7 @@ protected function assertAuthoringInfo() { 'translation_entity[name]' => $this->randomName(12), 'translation_entity[created]' => $this->randomName(), ); - $this->drupalPost($path, $edit, $this->getFormSubmitAction($entity)); + $this->drupalPost($path, $edit, $this->getFormSubmitAction()); $this->assertTrue($this->xpath('//div[@id="messages"]//div[contains(@class, "error")]//ul'), 'Invalid values generate a list of form errors.'); $this->assertEqual($entity->translation[$langcode]['uid'] == $values[$langcode]['uid'], 'Translation author correctly kept.'); $this->assertEqual($entity->translation[$langcode]['created'] == $values[$langcode]['created'], 'Translation date correctly kept.'); @@ -235,14 +235,8 @@ protected function getEditValues($values, $langcode, $new = FALSE) { /** * Returns the form action value to be used to submit the entity form. - * - * @param \Drupal\Core\Entity\EntityInterface $entity - * The entity being tested. - * - * @return string - * Name of the button to hit. */ - protected function getFormSubmitAction(EntityInterface $entity) { + protected function getFormSubmitAction() { return t('Save'); } @@ -258,8 +252,6 @@ protected function getFormSubmitAction(EntityInterface $entity) { * The translation object to act on. */ protected function getTranslation(EntityInterface $entity, $langcode) { - // @todo remove once EntityBCDecorator is gone. - $entity = $entity->getOriginalEntity(); return $entity instanceof EntityNG ? $entity->getTranslation($langcode, FALSE) : $entity; } @@ -278,8 +270,7 @@ protected function getTranslation(EntityInterface $entity, $langcode) { */ protected function getValue(ComplexDataInterface $translation, $property, $langcode) { $key = $property == 'user_id' ? 'target_id' : 'value'; - // @todo remove EntityBCDecorator condition once EntityBCDecorator is gone. - if (($translation instanceof EntityInterface) && !($translation instanceof EntityNG) && !($translation instanceof EntityBCDecorator)) { + if (($translation instanceof EntityInterface) && !($translation instanceof EntityNG)) { return is_array($translation->$property) ? $translation->{$property}[$langcode][0][$key] : $translation->$property; } else { diff --git a/core/modules/translation_entity/translation_entity.module b/core/modules/translation_entity/translation_entity.module index bb78d1e..b99fdcf 100644 --- a/core/modules/translation_entity/translation_entity.module +++ b/core/modules/translation_entity/translation_entity.module @@ -614,7 +614,6 @@ function translation_entity_form_alter(array &$form, array &$form_state) { // Handle fields shared between translations when there is at least one // translation available or a new one is being created. if (!$entity->isNew() && (!isset($translations[$form_langcode]) || count($translations) > 1)) { - $entity = $entity->getOriginalEntity(); if ($entity instanceof EntityNG) { foreach ($entity->getPropertyDefinitions() as $property_name => $definition) { if (isset($form[$property_name])) { diff --git a/core/modules/translation_entity/translation_entity.pages.inc b/core/modules/translation_entity/translation_entity.pages.inc index 65035d8..f0c3027 100644 --- a/core/modules/translation_entity/translation_entity.pages.inc +++ b/core/modules/translation_entity/translation_entity.pages.inc @@ -238,7 +238,6 @@ function translation_entity_edit_page(EntityInterface $entity, Language $languag function translation_entity_prepare_translation(EntityInterface $entity, Language $source, Language $target) { // @todo Unify field and property handling. $instances = field_info_instances($entity->entityType(), $entity->bundle()); - $entity = $entity->getOriginalEntity(); if ($entity instanceof EntityNG) { $source_translation = $entity->getTranslation($source->langcode); $target_translation = $entity->getTranslation($target->langcode); diff --git a/core/modules/update/update.module b/core/modules/update/update.module index 6f0f1e3..13e1771 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -604,7 +604,7 @@ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $lan break; } if (!empty($langcode)) { - $language = language_load($langcode); + $language = language_load(langcode); } else { $language = NULL; diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php index c4f90b8..7e8fc93 100644 --- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php @@ -44,9 +44,6 @@ public static function getInfo() { protected function setUp() { parent::setUp(); - // Create Basic page node type. - $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); - $this->vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => $this->randomName(), 'description' => $this->randomName(), @@ -96,13 +93,13 @@ protected function setUp() { $term = $this->createTerm($this->vocabulary); $values = array('created' => $time, 'type' => 'page'); - $values[$this->field_name][]['tid'] = $term->tid; + $values[$this->field_name][LANGUAGE_NOT_SPECIFIED][]['tid'] = $term->tid; // Make every other node promoted. if ($i % 2) { $values['promote'] = TRUE; } - $values['body'][]['value'] = l('Node ' . 1, 'node/' . 1); + $values['body'][LANGUAGE_NOT_SPECIFIED][]['value'] = l('Node ' . 1, 'node/' . 1); $node = $this->drupalCreateNode($values); diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index 319db29..b2fbc90 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -587,22 +587,19 @@ * * The options below return a simple, fast 404 page for URLs matching a * specific pattern: - * - $conf['system.performance]['fast_404']['exclude_paths']: A regular - * expression to match paths to exclude, such as images generated by image - * styles, or dynamically-resized images. If you need to add more paths, you - * can add '|path' to the expression. - * - $conf['system.performance]['fast_404']['paths']: A regular expression to - * match paths that should return a simple 404 page, rather than the fully - * themed 404 page. If you don't have any aliases ending in htm or html you - * can add '|s?html?' to the expression. - * - $conf['system.performance]['fast_404']['html']: The html to return for - * simple 404 pages. + * - $conf['system.fast_404']['exclude_paths']: A regular expression to match paths to exclude, + * such as images generated by image styles, or dynamically-resized images. + * If you need to add more paths, you can add '|path' to the expression. + * - $conf['system.fast_404']['paths']: A regular expression to match paths that should return a + * simple 404 page, rather than the fully themed 404 page. If you don't have + * any aliases ending in htm or html you can add '|s?html?' to the expression. + * - $conf['system.fast_404']['html']: The html to return for simple 404 pages. * * Remove the leading hash signs if you would like to alter this functionality. */ -#$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'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; +#$conf['system.fast_404']['exclude_paths'] = '/\/(?:styles)\//'; +#$conf['system.fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; +#$conf['system.fast_404']['html'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; /** * Load local development override configuration, if available.