Collections functions
General functions
Render functions
Theme permission 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 2563 to 2588

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))
                {
                if(!isset(
$count[$node]) ||  $count[$node] == 0)
                    {
                    
debug("Deleting unused node #" $node" - (" $nodeinfo["name"] . ")");
                    
delete_node($node);
                    }
                }
            }
        }
    }

This article was last updated 3rd October 2022 12:35 Europe/London time based on the source file dated 30th September 2022 14:20 Europe/London time.