Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

check_delete_nodes()

Description

Check array of nodes and delete any that relate to non-fixed list fields and are unused

Parameters

ColumnTypeDefaultDescription
$nodes array Array of node IDs

Location

include/node_functions.php lines 2607 to 2631

Definition

 
function check_delete_nodes($nodes)
    {
    global 
$FIXED_LIST_FIELD_TYPES;
    
debug_function_call('check_delete_nodes',func_get_args());
    
    
// Check and delete unused nodes
    
$count get_nodes_use_count($nodes);
    foreach(
$nodes as $node)
        {
        
$nodeinfo = [];
        
get_node($node,$nodeinfo);
        if(isset(
$nodeinfo["resource_type_field"]))
            {
            
$fieldinfo  get_resource_type_field($nodeinfo["resource_type_field"]);
            
debug("check_delete_nodes: checking node " $node " - (" $nodeinfo["name"] . ")");
            if (
                !
in_array($fieldinfo["type"],$FIXED_LIST_FIELD_TYPES)
                && (!isset(
$count[$node]) ||  $count[$node] == 0)
                ) {
                    
debug("Deleting unused node #" $node" - (" $nodeinfo["name"] . ")");
                    
delete_node($node);
                }
            }
        }
    }

This article was last updated 19th March 2024 06:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.