diff --git a/core/lib/Drupal/Core/Field/FieldItemInterface.php b/core/lib/Drupal/Core/Field/FieldItemInterface.php index 14cf9e9..a257dd0 100644 --- a/core/lib/Drupal/Core/Field/FieldItemInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemInterface.php @@ -98,7 +98,7 @@ public function getEntity(); /** * Gets the langcode of the field values held in the object. * - * @return $langcode + * @return string * The langcode. */ public function getLangcode(); diff --git a/core/lib/Drupal/Core/Field/FieldItemListInterface.php b/core/lib/Drupal/Core/Field/FieldItemListInterface.php index e8bba02..2266c9c 100644 --- a/core/lib/Drupal/Core/Field/FieldItemListInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemListInterface.php @@ -44,7 +44,7 @@ public function setLangcode($langcode); /** * Gets the langcode of the field values held in the object. * - * @return $langcode + * @return string * The langcode. */ public function getLangcode(); diff --git a/core/modules/file/src/Entity/File.php b/core/modules/file/src/Entity/File.php index 7c302f2..e106a12 100644 --- a/core/modules/file/src/Entity/File.php +++ b/core/modules/file/src/Entity/File.php @@ -188,7 +188,11 @@ public static function preCreate(EntityStorageInterface $storage, array &$values public function preSave(EntityStorageInterface $storage) { parent::preSave($storage); - $this->setSize(filesize($this->getFileUri())); + // the file itself might not exist or be available right now. + $uri = $this->getfileuri(); + if ($size = @filesize($uri)) { + $this->setsize($size); + } } /** diff --git a/core/modules/file/src/Tests/FileManagedFileElementTest.php b/core/modules/file/src/Tests/FileManagedFileElementTest.php index f5d5be3..07102a0 100644 --- a/core/modules/file/src/Tests/FileManagedFileElementTest.php +++ b/core/modules/file/src/Tests/FileManagedFileElementTest.php @@ -171,4 +171,27 @@ public function testManagedFileRemoved() { $this->assertRaw('The file referenced by the Managed file & butter field does not exist.'); } + /** + * Ensure a file entity can be saved when the file does not exist on disk. + */ + public function testFileRemovedFromDisk() { + $this->drupalGet('file/test/1/0/1'); + $test_file = $this->getTestFile('text'); + $file_field_name = 'files[nested_file][]'; + + $edit = [$file_field_name => drupal_realpath($test_file->getFileUri())]; + $this->drupalPostForm(NULL, $edit, t('Upload')); + $this->drupalPostForm(NULL, array(), t('Save')); + + $fid = $this->getLastFileId(); + /** @var $file \Drupal\file\FileInterface */ + $file = $this->container->get('entity_type.manager')->getStorage('file')->load($fid); + $file->setPermanent(); + $file->save(); + $this->assertTrue(file_unmanaged_delete($file->getFileUri())); + $file->save(); + $this->assertTrue($file->isPermanent()); + $file->delete(); + } + } diff --git a/core/modules/language/src/ContentLanguageSettingsInterface.php b/core/modules/language/src/ContentLanguageSettingsInterface.php index 3bb3d5d..7e1211d 100644 --- a/core/modules/language/src/ContentLanguageSettingsInterface.php +++ b/core/modules/language/src/ContentLanguageSettingsInterface.php @@ -39,7 +39,7 @@ public function setTargetBundle($target_bundle); * @param string $default_langcode * The default language code. * - * @return $this; + * @return $this */ public function setDefaultLangcode($default_langcode); diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index d4cc8c0..b0f90ed 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -2629,7 +2629,7 @@ protected function assertNoResponse($code, $message = '', $group = 'Browser') { * @param $override_server_vars * An array of server variables to override. * - * @return $request + * @return \Symfony\Component\HttpFoundation\Request * The mocked request object. */ protected function prepareRequestForGenerator($clean_urls = TRUE, $override_server_vars = array()) { diff --git a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php index 4cc49d2..d4e1b23 100644 --- a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php +++ b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php @@ -160,7 +160,7 @@ public function getLimit() { * @param $where * 'where' or 'having'. * - * @return $group + * @return * The group ID generated. */ public function setWhereGroup($type = 'AND', $group = NULL, $where = 'where') { diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php index c860d32..cfe593c 100644 --- a/core/modules/views/src/Plugin/views/query/Sql.php +++ b/core/modules/views/src/Plugin/views/query/Sql.php @@ -373,7 +373,7 @@ public function addRelationship($alias, JoinPluginBase $join, $base, $link_point * @param $alias * A specific alias to use, rather than the default alias. * - * @return $alias + * @return string * The alias of the table; this alias can be used to access information * about the table and should always be used to refer to the table when * adding parts to the query. Or FALSE if the table was not able to be @@ -412,7 +412,7 @@ public function addTable($table, $relationship = NULL, JoinPluginBase $join = NU * @param $alias * A specific alias to use, rather than the default alias. * - * @return $alias + * @return string * The alias of the table; this alias can be used to access information * about the table and should always be used to refer to the table when * adding parts to the query. Or FALSE if the table was not able to be @@ -759,7 +759,7 @@ public function getTableInfo($table) { * - aggregate: Set to TRUE to indicate that this value should be * aggregated in a GROUP BY. * - * @return $name + * @return string * The name that this field can be referred to as. Usually this is the alias. */ public function addField($table, $field, $alias = '', $params = array()) { diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index b2629f7..dae5b7a 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -45,7 +45,6 @@ -