Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Model/Table/MetaTemplatesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,17 @@ public function getStatusForMetaTemplate(array $template, \App\Model\Entity\Meta
$updateStatus['new'] = false;
$updateStatus['automatically-updateable'] = false;
$updateStatus['conflicts'] = [];
/*
Removability depends on whether the template holds any values, not on how
its version compares to the one on disk. Computed up front so it survives
the early returns below: previously a template with no meta-fields at all
could not be deleted whenever the stored and on-disk versions matched,
which is the ordinary state of an unmodified template.
*/
$updateStatus['meta_field_amount'] = $this->MetaTemplateFields->MetaFields->find()
->where(['meta_template_id' => $metaTemplate->id])
->count();
$updateStatus['can-be-removed'] = empty($updateStatus['meta_field_amount']) && empty($updateStatus['to-existing']);
if (empty($template)) {
$updateStatus['up-to-date'] = false;
$updateStatus['automatically-updateable'] = false;
Expand Down Expand Up @@ -1353,8 +1364,6 @@ public function getStatusForMetaTemplate(array $template, \App\Model\Entity\Meta
} else {
$updateStatus['automatically-updateable'] = true;
}
$updateStatus['meta_field_amount'] = $this->MetaTemplateFields->MetaFields->find()->where(['meta_template_id' => $metaTemplate->id])->count();
$updateStatus['can-be-removed'] = empty($updateStatus['meta_field_amount']) && empty($updateStatus['to-existing']);
return $updateStatus;
}

Expand Down
Loading