fix: [meta-templates] empty template can't be deleted at equal ver - #238
Open
DocArmoryTech wants to merge 1 commit into
Open
fix: [meta-templates] empty template can't be deleted at equal ver#238DocArmoryTech wants to merge 1 commit into
DocArmoryTech wants to merge 1 commit into
Conversation
getStatusForMetaTemplate() computed `meta_field_amount` and
`can-be-removed` at the very end of the method, after two early returns.
One of those fires whenever the stored version is not older than the one on
disk:
if (intval($metaTemplate->version) >= intval($template['version'])) {
$updateStatus['up-to-date'] = true;
$updateStatus['conflicts'][] = __('Could not update the template. ...');
return $updateStatus; // can-be-removed never set
}
MetaTemplatesController::delete() then rejects the request:
if (empty($templateStatus['can-be-removed'])) {
throw new MethodNotAllowedException(__('This meta-template cannot be removed'));
}
So a template holding no meta-fields at all could not be deleted whenever
the stored and on-disk versions matched -- which is the ordinary state of
any template nobody has edited. The error message gives no hint that the
version comparison is responsible.
Removability depends on whether values exist, not on version, so the
computation is moved above the early returns. The `empty($template)` branch
still forces false, as before.
Practical effect: template authoring regains a reset. Previously
createNewTemplate refused an existing UUID+version, update() no-opped
unless the on-disk version was higher, and delete was rejected -- leaving
no way to iterate on a template without bumping its version.
> Note `$updateStatus['to-existing']` is never assigned within this method --
> it is set in getUpdateStatusForTemplate() on a different array -- so the
> second half of the can-be-removed condition is always true. Left as-is
> rather than changed, since making it meaningful would alter behaviour
> beyond this fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getStatusForMetaTemplate() computed
meta_field_amountandcan-be-removedat the very end of the method, after two early returns. One of those fires whenever the stored version is not older than the one on disk:MetaTemplatesController::delete() then rejects the request:
So a template holding no meta-fields at all could not be deleted whenever the stored and on-disk versions matched -- which is the ordinary state of any template nobody has edited. The error message gives no hint that the version comparison is responsible.
Removability depends on whether values exist, not on version, so the computation is moved above the early returns. The
empty($template)branch still forces false, as before.Practical effect: template authoring regains a reset. Previously createNewTemplate refused an existing UUID+version, update() no-opped unless the on-disk version was higher, and delete was rejected -- leaving no way to iterate on a template without bumping its version.