Content removal: permission and count checks
Read this page if you upgrade an installation to 6.0.15, if you give roles a limited content/remove policy, if you
override design:node/removeobject.tpl, or if you call eZContentObjectTreeNode::removeSubtrees() from your own code.
What changed
- A limited
content/removepolicy is enforced on the confirmed removal, not only on the confirmation page. Before, the check ran only when the removal information was collected for display. A confirmed removal of an entry whose subtree the policy does not fully cover could still go through. Now the removal view asks the removal information first and shows the confirmation page again instead of removing;removeSubtrees()skips such an entry and writes one warning naming its node ID. It still returnstrue. - The standard removal page states the refusal. When the user may not remove everything, it shows "Insufficient permissions" and disables the Confirm button.
- Child counts include what the user cannot read. The counts on the confirmation (
child_count,total_child_countand theMaxNodesRemoveSubtreecheck) come from one query without permission, visibility or language filter. Removing the location list also asks for confirmation when any node is below, readable or not. - The "Move to trash" checkbox disappears when nothing would go to the trash. The figure behind it
(
subtreeSoleNodeCount()) used to count over the whole tree, so the checkbox was shown for a removal of secondary locations only. It now counts the selected subtree. An object whose every location is selected counts as going to the trash. - A subtree removal also removes objects that are not translated into the siteaccess languages, including in a
siteaccess with
ShowUntranslatedObjectsdisabled. Before, such objects were refused or left behind without a node. - A stale node ID in the selection no longer resets the reverse-relation count of the other entries to 0.
Who is affected
- Roles with a
content/removepolicy limited by class, section, subtree or owner. Removals that were accepted by mistake are now refused. - Templates and extensions that read the removal information:
child_countandtotal_child_countcan be higher than before, andmove_to_trashis now false where it used to be true. - Overrides of
design:node/removeobject.tpl. The default design passesdisabledto the Confirm button whenremove_info.can_remove_allis false; an override that ignores this still cannot remove, but shows no reason. - Code that calls
removeSubtrees()and expected atruereturn to mean "everything was removed".
What to check when you upgrade
- Sign in as a user with a limited remove policy and try to remove a subtree the policy only partly covers. The page must state the refusal and the Confirm button must be disabled.
- Check the removal confirmation of a tree with items the user cannot read: the counts must include them.
- Remove a secondary location only: the "Move to trash" checkbox must be absent.
- Compare your
MaxNodesRemoveSubtreesetting with the new counts; it may now trigger earlier. - Review overrides of
node/removeobject.tplagainst the standard template. - Clear the template and template-override caches.
Code
- New:
eZContentObjectTreeNode::subtreeTotalNodeCount()returns the number of nodes below the node as anint, with no permission, visibility or language filter. - Changed:
subtreeSoleNodeCount()reads path and depth from the node itself, runs one query and returns anint. - Changed:
reverseRelatedCount()skips node IDs that no longer exist and returns0when none is left. - Changed:
removeSubtrees()as described above; the information array keeps its keys,real_child_countkeeps its meaning. - Changed:
kernel/private/classes/views/content/removeobject.php,action.phpanddesign/standard/templates/node/removeobject.tpl.