diff --git a/src/Extensions/FileArchiveExtension.php b/src/Extensions/FileArchiveExtension.php index 6f85a31f..69bff841 100644 --- a/src/Extensions/FileArchiveExtension.php +++ b/src/Extensions/FileArchiveExtension.php @@ -73,10 +73,14 @@ public function getArchiveField() * The files archive is only useful if archived assets are stored * so this checks if this option is enabled * + * This should really only check File.keep_archived_assets, though it was originally + * only checking AssetControlExtension.keep_archived_assets, so keeping that for BC + * * @return boolean */ public function isArchiveFieldEnabled() { - return Config::inst()->get(AssetControlExtension::class, 'keep_archived_assets'); + return Config::inst()->get(AssetControlExtension::class, 'keep_archived_assets') + || Config::inst()->get(File::class, 'keep_archived_assets'); } } diff --git a/tests/Extensions/FileArchiveExtensionTest.php b/tests/Extensions/FileArchiveExtensionTest.php new file mode 100644 index 00000000..02004895 --- /dev/null +++ b/tests/Extensions/FileArchiveExtensionTest.php @@ -0,0 +1,51 @@ +set(AssetControlExtension::class, 'keep_archived_assets', $assetControlExtension); + Config::modify()->set(File::class, 'keep_archived_assets', $file); + $actual = File::singleton()->isArchiveFieldEnabled(); + $this->assertSame($expected, $actual); + } + + public function provideIsArchiveFieldEnabled(): array + { + return [ + [ + 'assetControlExtension' => false, + 'file' => false, + 'expected' => false, + ], + [ + 'assetControlExtension' => true, + 'file' => false, + 'expected' => true, + ], + [ + 'assetControlExtension' => false, + 'file' => true, + 'expected' => true, + ], + [ + 'assetControlExtension' => true, + 'file' => true, + 'expected' => true, + ], + ]; + } +}