Collections functions
General functions
Render functions
Theme permission functions
Resource functions

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 6297 to 6321

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 30th January 2023 07:05 Europe/London time based on the source file dated 6th January 2023 19:05 Europe/London time.