From 22fe5bf9ef2dbe05fd8d6889810ae367a333fbef Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Wed, 16 Oct 2019 09:02:59 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#992 --- wire/modules/Fieldtype/FieldtypeFile.module | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wire/modules/Fieldtype/FieldtypeFile.module b/wire/modules/Fieldtype/FieldtypeFile.module index e303ba9d..cd6b6adc 100644 --- a/wire/modules/Fieldtype/FieldtypeFile.module +++ b/wire/modules/Fieldtype/FieldtypeFile.module @@ -976,7 +976,9 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule { // pagefiles is a default/fallback value from another page and should not be deleted } else if($pagefiles instanceof Pagefiles) { - $pagefiles->deleteAll(); + // $pagefiles->removeAll() not used here because it queues delete to $page->save(), + // which does not occur when a field is removed from a template + foreach($pagefiles as $pagefile) $pagefile->unlink(); } else if($pagefiles instanceof Pagefile) { $pagefiles->unlink();