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

get_resources_to_validate()

Description

Get an array of all resources that require files to be validated

Parameters

ColumnTypeDefaultDescription
$days int Return only resources not validated in the last X number of days
$GLOBALS["file_integrity_ignore_resource_types"]

Return

array *

Location

include/resource_functions.php lines 9570 to 9605

Definition

 
function get_resources_to_validate(int $days 0): array
{
    
$params = [];
    
$filtersql "";
    
$restypes_ignore array_unique(array_merge(
        
$GLOBALS["data_only_resource_types"],
        
$GLOBALS["file_integrity_ignore_resource_types"])
        );

    if (
count($GLOBALS["file_integrity_ignore_states"]) > 0) {
        
$filtersql .= " AND archive NOT IN (" ps_param_insert(count($GLOBALS["file_integrity_ignore_states"])) . ")";
        
$params array_merge($params,ps_param_fill($GLOBALS["file_integrity_ignore_states"], "i"));
    }

    if(
count($restypes_ignore) > 0) {
        
$filtersql .= " AND resource_type NOT IN (" ps_param_insert(count($restypes_ignore)) . ")";
        
$params array_merge($params,ps_param_fill($restypes_ignore"i"));
    }

    if(
$days 0) {
        
$filtersql .= " AND (last_verified IS NULL OR DATEDIFF(NOW(), last_verified) > ?)";
        
$params array_merge($params,["i"$days]);
    }

    return 
ps_query("SELECT ref,
                            archive,
                            file_extension,
                            resource_type,
                            file_checksum,
                            last_verified,
                            integrity_fail
                    FROM resource
                    WHERE ref > 0 AND no_file = 0 
{$filtersql}
                    ORDER BY integrity_fail DESC, last_verified ASC"
,
                    
$params);
}

This article was last updated 29th May 2024 09:05 Europe/London time based on the source file dated 24th May 2024 10:10 Europe/London time.