Resolve #3035352 "Deprecate filegetfilereferences"
Closes #3035352
Merge request reports
Activity
22 'user', 23 ]; 24 25 /** 26 * {@inheritdoc} 27 */ 28 protected function setUp(): void { 29 parent::setUp(); 30 $this->installSchema('file', ['file_usage']); 31 $this->installEntitySchema('file'); 32 } 33 34 /** 35 * Test the file_get_file_references() deprecation. 36 */ 37 public function testFileGetFileReferencesDeprecation() { changed this line in version 4 of the diff
81 * (optional) A constant that specifies which references to count. Use 82 * EntityStorageInterface::FIELD_LOAD_REVISION (the default) to retrieve all 83 * references within all revisions or 84 * EntityStorageInterface::FIELD_LOAD_CURRENT to retrieve references only in 85 * the current revisions of all entities that have references to this file. 86 * @param string $field_type 87 * (optional) The name of a field type. If given, limits the reference check 88 * to fields of the given type. If both $field and $field_type are given but 89 * $field is not the same type as $field_type, an empty array will be 90 * returned. Defaults to 'file'. 91 * 92 * @return array 93 * A multidimensional array. The keys are field_name, entity_type, 94 * entity_id and the value is an entity referencing this file. 95 */ 96 public function getReferences(FileInterface $file, FieldDefinitionInterface $field = NULL, $age = EntityStorageInterface::FIELD_LOAD_REVISION, $field_type = 'file'); changed this line in version 4 of the diff
77 * @param \Drupal\Core\Field\FieldDefinitionInterface|null $field 78 * (optional) A field definition to be used for this check. If given, limits 79 * the reference check to the given field. Defaults to NULL. 80 * @param string $age 81 * (optional) A constant that specifies which references to count. Use 82 * EntityStorageInterface::FIELD_LOAD_REVISION (the default) to retrieve all 83 * references within all revisions or 84 * EntityStorageInterface::FIELD_LOAD_CURRENT to retrieve references only in 85 * the current revisions of all entities that have references to this file. 86 * @param string $field_type 87 * (optional) The name of a field type. If given, limits the reference check 88 * to fields of the given type. If both $field and $field_type are given but 89 * $field is not the same type as $field_type, an empty array will be 90 * returned. Defaults to 'file'. 91 * 92 * @return array changed this line in version 7 of the diff
26 * 27 * @var \Drupal\Core\Entity\EntityTypeManagerInterface 28 */ 29 protected $entityTypeManager; 30 31 /** 32 * The entity field manager service. 33 * 34 * @var \Drupal\Core\Entity\EntityFieldManagerInterface 35 */ 36 protected $entityFieldManager; 37 38 /** 39 * Memory cached references to a file. 40 * 41 * @var array 33 * 34 * @var \Drupal\Core\Entity\EntityFieldManagerInterface 35 */ 36 protected $entityFieldManager; 37 38 /** 39 * Memory cached references to a file. 40 * 41 * @var array 42 */ 43 protected $references = []; 44 45 /** 46 * Memory cached field columns. 47 * 48 * @var array changed this line in version 4 of the diff
33 33 * @param \Drupal\Core\Database\Connection $connection 34 34 * The database connection which will be used to store the file usage 35 35 * information. 36 36 * @param string $table 37 37 * (optional) The table to store file usage info. Defaults to 'file_usage'. 38 * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory 39 * The config factory service. 40 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager 41 * The entity type manager service. 42 * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager 43 * The entity field manager service. 38 44 */ 39 public function __construct(ConfigFactoryInterface $config_factory, Connection $connection, $table = 'file_usage') { 40 parent::__construct($config_factory); 45 public function __construct(Connection $connection, $table = 'file_usage', ConfigFactoryInterface $config_factory = NULL, EntityTypeManagerInterface $entity_type_manager = NULL, EntityFieldManagerInterface $entity_field_manager = NULL) { 46 parent::__construct($config_factory, $entity_type_manager, $entity_field_manager); 185 185 } 186 186 187 187 /** 188 * Determine whether a field references files stored in {file_managed}. 188 * Determines whether a field references files stored in {file_managed}. changed this line in version 5 of the diff
185 185 } 186 186 187 187 /** 188 * Determine whether a field references files stored in {file_managed}. 188 * Determines whether a field references files stored in {file_managed}. 189 189 * 190 190 * @param \Drupal\Core\Field\FieldDefinitionInterface $field 191 191 * A field definition. 192 192 * 193 193 * @return bool 194 * The field column if the field references {file_managed}.fid, typically 195 * fid, FALSE if it does not. 194 * The field column if the field references {file_managed}.fid, typically fid, 195 * FALSE if it does not. changed this line in version 5 of the diff
1679 1682 * @param \Drupal\file\FileInterface $file 1680 1683 * A file entity. 1681 1684 * @param \Drupal\Core\Field\FieldDefinitionInterface|null $field 1682 * (optional) A field definition to be used for this check. If given, 1683 * limits the reference check to the given field. Defaults to NULL. 1684 * @param int $age 1685 * (optional) A field definition to be used for this check. If given, limits 1686 * the reference check to the given field. Defaults to NULL. 1687 * @param string $age changing the comment here is out of scope.
Changing
$age
from typeint
tostring
while correct I don't think needs to be done in this issue.Seeing this unrelated changes it makes me wonder if the new doc comment for
\Drupal\file\FileUsage\FileUsageInterface::getReferences() has been copied back to
file_get_file_references()` to make this identical. While it would be nice to have them the same it brings in more changes than we need here.changed this line in version 5 of the diff
1694 1697 * returned. Defaults to 'file'. 1695 1698 * 1696 1699 * @return array 1697 * A multidimensional array. The keys are field_name, entity_type, 1698 * entity_id and the value is an entity referencing this file. 1700 * A multidimensional array. The keys are field_name, entity_type, entity_id 1701 * and the value is an entity referencing this file. changed this line in version 5 of the diff
1 1 services: 2 2 file.usage: 3 3 class: Drupal\file\FileUsage\DatabaseFileUsageBackend 4 arguments: ['@config.factory', '@database', 'file_usage'] 4 arguments: ['@database', 'file_usage', '@config.factory', '@entity_type.manager', '@entity_field.manager'] changed this line in version 5 of the diff
55 103 } 56 104 } 57 105 106 /** 107 * {@inheritdoc} 108 */ 109 public function getReferences(FileInterface $file, FieldDefinitionInterface $field = NULL, $age = EntityStorageInterface::FIELD_LOAD_REVISION, $field_type = 'file') { changed this line in version 6 of the diff