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 9585 to 9620

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 8th May 2024 21:35 Europe/London time based on the source file dated 8th May 2024 11:40 Europe/London time.