diff --git a/core/modules/file/src/Element/ManagedFile.php b/core/modules/file/src/Element/ManagedFile.php index c1e80c3..a42c37c 100644 --- a/core/modules/file/src/Element/ManagedFile.php +++ b/core/modules/file/src/Element/ManagedFile.php @@ -406,6 +406,10 @@ public static function validateManagedFile(&$element, FormStateInterface $form_s $fids = $element['fids']['#value']; foreach ($fids as $fid) { if ($file = File::load($fid)) { + // Issue @link https://www.drupal.org/node/2896480 @endlink disabled + // unused, but permanent, files from being garbage collected. We + // need to check the status here to see if we should check the + // reference count. if ($file->isPermanent() && \Drupal::config('file.settings')->get('make_unused_managed_files_temporary')) { $references = static::fileUsage()->listUsage($file); if (empty($references)) { diff --git a/core/modules/file/src/Tests/FileManagedFileElementTest.php b/core/modules/file/src/Tests/FileManagedFileElementTest.php index 4851697..1ff00b9 100644 --- a/core/modules/file/src/Tests/FileManagedFileElementTest.php +++ b/core/modules/file/src/Tests/FileManagedFileElementTest.php @@ -207,7 +207,7 @@ public function testUnusedPermanentFileValidation() { // By default, unused files are no longer marked temporary, and it must be // allowed to reference an unused file. $this->drupalGet('file/test/1/0/1/' . $file->id()); - $this->drupalPostForm(NULL, [], t('Save')); + $this->drupalPostForm(NULL, [], 'Save'); $this->assertNoText('The file used in the Managed file & butter field may not be referenced.'); $this->assertText('The file ids are ' . $file->id()); @@ -217,7 +217,7 @@ public function testUnusedPermanentFileValidation() { ->set('make_unused_managed_files_temporary', TRUE) ->save(); $this->drupalGet('file/test/1/0/1/' . $file->id()); - $this->drupalPostForm(NULL, [], t('Save')); + $this->drupalPostForm(NULL, [], 'Save'); $this->assertText('The file used in the Managed file & butter field may not be referenced.'); $this->assertNoText('The file ids are ' . $file->id()); @@ -226,7 +226,7 @@ public function testUnusedPermanentFileValidation() { $file->save(); $this->drupalGet('file/test/1/0/1/' . $file->id()); - $this->drupalPostForm(NULL, [], t('Save')); + $this->drupalPostForm(NULL, [], 'Save'); $this->assertNoText('The file used in the Managed file & butter field may not be referenced.'); $this->assertText('The file ids are ' . $file->id()); @@ -240,7 +240,7 @@ public function testUnusedPermanentFileValidation() { $file_usage->add($file, 'file', 'file', $file->id()); $this->drupalGet('file/test/1/0/1/' . $file->id()); - $this->drupalPostForm(NULL, [], t('Save')); + $this->drupalPostForm(NULL, [], 'Save'); $this->assertNoText('The file used in the Managed file & butter field may not be referenced.'); $this->assertText('The file ids are ' . $file->id()); }