Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 2625 to 2649

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 5th December 2024 07:05 Europe/London time based on the source file dated 28th November 2024 12:10 Europe/London time.