Collections functions
General functions
Render functions
Theme permission functions
Resource functions

delete_unused_non_fixed_list_nodes()

Description

Delete unused non-fixed list field nodes with a 1:1 resource association

Parameters

ColumnTypeDefaultDescription
$resource_type_field integer Resource type field (metadata field) ID

Location

include/node_functions.php lines 2503 to 2523

Definition

 
function delete_unused_non_fixed_list_nodes(int $resource_type_field)
    {
    if(
$resource_type_field <= 0)
        {
        return;
        }

    
// Delete nodes that no longer have a resource association
    
ps_query(
           
'DELETE n
              FROM node AS n
        INNER JOIN resource_type_field AS rtf ON n.resource_type_field = rtf.ref
         LEFT JOIN resource_node AS rn ON rn.node = n.ref
             WHERE n.resource_type_field = ?
               AND rtf.`type`IN (' 
ps_param_insert(count(NON_FIXED_LIST_SINGULAR_RESOURCE_VALUE_FIELD_TYPES)) . ')
               AND rn.node IS NULL'
,
        
array_merge(['i'$resource_type_field], ps_param_fill(NON_FIXED_LIST_SINGULAR_RESOURCE_VALUE_FIELD_TYPES'i'))
    );
    
remove_invalid_node_keyword_mappings();
    
clear_query_cache('schema');
    }

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