cleanup_anonymous_collections()

Description

Remove all old anonymous collections

Parameters

ColumnTypeDefaultDescription
$limit int 100 Maximum number of collections to delete - if run from browser this is kept low to avoid delays

Return

void

Location

include/collections_functions.php lines 5841 to 5861

Definition

 
function cleanup_anonymous_collections(int $limit 100)
{
    global 
$anonymous_login;

    
$sql_limit "";
    
$params = [];
    if (
$limit != 0) {
        
$sql_limit 'LIMIT ?';
        
$params = ['i'$limit];
    }

    if (!
is_array($anonymous_login)) {
        
$anonymous_login = array($anonymous_login);
    }
    foreach (
$anonymous_login as $anonymous_user) {
        
$user get_user_by_username($anonymous_user);
        if (
is_int_loose($user)) {
            
ps_query("DELETE FROM collection WHERE user = ? AND created < (curdate() - interval '2' DAY) ORDER BY created ASC " $sql_limitarray_merge(['i'$user], $params));
        }
    }
}

This article was last updated 22nd April 2025 21:35 Europe/London time based on the source file dated 17th April 2025 18:30 Europe/London time.